Skip to content

Commit

Permalink
Fix deprecated rules (#968)
Browse files Browse the repository at this point in the history
  • Loading branch information
fisker authored and sindresorhus committed Dec 30, 2020
1 parent 7392174 commit c898f7a
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 6 deletions.
8 changes: 4 additions & 4 deletions docs/deprecated-rules.md
@@ -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
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
Expand Up @@ -16,6 +16,8 @@ function createDeprecatedRules(data) {
}
};
}

return rules;
}

module.exports = createDeprecatedRules;
8 changes: 7 additions & 1 deletion test/package.js
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);
});

0 comments on commit c898f7a

Please sign in to comment.