Skip to content

feat(eslint-plugin): add rule 'sort-ngmodule-metadata-arrays' for array sort order of modules #386

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 5 commits into from
Apr 11, 2021

Conversation

blingerson
Copy link
Contributor

This is a best practice we have implemented that simply enforces the sorting of identifiers in ngModule arrays. Not sure if non-codelyzer rules would be acceptable for this project, but thought I would give it a try.

Copy link
Member

@JamesHenry JamesHenry 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 @blingerson, this seems like something that would be useful to some folks!

Rather than adding to the README, from now on we would like to ensure that new rules always provide an entry in docs/rules/.

Please could you take a look at the existing example in packages/eslint-plugin/docs/rules and add one for your rule?

@blingerson
Copy link
Contributor Author

@JamesHenry, will do, should I remove the changes from the README as well? Thanks.

@JamesHenry
Copy link
Member

Yes please

@blingerson
Copy link
Contributor Author

Done, I originally had the module class identifiers on separate lines. Perhaps prettier formats the code blocks in the .md files as well?

@nx-cloud
Copy link

nx-cloud bot commented Mar 28, 2021

Nx Cloud Report

CI ran the following commands for commit ed93f9b. Click to see the status, the terminal output, and the build insights.

📂 See all runs for this branch

Status Command
#000000 nx run-many --target=build --all --parallel
#000000 nx run-many --target=check-configs --all --parallel
#000000 nx run-many --target=test --all --parallel
#000000 nx run-many --target=typecheck --all --parallel

Sent with 💌 from NxCloud.

Copy link
Member

@rafaelss95 rafaelss95 left a comment

Choose a reason for hiding this comment

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

Hello @blingerson, thanks for your contribution. I commented on some points that I found relevant. Please have a look.

@blingerson blingerson changed the title feat: add rule 'ngmodule-array-sorted' for array sort order of modules feat: add rule 'sort-ngmodule-arrays' for array sort order of modules Mar 29, 2021
@blingerson blingerson requested a review from JamesHenry March 29, 2021 22:50
rafaelss95
rafaelss95 previously approved these changes Mar 30, 2021
Copy link
Member

@rafaelss95 rafaelss95 left a comment

Choose a reason for hiding this comment

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

LGTM with some minor nits in this review and others commented earlier. 🚀

@rafaelss95
Copy link
Member

rafaelss95 commented Mar 30, 2021

I sent the review again, as it gets outdated after the files were renamed.

@blingerson
Copy link
Contributor Author

Ok, hopefully I got all the small issues and semantic stuff this time.

@blingerson blingerson force-pushed the master branch 2 times, most recently from a1e604a to 0fa0f43 Compare March 30, 2021 19:43
@blingerson
Copy link
Contributor Author

Sorry for the ugly git history guys, I realize now I clicked the update with master button which complicates my ability to squash. If it is easier for me to just create a new fork with a clean set of changes in a single commit I don't mind. let me know how you would like me to proceed

@blingerson
Copy link
Contributor Author

blingerson commented Mar 30, 2021

@rafaelss95 @JamesHenry Ok, was able to fix up the commit history without doing any harm with some git magic. Thanks for bearing with me. Next time I will read the gitflow best practices FIRST. ;)

@JamesHenry
Copy link
Member

@blingerson we always squash merge so your history on PRs doesn’t matter.

In fact it’s kind of the opposite - I always encourage folks not to rebase and force push once a PR is already in review because you force the reviewer to start from scratch

@JamesHenry
Copy link
Member

I’ll give this a review tomorrow, thanks for working through the feedback!

@blingerson
Copy link
Contributor Author

blingerson commented Mar 30, 2021

Ok, @JamesHenry noted for next time. I have 1 more rule I would like to propose and on that one I will keep my messy git history once review starts instead of rebasing /force pushing like I did here (eventually). Next rule is also for NgModule and is "no-empty-ngmodule-arrays" Shouldn't take me long now that I have written an eslint rule and understand the process better.

@blingerson
Copy link
Contributor Author

@JamesHenry / @rafaelss95 let me know if you need any more changes (and I won't erase your review history this time) And also thank you for making it possible to so effortlessly write angular linter rules!

@rafaelss95
Copy link
Member

Ok, @JamesHenry noted for next time. I have 1 more rule I would like to propose and on that one I will keep my messy git history once review starts instead of rebasing /force pushing like I did here (eventually). Next rule is also for NgModule and is "no-empty-ngmodule-arrays" Shouldn't take me long now that I have written an eslint rule and understand the process better.

James can have another opinion here, but I'd recommend creating an issue before starting the implementation.

@JamesHenry / @rafaelss95 let me know if you need any more changes (and I won't erase your review history this time) And also thank you for making it possible to so effortlessly write angular linter rules!

@JamesHenry Looking at it again, would it be weird to call it as sort-ngmodule-metadata-arrays to make it clear that sorting should be done on the internal content of the arrays? I'm just asking because I'm afraid that in the current way, people could interpret it as if it were the ordering of NgModule arrays, that is, the bootstrap should be on top, followed by declarations and so on.

Apart of this, from my side everything seems okay. Thank you! :)

@blingerson
Copy link
Contributor Author

@rafaelss95, noted, will create an issue for the next proposed feature

@JamesHenry
Copy link
Member

@rafaelss95 @blingerson - sure, let's go for sort-ngmodule-metadata-arrays. Sorry for the extra work @blingerson, thank you for being patient on this PR!

Co-authored-by: James Henry <james@henry.sc>
@rafaelss95 rafaelss95 changed the title feat: add rule 'sort-ngmodule-arrays' for array sort order of modules feat: add rule 'sort-ngmodule-metadata-arrays' for array sort order of modules Apr 6, 2021
@rafaelss95 rafaelss95 changed the title feat: add rule 'sort-ngmodule-metadata-arrays' for array sort order of modules feat(eslint-plugin): add rule 'sort-ngmodule-metadata-arrays' for array sort order of modules Apr 6, 2021
Copy link
Member

@JamesHenry JamesHenry left a comment

Choose a reason for hiding this comment

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

Thanks again!

@JamesHenry JamesHenry enabled auto-merge (squash) April 11, 2021 12:55
@JamesHenry JamesHenry disabled auto-merge April 11, 2021 13:04
@JamesHenry JamesHenry merged commit 935afdd into angular-eslint:master Apr 11, 2021
@blingerson
Copy link
Contributor Author

Thank you as well!

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