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

Mark deprecated rules as deprecated in their metadata #911

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions lib/rules/no-comment-textnodes.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ var isWarnedForDeprecation = false;

module.exports = {
meta: {
deprecated: true,
docs: {
description: 'Comments inside children section of tag should be placed inside braces',
category: 'Possible Errors',
Expand Down
1 change: 1 addition & 0 deletions lib/rules/require-extension.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ var PKG_REGEX = /^[^\.]((?!\/).)*$/;

module.exports = {
meta: {
deprecated: true,
docs: {
description: 'Restrict file extensions that may be required',
category: 'Stylistic Issues',
Expand Down
1 change: 1 addition & 0 deletions lib/rules/wrap-multilines.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ var isWarnedForDeprecation = false;

module.exports = {
meta: {
deprecated: true,
docs: {
description: 'Prevent missing parentheses around multilines JSX',
category: 'Stylistic Issues',
Expand Down
14 changes: 14 additions & 0 deletions tests/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,20 @@ describe('all rule files should be exported by the plugin', function() {
});
});

describe('deprecated rules', function() {
it('marks all deprecated rules as deprecated', function() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if we should just use the deprecated property to dynamically build up the deprecatedRules list?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lol i see this in your OP now. yeah i think it might be worth it - getAllRules().filter(x => x.deprecated) seems like it should be a viable approach

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't have a getAllRules() function here, but I'll take another run at this and see what I can come up with. I agree that the duplicated knowledge of which rules are deprecated is not ideal.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ljharb OK, here's what I came up with: 33aa4d5. Let me know what you think.

ruleFiles.forEach(function(ruleName) {
var inDeprecatedRules = Boolean(plugin.deprecatedRules[ruleName]);
var isDeprecated = plugin.rules[ruleName].meta.deprecated;
if (inDeprecatedRules) {
assert(isDeprecated, ruleName + ' metadata should mark it as deprecated');
} else {
assert(!isDeprecated, ruleName + ' metadata should not mark it as deprecated');
}
});
});
});

describe('configurations', function() {
it('should export a \'recommended\' configuration', function() {
assert(plugin.configs.recommended);
Expand Down