-
Notifications
You must be signed in to change notification settings - Fork 56
feat: all rules: #214: Warn the user/Throw an error when a group entered in config does not exist #232
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
eeb9c95 to
6c7b5c2
Compare
6c7b5c2 to
1f8c50a
Compare
azat-io
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice job! ❤️
| { | ||
| ...options, | ||
| customGroups: { top: ['c', 'b'] }, | ||
| groups: ['top', 'unknown'], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why remove 'unknown'?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed. Mistake on my part.
| import { validateGroupsConfiguration } from '../utils/validate-groups-configuration' | ||
|
|
||
| /** | ||
| * It is currently not possible to test rules that throw errors (https://github.com/eslint/eslint/issues/13434), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's try to stick to the 80 character line length limit rule as stated in the prettier config?
I suggest breaking the comment down into a few lines.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
1f8c50a to
8aad99e
Compare
8aad99e to
2009810
Compare
|
Great. Thank you! |
Description
Resolves (partially) #214. The
sort-classesrule is not part of this PR as checking if a group entered by the user is part of predefined groups requires a more complex strategy which I believe deserves its own PR.Checks and validates group configuration for rules using
groups. Configurations referencing groups that arecustomGroupsare very likely user mistakes or typos. These groups are considered invalid and will throw an error, stopping ESLint.
Affected rules:
sort-astro-attributessort-importssort-interfacessort-intersection-typessort-jsx-propssort-object-typessort-objectsort-svelte-attributessort-union-typessort-vue-attributesRemaining to do:
Additional context
Some tests have been slightly changed as they were referencing invalid groups. In those cases, invalid groups were removed from the test configuration.
Ideally, we should be testing that invalid group configurations throw an error for each rule. Unfortunately, it is currently not possible to test rules that throw errors (Add ability to test rule schemas eslint/eslint#13434 | feat: ability to test rule errors and invalid schemas eslint/eslint#16823). Furthermore, getting 100% code coverage in
validateGroupsConfiguration.tsis not possible only through ESLint's RuleTester as there is no way to catchthe error thrown. We get 100% coverage temporarily in that file with a simple unit test in
validateGroupsConfiguration.test.tsuntil that feature is implemented in ESLint.What is the purpose of this pull request?