-
-
Notifications
You must be signed in to change notification settings - Fork 3
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
feat: add rule no-unnormalized-keys #38
base: main
Are you sure you want to change the base?
Conversation
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.
Can you add the rule to the plugin (otherwise, it could not be used):
Lines 29 to 32 in cac8847
rules: { | |
"no-duplicate-keys": noDuplicateKeys, | |
"no-empty-keys": noEmptyKeys, | |
}, |
And, also add it to the docs:
Lines 153 to 156 in cac8847
## Rules | |
- `no-duplicate-keys` - warns when there are two keys in an object with the same text. | |
- `no-empty-keys` - warns when there is a key in an object that is an empty string or contains only whitespace (note: `package-lock.json` uses empty keys intentionally) |
@@ -0,0 +1,61 @@ | |||
/** | |||
* @fileoverview Tests for no-empty-keys rule. |
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.
* @fileoverview Tests for no-empty-keys rule. | |
* @fileoverview Tests for no-unnormalized-keys rule. |
schema: { | ||
type: "array", | ||
minItems: 0, | ||
maxItems: 1, | ||
items: { | ||
enum: ["NFC", "NFD", "NFKC", "NFKD"], | ||
}, | ||
}, |
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.
schema: { | |
type: "array", | |
minItems: 0, | |
maxItems: 1, | |
items: { | |
enum: ["NFC", "NFD", "NFKC", "NFKD"], | |
}, | |
}, | |
schema: [ | |
{ | |
enum: ["NFC", "NFD", "NFKC", "NFKD"], | |
}, | |
], |
This can be simplified by using the shorthand form (https://eslint.org/docs/latest/extend/custom-rules#options-schemas, the first format).
const key = | ||
node.name.type === "String" | ||
? node.name.value | ||
: node.name.name; |
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.
Can you add an invalid
test where node.name
is an Identifier node?
@bmeck there's feedback for you here. |
@bmeck are you still working on this? |
I'm going to finish this up. |
Prerequisites checklist
What is the purpose of this pull request?
To add a rule to check for JSON keys that are not normalized.
What changes did you make? (Give an overview)
Added a rule to check for JSON keys that are not normalized.
Related Issues
Fixes #32
Is there anything you'd like reviewers to focus on?
Couldn't get options working on invalid test cases?