Created
June 8, 2024 14:15
-
-
Save umstek/da056e505f819ad924c04ab820b2382e to your computer and use it in GitHub Desktop.
Deduplicate ESLint configs migrated with Biome
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
// Needs Bun | |
import biome from './biome.json'; | |
// Extracted from https://biomejs.dev/linter/rules/#recommended-rules | |
const recommended = (await Bun.file('./recommended.txt').text()) | |
.split('\n') | |
.map((x: string) => x.trim()) | |
.filter(Boolean); | |
biome.linter.rules.recommended = true; | |
delete biome.overrides; | |
const groups = Object.keys(biome.linter.rules).filter( | |
(x) => typeof biome.linter.rules[x] === 'object', | |
); | |
for (const rule of recommended) { | |
for (const group of groups) { | |
if ( | |
biome.linter.rules?.[group][rule] && | |
['error', 'warn', 'info'].includes(biome.linter.rules[group][rule]) | |
) { | |
// Delete rule covered by recommended rules | |
delete biome.linter.rules[group][rule]; | |
} | |
// Deletes any rules that are Biome-recommended, but turned off by original eslint config | |
if (biome.linter.rules?.[group][rule] === 'off') { | |
delete biome.linter.rules[group][rule]; | |
} | |
} | |
} | |
Bun.write('biome.deduped.json', JSON.stringify(biome, null, 2)); |
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
noAccessKey | |
noAriaHiddenOnFocusable | |
noAriaUnsupportedElements | |
noAutofocus | |
noBlankTarget | |
noDistractingElements | |
noHeaderScope | |
noInteractiveElementToNoninteractiveRole | |
noNoninteractiveElementToInteractiveRole | |
noNoninteractiveTabindex | |
noPositiveTabindex | |
noRedundantAlt | |
noRedundantRoles | |
noSvgWithoutTitle | |
useAltText | |
useAnchorContent | |
useAriaActivedescendantWithTabindex | |
useAriaPropsForRole | |
useButtonType | |
useHeadingContent | |
useHtmlLang | |
useIframeTitle | |
useKeyWithClickEvents | |
useKeyWithMouseEvents | |
useMediaCaption | |
useValidAnchor | |
useValidAriaProps | |
useValidAriaRole | |
useValidAriaValues | |
useValidLang | |
noBannedTypes | |
noEmptyTypeParameters | |
noExcessiveNestedTestSuites | |
noExtraBooleanCast | |
noForEach | |
noMultipleSpacesInRegularExpressionLiterals | |
noStaticOnlyClass | |
noThisInStatic | |
noUselessCatch | |
noUselessConstructor | |
noUselessEmptyExport | |
noUselessFragments | |
noUselessLabel | |
noUselessLoneBlockStatements | |
noUselessRename | |
noUselessSwitchCase | |
noUselessTernary | |
noUselessThisAlias | |
noUselessTypeConstraint | |
noWith | |
useArrowFunction | |
useFlatMap | |
useLiteralKeys | |
useOptionalChain | |
useRegexLiterals | |
useSimpleNumberKeys | |
noChildrenProp | |
noConstAssign | |
noConstantCondition | |
noConstructorReturn | |
noEmptyCharacterClassInRegex | |
noEmptyPattern | |
noFlatMapIdentity | |
noGlobalObjectCalls | |
noInnerDeclarations | |
noInvalidConstructorSuper | |
noInvalidNewBuiltin | |
noInvalidUseBeforeDeclaration | |
noNonoctalDecimalEscape | |
noPrecisionLoss | |
noRenderReturnValue | |
noSelfAssign | |
noSetterReturn | |
noStringCaseMismatch | |
noSwitchDeclarations | |
noUnnecessaryContinue | |
noUnreachable | |
noUnreachableSuper | |
noUnsafeFinally | |
noUnsafeOptionalChaining | |
noUnusedLabels | |
noVoidElementsWithChildren | |
noVoidTypeReturn | |
useExhaustiveDependencies | |
useIsNan | |
useJsxKeyInIterable | |
useValidForDirection | |
useYield | |
noAccumulatingSpread | |
noDelete | |
noDangerouslySetInnerHtml | |
noDangerouslySetInnerHtmlWithChildren | |
noGlobalEval | |
noArguments | |
noCommaOperator | |
noInferrableTypes | |
noNonNullAssertion | |
noParameterAssign | |
noUnusedTemplateLiteral | |
noUselessElse | |
noVar | |
useAsConstAssertion | |
useConst | |
useDefaultParameterLast | |
useEnumInitializers | |
useExponentiationOperator | |
useExportType | |
useImportType | |
useLiteralEnumMembers | |
useNodejsImportProtocol | |
useNumberNamespace | |
useNumericLiterals | |
useSelfClosingElements | |
useShorthandFunctionType | |
useSingleVarDeclarator | |
useTemplate | |
useWhile | |
noApproximativeNumericConstant | |
noArrayIndexKey | |
noAssignInExpressions | |
noAsyncPromiseExecutor | |
noCatchAssign | |
noClassAssign | |
noCommentText | |
noCompareNegZero | |
noConfusingLabels | |
noConfusingVoidType | |
noConstEnum | |
noControlCharactersInRegex | |
noDebugger | |
noDoubleEquals | |
noDuplicateCase | |
noDuplicateClassMembers | |
noDuplicateJsxProps | |
noDuplicateObjectKeys | |
noDuplicateParameters | |
noDuplicateTestHooks | |
noEmptyInterface | |
noExplicitAny | |
noExportsInTest | |
noExtraNonNullAssertion | |
noFallthroughSwitchClause | |
noFocusedTests | |
noFunctionAssign | |
noGlobalAssign | |
noGlobalIsFinite | |
noGlobalIsNan | |
noImplicitAnyLet | |
noImportAssign | |
noLabelVar | |
noMisleadingCharacterClass | |
noMisleadingInstantiator | |
noMisrefactoredShorthandAssign | |
noPrototypeBuiltins | |
noRedeclare | |
noRedundantUseStrict | |
noSelfCompare | |
noShadowRestrictedNames | |
noSparseArray | |
noSuspiciousSemicolonInJsx | |
noThenProperty | |
noUnsafeDeclarationMerging | |
noUnsafeNegation | |
useDefaultSwitchClauseLast | |
useGetterReturn | |
useIsArray | |
useNamespaceKeyword | |
useValidTypeof |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Still needs some manual intervention