8000 fix(eslint-plugin): [sort-ngmodule-metadata-arrays]: properly handle multiple fixes at once by rafaelss95 · Pull Request #695 · angular-eslint/angular-eslint · GitHub
[go: up one dir, main page]

Skip to content

fix(eslint-plugin): [sort-ngmodule-metadata-arrays]: properly handle multiple fixes at once #695

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

Conversation

rafaelss95
Copy link
Member

Fixes #675 (there's more context there on this change).

@nx-cloud
Copy link
nx-cloud bot commented Sep 20, 2021

},
fixable: 'code',
schema: [],
messages: {
sortNgmoduleMetadataArrays:
'`NgModule` metadata arrays should be sorted in ASC alphabetical order',
suggestFix: 'Sort members (WARNING! comments will probably be messed up)',
Copy link
Member Author

Choose a reason for hiding this comment

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

Please, suggest a better messageId/description if that's the case.

Comment on lines +55 to +57
...(hasComments
? { suggest: [{ messageId: 'suggestFix', fix }] }
: { fix }),
Copy link
Member Author
@rafaelss95 rafaelss95 Sep 20, 2021

Choose a reason for hiding this comment

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

I even tried to use fix, even if there were comments, but besides being very costly to maintain such an implementation, it's also very prone to failure. 😞

Example of hard cases can be found here, for example.

Copy link
Member Author
@rafaelss95 rafaelss95 Sep 20, 2021

Choose a reason for hiding this comment

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

One thing that came to mind now is, since this is something we have control over and wouldn't cause any compilation errors if applied, we could add an option called something like alwaysFixEvenWithComments/forceFix (I'm really bad at naming) to the rule to ignore comments and always fix the reports. It would be false by default, of course.

Let me know what you think, so I can send another PR for this if that's the case.

AppModule1,
AppModule2,
Copy link
Member Author

Choose a reason for hiding this comment

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

This change is due to the fact that the fixer now, fixes everything at once, not one-by-one as previously.

Comment on lines +219 to +222
bProvider,
cProvider,
DProvider,
~~~~~~~~~
Copy link
Member Author

Choose a reason for hiding this comment

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

This change is due to the fact that the fixer now, puts everything that isn't a Identifier at the end, to avoid conflicts and simplify the implementation.

@codecov
Copy link
codecov bot commented Sep 20, 2021

Codecov Report

Merging #695 (5770576) into master (8ac2193) will increase coverage by 0.09%.
The diff coverage is 100.00%.

❗ Current head 5770576 differs from pull request most recent head 6ddb806. Consider uploading reports for the commit 6ddb806 to get more accurate results

@@            Coverage Diff             @@
##           master     #695      +/-   ##
==========================================
+ Coverage   85.37%   85.47%   +0.09%     
==========================================
  Files          83       83              
  Lines        1922     1935      +13     
  Branches      339      341       +2     
==========================================
+ Hits         1641     1654      +13     
  Misses        170      170              
  Partials      111      111              
Impacted Files Coverage Δ
...-plugin/src/rules/sort-ngmodule-metadata-arrays.ts 100.00% <100.00%> (ø)

@rafaelss95 rafaelss95 force-pushed the fix/sort-ngmodule-metadata-arrays-part-3 branch from 115d84a to 6ddb806 Compare September 22, 2021 15:28
@rafaelss95 rafaelss95 marked this pull request as draft September 23, 2021 13:53
@JamesHenry
Copy link
Member

I emailed Rafael about 2 months ago asking if wished to continue working on this but sadly have not received a response in that time. I will therefore close this so that it is clear that it is not being worked on and that somebody else can pick this up if it is important to them.

Many thanks to Rafael for his fantastic contributions to angular-eslint to date 🙏

7ED9

@JamesHenry JamesHenry closed this Nov 14, 2022
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.

[sort-ngmodule-metadata-arrays] --fix not able to correct all the reports once
2 participants
0