Skip to content
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

Validate against invalid rule schema defaults in RuleTester #11473

Closed
not-an-aardvark opened this issue Mar 4, 2019 · 2 comments

Comments

Projects
2 participants
@not-an-aardvark
Copy link
Member

commented Mar 4, 2019

The version of ESLint you are using.

v5.15.0

The problem you want to solve.

As of v5.14.0, we allow rule schemas to include the default keyword to specify default options. However, it's easy for a rule author to inadvertently use the default keyword in a place where the keyword is ignored, resulting in a buggy rule. (Also see: #11427)

Your take on the correct solution to problem.

When we validate rule schemas in RuleTester, we should use the new strictDefaults option in Ajv to raise an error if a rule schema has an invalid default keyword.

This is a breaking change for users who use RuleTester, because RuleTester would sometimes start reporting additional validation errors. However, rules themselves would still work as before, even if they contain invalid defaults. Additionally, the impact is expected to be very low since we only added support for the default keyword recently.

Are you willing to submit a pull request to implement this change?

Yes

@aladdin-add

This comment has been minimized.

Copy link
Member

commented Mar 4, 2019

And, we can enable validateSchema: true in rule tester.

eslint/lib/util/ajv.js

Lines 18 to 25 in b00a5e9

const ajv = new Ajv({
meta: false,
useDefaults: true,
validateSchema: false,
missingRefs: "ignore",
verbose: true,
schemaId: "auto"
});

@ilyavolodin ilyavolodin moved this from Needs discussion to Accepted, ready to implement in v6.0.0 Mar 14, 2019

@not-an-aardvark

This comment has been minimized.

Copy link
Member Author

commented Mar 15, 2019

This proposal was accepted in yesterday's TSC meeting.

@not-an-aardvark not-an-aardvark added accepted and removed evaluating labels Mar 15, 2019

not-an-aardvark added a commit that referenced this issue Apr 7, 2019

@not-an-aardvark not-an-aardvark moved this from Accepted, ready to implement to Implemented, pending review in v6.0.0 Apr 7, 2019

v6.0.0 automation moved this from Implemented, pending review to Done Apr 9, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.