-
-
Notifications
You must be signed in to change notification settings - Fork 4.4k
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 test deprecation warnings: fn-style rules/missing schema #15761
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -521,6 +521,10 @@ class RuleTester { | |
].concat(scenarioErrors).join("\n")); | ||
} | ||
|
||
if (typeof rule === "function") { | ||
// eslint-disable-next-line no-console -- needed for temporary deprecation warning before this is converted into an assert | ||
console.warn("DEPRECATION WARNING: This rule is using the deprecated function-style format and will stop working in ESLint v9. Please convert to object-style rules: https://eslint.org/docs/developer-guide/working-with-rules This lint rule can assist with the conversion: https://github.com/not-an-aardvark/eslint-plugin-eslint-plugin/blob/main/docs/rules/prefer-object-rule.md"); | ||
} | ||
|
||
linter.defineRule(ruleName, Object.assign({}, rule, { | ||
|
||
|
@@ -578,6 +582,10 @@ class RuleTester { | |
|
||
if (hasOwnProperty(item, "options")) { | ||
assert(Array.isArray(item.options), "options must be an array"); | ||
if (!rule.schema) { | ||
// eslint-disable-next-line no-console -- needed for temporary deprecation warning before this is converted into an assert | ||
console.warn("DEPRECATION WARNING: This test case specifies `options` but the rule is missing `meta.schema` and will stop working in ESLint v9. Please add `meta.schema`: https://eslint.org/docs/developer-guide/working-with-rules#options-schemas This lint rule can assist with the conversion: https://github.com/not-an-aardvark/eslint-plugin-eslint-plugin/blob/main/docs/rules/require-meta-schema.md"); | ||
Comment on lines
+586
to
+587
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This assumes that the warning message will be logged right after the test title, but that doesn't have to be the case. For example, if you run mocha with
The problem is that there's no info about which rule is the cause of the warnings. We could add |
||
} | ||
config.rules[ruleName] = [1].concat(item.options); | ||
} else { | ||
config.rules[ruleName] = 1; | ||
|
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.
I think we shouldn't log the warning if
item.options
is an empty array, as that's basically the same as if no options had been passed.