create-deprecated-rules.js 665 B

12345678910111213141516171819202122232425
  1. 'use strict';
  2. const packageJson = require('../../package.json');
  3. const repoUrl = 'https://github.com/sindresorhus/eslint-plugin-unicorn';
  4. /** @returns {{ [ruleName: string]: import('eslint').Rule.RuleModule }} */
  5. function createDeprecatedRules(data) {
  6. return Object.fromEntries(
  7. Object.entries(data).map(([ruleId, replacedBy = []]) => [
  8. ruleId,
  9. {
  10. create: () => ({}),
  11. meta: {
  12. docs: {
  13. url: `${repoUrl}/blob/v${packageJson.version}/docs/deprecated-rules.md#${ruleId}`,
  14. },
  15. deprecated: true,
  16. replacedBy: Array.isArray(replacedBy) ? replacedBy : [replacedBy],
  17. },
  18. },
  19. ]),
  20. );
  21. }
  22. module.exports = createDeprecatedRules;