Skip to content
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
1 change: 0 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
const rules = toEslintRules(rawRules);

const deprecatedRules = createDeprecatedRules({
// {ruleId: {message: string, replacedBy: string[]}}
'no-instanceof-array': {
message: 'Replaced by `unicorn/no-instanceof-builtins` which covers more cases.',
replacedBy: ['unicorn/no-instanceof-builtins'],
Expand Down Expand Up @@ -78,7 +77,7 @@
unopinionated: createConfig(unopinionatedRules, 'unicorn/unopinionated'),
all: createConfig(allRules, 'unicorn/all'),

// TODO: Remove this at some point. Kept for now to avoid breaking users.

Check warning on line 80 in index.js

View workflow job for this annotation

GitHub Actions / update-snapshots

Unexpected 'todo' comment: 'TODO: Remove this at some point. Kept...'

Check warning on line 80 in index.js

View workflow job for this annotation

GitHub Actions / lint

Unexpected 'todo' comment: 'TODO: Remove this at some point. Kept...'

Check warning on line 80 in index.js

View workflow job for this annotation

GitHub Actions / lint

Unexpected 'todo' comment: 'TODO: Remove this at some point. Kept...'
'flat/recommended': createConfig(recommendedRules, 'unicorn/flat/recommended'),
'flat/all': createConfig(allRules, 'unicorn/flat/all'),
};
Expand Down
8 changes: 7 additions & 1 deletion rules/utils/create-deprecated-rules.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import getDocumentationUrl from './get-documentation-url.js';
import packageJson from '../../package.json' with {type: 'json'};

const repoUrl = 'https://github.com/sindresorhus/eslint-plugin-unicorn';
Expand All @@ -20,7 +21,12 @@ export default function createDeprecatedRules(rules) {
deprecated: {
message: deprecatedInfo.message,
url,
replacedBy: deprecatedInfo.replacedBy,
replacedBy: deprecatedInfo.replacedBy.map(replacementRuleId => ({
rule: {
name: replacementRuleId,
url: getDocumentationUrl(replacementRuleId),
},
})),
},
},
},
Expand Down
6 changes: 6 additions & 0 deletions test/package.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,12 @@ test('Every deprecated rules listed in docs/deleted-and-deprecated-rules.md', as
t.deepEqual(rule.create(), {}, `${name} create should return empty object`);
t.is(typeof rule.meta.deprecated.message, 'string', `${name} meta.deprecated.message should be string`);
t.true(Array.isArray(rule.meta.deprecated.replacedBy), `${name} meta.deprecated.replacedBy should be array`);

for (const replacement of rule.meta.deprecated.replacedBy) {
t.is(typeof replacement.rule.name, 'string', `${name} meta.deprecated.replacedBy[].rule.name should be string`);
t.is(typeof replacement.rule.url, 'string', `${name} meta.deprecated.replacedBy[].rule.url should be string`);
}

t.true(content.includes(`\n### ${name}\n`));
t.false(content.includes(`\n### ~${name}~\n`));
}
Expand Down
Loading