Created
December 28, 2023 08:27
-
-
Save ygkn/ca983350f88cd51eeabf4a25c0301018 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const rules = | |
require("@typescript-eslint/eslint-plugin/use-at-your-own-risk/rules").default; | |
const displayRule = (ruleKey) => { | |
const rule = rules[ruleKey.replace("@typescript-eslint/", "")]; | |
if (!rule) { | |
return ruleKey; | |
} | |
return `${rule.meta.deprecated ? " 💀" : ""} ${ruleKey} - ${ | |
rule.meta.docs.description | |
}`; | |
}; | |
const standard = Object.groupBy( | |
Object.entries( | |
require("./node_modules/eslint-config-standard-with-typescript/lib/").rules, | |
), | |
([key, value]) => (typeof value === "string" ? value : value[0]), | |
); | |
const strict = Object.groupBy( | |
Object.entries( | |
require("./node_modules/@typescript-eslint/eslint-plugin/dist/configs/strict-type-checked") | |
.rules, | |
), | |
([key, value]) => (typeof value === "string" ? value : value[0]), | |
); | |
const stylistic = Object.groupBy( | |
Object.entries( | |
require("./node_modules/@typescript-eslint/eslint-plugin/dist/configs/stylistic-type-checked") | |
.rules, | |
), | |
([key, value]) => (typeof value === "string" ? value : value[0]), | |
); | |
const standardRules = { | |
error: (standard.error ?? []).map(([key, value]) => key), | |
warn: (standard.warn ?? []).map(([key, value]) => key), | |
off: (standard.off ?? []).map(([key, value]) => key), | |
}; | |
const strictRules = { | |
error: (strict.error ?? []).map(([key, value]) => key), | |
warn: (strict.warn ?? []).map(([key, value]) => key), | |
off: (strict.off ?? []).map(([key, value]) => key), | |
}; | |
const stylisticRules = { | |
error: (stylistic.error ?? []).map(([key, value]) => key), | |
warn: (stylistic.warn ?? []).map(([key, value]) => key), | |
off: (stylistic.off ?? []).map(([key, value]) => key), | |
}; | |
console.log("* error"); | |
console.log( | |
"+", | |
Array.from(new Set([...strictRules.error, ...stylisticRules.error])) | |
.filter((key) => !standardRules.error.includes(key)) | |
.map(displayRule), | |
); | |
console.log( | |
"-", | |
standardRules.error | |
.filter( | |
(key) => | |
!( | |
strictRules.error.includes(key) || stylisticRules.error.includes(key) | |
), | |
) | |
.map(displayRule), | |
); | |
console.log(""); | |
console.log("* warn"); | |
console.log( | |
"+", | |
Array.from(new Set([...strictRules.warn, ...stylisticRules.warn])).filter( | |
(key) => !standardRules.warn.includes(key), | |
), | |
); | |
console.log( | |
"-", | |
standardRules.warn | |
.filter( | |
(key) => | |
!(strictRules.warn.includes(key) || stylisticRules.warn.includes(key)), | |
) | |
.map(displayRule), | |
); | |
console.log(""); | |
console.log("* off"); | |
console.log( | |
"+", | |
Array.from(new Set([...strictRules.off, ...stylisticRules.off])) | |
.filter((key) => !standardRules.off.includes(key)) | |
.map(displayRule), | |
); | |
console.log( | |
"-", | |
standardRules.off | |
.filter( | |
(key) => | |
!(strictRules.off.includes(key) || stylisticRules.off.includes(key)), | |
) | |
.map(displayRule), | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment