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

Fix deprecated rules #968

Merged
merged 2 commits into from
Dec 29, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
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
8 changes: 4 additions & 4 deletions docs/deprecated-rules.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
# Deprecated Rules

## no-fn-reference-in-iterator

This rule was renamed to [`no-array-callback-reference`](rules/no-array-callback-reference.md) to avoid using the abbreviation `fn` in the name.

## no-array-instanceof

This rule was renamed to [`no-instanceof-array`](rules/no-instanceof-array.md) to be more correct.

## no-fn-reference-in-iterator

This rule was renamed to [`no-array-callback-reference`](rules/no-array-callback-reference.md) to avoid using the abbreviation `fn` in the name.

## no-reduce

This rule was renamed to [`no-array-reduce`](rules/no-array-reduce.md) to be more specific.
Expand Down
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ const deprecatedRules = createDeprecatedRules({
'no-array-instanceof': 'unicorn/no-instanceof-array',
'no-fn-reference-in-iterator': 'unicorn/no-array-callback-reference',
'no-reduce': 'unicorn/no-array-reduce',
'prefer-dataset': 'unicorn/prefer-dom-node-dataset',
'prefer-event-key': 'unicorn/prefer-keyboard-event-key',
'prefer-exponentiation-operator': 'prefer-exponentiation-operator',
'prefer-dataset': 'unicorn/prefer-dom-node-dataset',
'prefer-flat-map': 'unicorn/prefer-array-flat-map',
'prefer-node-append': 'unicorn/prefer-dom-node-append',
'prefer-node-remove': 'unicorn/prefer-dom-node-remove',
Expand Down
2 changes: 2 additions & 0 deletions rules/utils/create-deprecated-rules.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ function createDeprecatedRules(data) {
}
};
}

return rules;
}

module.exports = createDeprecatedRules;
8 changes: 7 additions & 1 deletion test/package.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ test('Every rule is defined in index file in alphabetical order', t => {
}

t.is(
Object.keys(index.rules).length,
Object.keys(index.rules).length - deprecatedRules.length,
ruleFiles.length,
'There are more exported rules than rule files.'
);
Expand Down Expand Up @@ -111,3 +111,9 @@ test('Every rule has valid meta.type', t => {
t.true(validTypes.includes(rule.meta.type), `${name} meta.type is not one of [${validTypes.join(', ')}]`);
}
});

test('Every deprecated rules listed in docs/deprecated-rules.md', t => {
const content = fs.readFileSync('docs/deprecated-rules.md', 'utf8');
const rulesInMarkdown = content.match(/(?<=^## ).*?$/gm);
t.deepEqual(deprecatedRules, rulesInMarkdown);
});