-
-
Notifications
You must be signed in to change notification settings - Fork 4.6k
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Update: remove invalid defaults from core rules (fixes #11415) #11427
Conversation
Ajv ignores the `default` property in JSON schemas when it appears inside `oneOf`, `anyOf`, or `not`. This commit removes ignored `default` properties and fixes a few bugs in rules that were incorrectly assuming the `default` properties would get processed.
Do we plan to report this upstream? Seems ajv could go back and apply defaults once it has identified which schema is being used. |
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.
LGTM, thanks!
- should the tag be
Fix
? since it seems a bugfix. - it would not hurt to add a test to avoid regression.
Lines 2344 to 2356 in f6ba633
it("should report no violation", () => { const code = [ "/*eslint-disable no-unused-vars */", "var foo; // eslint-disable-line no-unused-vars", "var bar;", "/* eslint-enable no-unused-vars */" // here ].join("\n"); const config = { rules: { "no-unused-vars": 2 } }; const messages = linter.verify(code, config, filename); assert.strictEqual(messages.length, 0); });
This is intentional behavior in Ajv (see here). The commit tag is @aladdin-add I'm not sure what kind of test you mean. I did add some tests for rules that had behavior changes -- are there other tests you would recommend? (I suppose we could possibly enhance |
sorry for unclear, I mean adding a test like in the issue: it("should report no violation", () => {
const code =`
var x = 20;
console.log(x >> 5); // eslint-disable-line no-bitwise`;
const config = { rules: { "no-bitwise": "error", } };
const messages = linter.verify(code, config, filename);
assert.strictEqual(messages.length, 0);
}); as to validate the schema, I opened a PR a while ago, but it was closed(#10713). |
Does the test added in Oops, I forgot about #10713. However, it seems like invalid I think my current position relating to that PR is:
|
ooops, sorry, I had misread the code in the issue. (。・∀・)ノ |
What is the purpose of this pull request? (put an "X" next to item)
[x] Bug fix (#11415)
What changes did you make? (Give an overview)
Ajv ignores the
default
property in JSON schemas when it appears insideoneOf
,anyOf
, ornot
. This commit removes ignoreddefault
properties and fixes a few bugs in rules that were incorrectly assuming thedefault
properties would get processed.Is there anything you'd like reviewers to focus on?
Nothing in particular