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
Fix: Warn for deprecation in Node output (fixes #7443) #10953
Changes from 3 commits
3c049d0
8375110
5d0fecf
cd0ee6e
3c72430
7e47529
475a063
f7eb619
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 |
---|---|---|
|
@@ -272,6 +272,28 @@ function createIgnoreResult(filePath, baseDir) { | |
}; | ||
} | ||
|
||
/** | ||
* Produces rule warnings (i.e. deprecation) from configured rules | ||
* @param {Object} rules - Rules configured | ||
* @param {Map} loadedRules - Map of loaded rules | ||
* @returns {Object} Contains rule warnings | ||
* @private | ||
*/ | ||
function createRuleWarnings(rules, loadedRules) { | ||
const ruleWarnings = { usedDeprecatedRules: [] }; | ||
|
||
if (rules) { | ||
Object.keys(rules).forEach(name => { | ||
const loadedRule = loadedRules.get(name); | ||
|
||
if (loadedRule.meta && loadedRule.meta.deprecated) { | ||
ruleWarnings.usedDeprecatedRules.push({ ruleId: name, replacedBy: loadedRule.meta.docs.replacedBy }); | ||
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. Will this work correctly if a rule doesn't have a More generally, I'm wondering if we should move edit: In either case, I think we should also update the Working with Rules page to note the new available options in the rule API. 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. That's a great point about I'm happy to move 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. My personal preference would be to move it to 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. Moving 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. I think we should only include the |
||
} | ||
}); | ||
} | ||
|
||
return ruleWarnings; | ||
} | ||
|
||
/** | ||
* Checks if the given message is an error message. | ||
|
@@ -555,14 +577,17 @@ class CLIEngine { | |
|
||
const stats = calculateStatsPerRun(results); | ||
|
||
const ruleWarnings = createRuleWarnings(this.options.rules, this.getRules()); | ||
|
||
debug(`Linting complete in: ${Date.now() - startTime}ms`); | ||
|
||
return { | ||
results, | ||
errorCount: stats.errorCount, | ||
warningCount: stats.warningCount, | ||
fixableErrorCount: stats.fixableErrorCount, | ||
fixableWarningCount: stats.fixableWarningCount | ||
fixableWarningCount: stats.fixableWarningCount, | ||
usedDeprecatedRules: ruleWarnings.usedDeprecatedRules | ||
}; | ||
} | ||
|
||
|
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.
Could you be more specific in this documentation about what the shape of an object in
usedDeprecatedRules
would look like (namely, that it has aruleId
andreplacedBy
property)?