这是indexloc提供的服务,不要输入任何密码
Skip to content

chore(codestyle): apply prettier to packages #1416

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 18, 2024

Conversation

wermanoid
Copy link
Contributor

A picture tells a thousand words

There is a prettier and .prettierrc.cjs in repo

Before this PR

It was not applied to code, so any change leads to massive file changes

After this PR

Just applied code formatting for packages, so less annoying and unexpected file changes

How to reproduce

run pnpm prettier --write --cache packages

@wermanoid
Copy link
Contributor Author

Slightly unexpected, but I don't know why code in packages was not aligned with configured tool for code styling. In my setup, when formatting is applied on every Ctrl+S it leads to massive changes and huge git diff. So fixing style issue and will add more PR's later

@guillaume-chervet
Copy link
Contributor

Thank you very much @wermanoid for your PullRequest.

I will merge this PullRequest before #1410 and also this one before #1402.

It may impact your PullRequest.

@wermanoid
Copy link
Contributor Author

wermanoid commented Jul 16, 2024

I will keep it up-to-date, so merge anything that is needed :) no problems

Btw, maybe it worth also to check prettier config too? Tbh, this is first time when I see that someone is using tab keys for indentation. Usually it is 2 or 4 whitespaces.

If you don't mind, I can change to this:

  printWidth: 100,
  tabWidth: 2,
  trailingComma: 'all',
  arrowParens: 'avoid',
  endOfLine: 'auto',
  bracketSameLine: false,
  bracketSpacing: true,
  singleQuote: true,
  useTabs: false,
  semi: true,

@jafin
Copy link
Contributor

jafin commented Jul 17, 2024

@wermanoid I would suggest reviewing the prettier config to align to the existing project source, and agree tab should be replaced with whatever the most common existing pattern is in the project, which appears to be 2 spaces not tab.

i.e. treat the project's existing approach as preferred and adjust prettierrc to conform, vs prettier being the point of truth now.
I think I may of added prettier as a placeholder a ways back, and not correctly aligned to project style.

Also, there appears to be a disconnect between ESlint running prettier rules and running prettier externally. Ideally, ESlint should be reading the prettier config and if request autofix with eslint --fix . So I think there is something amiss with the eslint-> prettier config. I did a PR to migrate to ESLint 9 flat config style, so probably have something misconfigured.

@guillaume-chervet does this sound ok?

@jafin
Copy link
Contributor

jafin commented Jul 17, 2024

@wermanoid @guillaume-chervet
I found the issue with eslint not running prettier. If you commit #1419 it will ensure eslint runs prettier.
I haven't made changes to prettier config or applied the prettier autofix, as this is what this PR is for.
pnpm run lint will now show the prettier issues.
pnpm run lint --fix will autofix them

@wermanoid wermanoid closed this Jul 17, 2024
@wermanoid wermanoid reopened this Jul 17, 2024
@wermanoid wermanoid force-pushed the chore/apply-code-style branch 2 times, most recently from f087864 to 98714d7 Compare July 17, 2024 09:22
@wermanoid
Copy link
Contributor Author

wermanoid commented Jul 17, 2024

Updated after all eslint fixes
@jafin @guillaume-chervet , I've modified config to proposed upper and applied that to whole repo (pnpm format in scripts actually).

Also, do I need to fix TS errors that prevents pipeline to pass? Or better to make that as another PR?

@wermanoid wermanoid force-pushed the chore/apply-code-style branch 3 times, most recently from 6bb83bd to 5988cd6 Compare July 17, 2024 09:53
};

public withTestingDefault(): OidcConfigBuilder {
this.oidcConfig.configurationName = 'test';
this.oidcConfig.tokens = new TokenBuilder().withNonExpiredToken().build();
this.oidcConfig.status = 'NOT_CONNECTED';
this.oidcConfig.state = { tab1: 'state' };
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the correct new version is { tab1: 'state' }; in the whole file @wermanoid

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it explain why unit tests are failing @wermanoid

Copy link
Contributor Author

@wermanoid wermanoid Jul 18, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Em... But I didn't touch any code in pr. There was only format... So that is broken is main, but was merged?

Weird... but ok, will try to update

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, updated from clear main branch. Should not introduce anything unexpected now

@guillaume-chervet
Copy link
Contributor

@jafin I do not code a lot in Javascript/typescript these days (unfortunately).

This configuration seems OK to you?

@wermanoid wermanoid force-pushed the chore/apply-code-style branch from 5988cd6 to 8f9629f Compare July 18, 2024 09:33
@wermanoid wermanoid force-pushed the chore/apply-code-style branch from 8f9629f to 042ef3f Compare July 18, 2024 09:34
Copy link
Contributor

@guillaume-chervet guillaume-chervet left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you very much @wermanoid I merge like it and I will fixe the few Types erros in another PullRequest.

@guillaume-chervet guillaume-chervet merged commit e4f4d97 into AxaFrance:main Jul 18, 2024
10 of 13 checks passed
@wermanoid wermanoid deleted the chore/apply-code-style branch July 18, 2024 19:59
@jafin jafin mentioned this pull request Jul 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants