biome-to-oxc 1.3.7 → 1.3.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { i as readJsonFile, n as DefaultReporter, r as findClosestPackageJson, t as migrate } from "../src-
|
|
2
|
+
import { i as readJsonFile, n as DefaultReporter, r as findClosestPackageJson, t as migrate } from "../src-DJypOiVx.mjs";
|
|
3
3
|
import { realpath } from "node:fs/promises";
|
|
4
4
|
import { dirname } from "node:path";
|
|
5
5
|
import { fileURLToPath } from "node:url";
|
package/dist/src/index.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { t as migrate } from "../src-
|
|
1
|
+
import { t as migrate } from "../src-DJypOiVx.mjs";
|
|
2
2
|
export { migrate };
|
|
@@ -745,6 +745,8 @@ const BIOME_TO_OXLINT_CATEGORY_MAP = {
|
|
|
745
745
|
};
|
|
746
746
|
const BIOME_TO_OXLINT_RULE_MAP = {
|
|
747
747
|
noAccessKey: "jsx-a11y/no-access-key",
|
|
748
|
+
noAdjacentSpacesInRegex: "no-regex-spaces",
|
|
749
|
+
noAmbiguousAnchorText: "jsx-a11y/anchor-ambiguous-text",
|
|
748
750
|
noArguments: "prefer-rest-params",
|
|
749
751
|
noAriaHiddenOnFocusable: "jsx-a11y/no-aria-hidden-on-focusable",
|
|
750
752
|
noAriaUnsupportedElements: "jsx-a11y/aria-unsupported-elements",
|
|
@@ -758,6 +760,7 @@ const BIOME_TO_OXLINT_RULE_MAP = {
|
|
|
758
760
|
noAsyncPromiseExecutor: "no-async-promise-executor",
|
|
759
761
|
noAutofocus: "jsx-a11y/no-autofocus",
|
|
760
762
|
noAwaitInLoops: "no-await-in-loop",
|
|
763
|
+
noBannedTypes: "typescript/ban-types",
|
|
761
764
|
noBaseToString: "typescript/no-base-to-string",
|
|
762
765
|
noBeforeInteractiveScriptOutsideDocument: "nextjs/no-before-interactive-script-outside-document",
|
|
763
766
|
noBitwiseOperators: "no-bitwise",
|
|
@@ -766,6 +769,11 @@ const BIOME_TO_OXLINT_RULE_MAP = {
|
|
|
766
769
|
noClassAssign: "no-class-assign",
|
|
767
770
|
noCommaOperator: "no-sequences",
|
|
768
771
|
noCommentText: "react/jsx-no-comment-textnodes",
|
|
772
|
+
noCommonJs: [
|
|
773
|
+
"import/no-commonjs",
|
|
774
|
+
"typescript/no-require-imports",
|
|
775
|
+
"typescript/no-var-requires"
|
|
776
|
+
],
|
|
769
777
|
noCompareNegZero: "no-compare-neg-zero",
|
|
770
778
|
noConfusingLabels: "no-labels",
|
|
771
779
|
noConfusingVoidType: "typescript/no-invalid-void-type",
|
|
@@ -790,16 +798,20 @@ const BIOME_TO_OXLINT_RULE_MAP = {
|
|
|
790
798
|
noDuplicateEnumValues: "typescript/no-duplicate-enum-values",
|
|
791
799
|
noDuplicateJsxProps: "react/jsx-no-duplicate-props",
|
|
792
800
|
noDuplicateObjectKeys: "no-dupe-keys",
|
|
801
|
+
noDuplicatedSpreadProps: "react/jsx-props-no-spread-multi",
|
|
793
802
|
noDocumentCookie: "unicorn/no-document-cookie",
|
|
794
803
|
noDocumentImportInPage: "nextjs/no-document-import-in-page",
|
|
795
804
|
noDoneCallback: "jest/no-done-callback",
|
|
796
805
|
noDivRegex: "no-div-regex",
|
|
797
|
-
noEmptyBlock: "no-empty",
|
|
798
806
|
noEmptyBlockStatements: "no-empty",
|
|
799
807
|
noEmptyCharacterClassInRegex: "no-empty-character-class",
|
|
800
808
|
noEmptyInterface: "typescript/no-empty-interface",
|
|
801
809
|
noEmptyPattern: "no-empty-pattern",
|
|
810
|
+
noEmptySource: "unicorn/no-empty-file",
|
|
811
|
+
noEqualsToNull: "no-eq-null",
|
|
812
|
+
noExcessiveClassesPerFile: "max-classes-per-file",
|
|
802
813
|
noExcessiveCognitiveComplexity: "complexity",
|
|
814
|
+
noExcessiveNestedCallbacks: "max-nested-callbacks",
|
|
803
815
|
noExplicitAny: "typescript/no-explicit-any",
|
|
804
816
|
noExtraBooleanCast: "no-extra-boolean-cast",
|
|
805
817
|
noExtraNonNullAssertion: "typescript/no-extra-non-null-assertion",
|
|
@@ -821,6 +833,7 @@ const BIOME_TO_OXLINT_RULE_MAP = {
|
|
|
821
833
|
noInnerDeclarations: "no-inner-declarations",
|
|
822
834
|
noImplicitBoolean: "no-implicit-coercion",
|
|
823
835
|
noImpliedEval: "no-implied-eval",
|
|
836
|
+
noIncrementDecrement: "no-plusplus",
|
|
824
837
|
noInferrableTypes: "typescript/no-inferrable-types",
|
|
825
838
|
noInvalidBuiltinInstantiation: "no-new-native-nonconstructor",
|
|
826
839
|
noInvalidUseBeforeDeclaration: "no-use-before-define",
|
|
@@ -839,13 +852,17 @@ const BIOME_TO_OXLINT_RULE_MAP = {
|
|
|
839
852
|
noMisrefactoredShorthandAssign: "oxc/misrefactored-assign-op",
|
|
840
853
|
noMisusedPromises: "typescript/no-misused-promises",
|
|
841
854
|
noMultiAssign: "no-multi-assign",
|
|
855
|
+
noMultilineString: "no-multi-str",
|
|
842
856
|
noMultiStr: "no-multi-str",
|
|
857
|
+
noNegationElse: "no-negated-condition",
|
|
843
858
|
noNewSymbol: "no-new-native-nonconstructor",
|
|
844
859
|
noNodejsModules: "import/no-nodejs-modules",
|
|
845
860
|
noNamespace: "typescript/no-namespace",
|
|
846
861
|
noNamespaceImport: "import/no-namespace",
|
|
847
862
|
noNestedComponentDefinitions: "react/no-unstable-nested-components",
|
|
863
|
+
noNestedPromises: "promise/no-nesting",
|
|
848
864
|
noNestedTernary: "no-nested-ternary",
|
|
865
|
+
noNextAsyncClientComponent: "nextjs/no-async-client-component",
|
|
849
866
|
noNoninteractiveElementInteractions: "jsx-a11y/no-noninteractive-element-interactions",
|
|
850
867
|
noNoninteractiveElementToInteractiveRole: "jsx-a11y/no-noninteractive-element-to-interactive-role",
|
|
851
868
|
noNoninteractiveTabindex: "jsx-a11y/no-noninteractive-tabindex",
|
|
@@ -856,12 +873,14 @@ const BIOME_TO_OXLINT_RULE_MAP = {
|
|
|
856
873
|
noParameterAssign: "no-param-reassign",
|
|
857
874
|
noParameterProperties: "typescript/parameter-properties",
|
|
858
875
|
noPrecisionLoss: "no-loss-of-precision",
|
|
876
|
+
noPositiveTabindex: "jsx-a11y/tabindex-no-positive",
|
|
859
877
|
noProcessEnv: "node/no-process-env",
|
|
860
878
|
noProto: "no-proto",
|
|
861
879
|
noPrototypeBuiltins: "no-prototype-builtins",
|
|
862
880
|
noRedeclare: "no-redeclare",
|
|
863
881
|
noRedundantAlt: "jsx-a11y/img-redundant-alt",
|
|
864
882
|
noRedundantRoles: "jsx-a11y/no-redundant-roles",
|
|
883
|
+
noReactStringRefs: "react/no-string-refs",
|
|
865
884
|
noDuplicateTestHooks: ["jest/no-duplicate-hooks", "vitest/no-duplicate-hooks"],
|
|
866
885
|
noConditionalExpect: ["jest/no-conditional-expect", "vitest/no-conditional-expect"],
|
|
867
886
|
noExcessiveNestedTestSuites: ["jest/max-nested-describe", "vitest/max-nested-describe"],
|
|
@@ -869,6 +888,7 @@ const BIOME_TO_OXLINT_RULE_MAP = {
|
|
|
869
888
|
noMisplacedAssertion: ["jest/no-standalone-expect", "vitest/no-standalone-expect"],
|
|
870
889
|
noRenderReturnValue: "react/no-render-return-value",
|
|
871
890
|
noRestrictedGlobals: "no-restricted-globals",
|
|
891
|
+
noRestrictedElements: "react/forbid-elements",
|
|
872
892
|
noRestrictedImports: "no-restricted-imports",
|
|
873
893
|
noRestrictedTypes: "typescript/no-restricted-types",
|
|
874
894
|
noReturnAssign: "no-return-assign",
|
|
@@ -884,10 +904,12 @@ const BIOME_TO_OXLINT_RULE_MAP = {
|
|
|
884
904
|
noSyncScripts: "nextjs/no-sync-scripts",
|
|
885
905
|
noSwitchDeclarations: "no-case-declarations",
|
|
886
906
|
noStaticElementInteractions: "jsx-a11y/no-static-element-interactions",
|
|
907
|
+
noSubstr: "unicorn/prefer-string-slice",
|
|
887
908
|
noTemplateCurlyInString: "no-template-curly-in-string",
|
|
888
909
|
noTernary: "no-ternary",
|
|
910
|
+
noThenProperty: "unicorn/no-thenable",
|
|
889
911
|
noUndeclaredVariables: "no-undef",
|
|
890
|
-
|
|
912
|
+
noUnknownAttribute: "react/no-unknown-property",
|
|
891
913
|
noUnassignedVariables: "no-unassigned-vars",
|
|
892
914
|
noUselessThisAlias: "typescript/no-this-alias",
|
|
893
915
|
noUnusedExpressions: "no-unused-expressions",
|
|
@@ -902,6 +924,8 @@ const BIOME_TO_OXLINT_RULE_MAP = {
|
|
|
902
924
|
noUnsafeFinally: "no-unsafe-finally",
|
|
903
925
|
noUnsafeNegation: "no-unsafe-negation",
|
|
904
926
|
noUnsafeOptionalChaining: "no-unsafe-optional-chaining",
|
|
927
|
+
noUnsafePlusOperands: "typescript/restrict-plus-operands",
|
|
928
|
+
noUnusedInstantiation: "no-new",
|
|
905
929
|
noUnusedLabels: "no-unused-labels",
|
|
906
930
|
noUnusedPrivateClassMembers: "no-unused-private-class-members",
|
|
907
931
|
noUnusedVariables: "no-unused-vars",
|
|
@@ -909,28 +933,38 @@ const BIOME_TO_OXLINT_RULE_MAP = {
|
|
|
909
933
|
noUselessCatch: "no-useless-catch",
|
|
910
934
|
noUselessConstructor: "no-useless-constructor",
|
|
911
935
|
noUselessEmptyExport: "typescript/no-useless-empty-export",
|
|
936
|
+
noUselessEscapeInRegex: "no-useless-escape",
|
|
912
937
|
noUselessEscapeInString: "no-useless-escape",
|
|
913
938
|
noUselessFragments: "react/jsx-no-useless-fragment",
|
|
914
939
|
noUselessLabel: "no-extra-label",
|
|
940
|
+
noUselessLoneBlockStatements: "no-lone-blocks",
|
|
941
|
+
noUselessRegexBackrefs: "no-useless-backreference",
|
|
915
942
|
noUselessRename: "no-useless-rename",
|
|
916
943
|
noUselessReturn: "no-useless-return",
|
|
944
|
+
noUselessStringConcat: "no-useless-concat",
|
|
917
945
|
noUselessTernary: "no-unneeded-ternary",
|
|
918
946
|
noUselessSwitchCase: "unicorn/no-useless-switch-case",
|
|
919
947
|
noUselessTypeConstraint: "typescript/no-unnecessary-type-constraint",
|
|
948
|
+
noUselessTypeConversion: "typescript/no-unnecessary-type-conversion",
|
|
920
949
|
noUselessUndefined: "unicorn/no-useless-undefined",
|
|
921
950
|
noVoid: "no-void",
|
|
922
951
|
noVar: "no-var",
|
|
923
952
|
noVoidElementsWithChildren: "react/void-dom-elements-no-children",
|
|
924
953
|
noVoidTypeReturn: "typescript/no-invalid-void-type",
|
|
925
954
|
noVueDataObjectDeclaration: ["vue/no-deprecated-data-object-declaration", "vue/no-shared-component-data"],
|
|
955
|
+
noVueArrowFuncInWatch: "vue/no-arrow-functions-in-watch",
|
|
926
956
|
noVueDuplicateKeys: "vue/no-dupe-keys",
|
|
957
|
+
noVueImportCompilerMacros: "vue/no-import-compiler-macros",
|
|
927
958
|
noVueReservedKeys: "vue/no-reserved-keys",
|
|
928
959
|
noVueReservedProps: "vue/no-reserved-props",
|
|
929
960
|
noWith: "no-with",
|
|
930
961
|
noYodaExpression: "yoda",
|
|
931
962
|
useAltText: "jsx-a11y/alt-text",
|
|
963
|
+
useAdjacentOverloadSignatures: "typescript/adjacent-overload-signatures",
|
|
932
964
|
useAnchorContent: "jsx-a11y/anchor-has-content",
|
|
933
965
|
useArrowFunction: "prefer-arrow-callback",
|
|
966
|
+
useArrayFind: "typescript/prefer-find",
|
|
967
|
+
useArrayLiterals: "no-array-constructor",
|
|
934
968
|
useArraySome: "unicorn/prefer-array-some",
|
|
935
969
|
useArraySortCompare: "typescript/require-array-sort-compare",
|
|
936
970
|
useAriaActivedescendantWithTabindex: "jsx-a11y/aria-activedescendant-has-tabindex",
|
|
@@ -942,10 +976,17 @@ const BIOME_TO_OXLINT_RULE_MAP = {
|
|
|
942
976
|
useAsConstAssertion: "typescript/prefer-as-const",
|
|
943
977
|
useAtIndex: "unicorn/prefer-at",
|
|
944
978
|
useAwait: "require-await",
|
|
979
|
+
useBlockStatements: "curly",
|
|
945
980
|
useComponentExportOnlyModules: "react/only-export-components",
|
|
981
|
+
useCollapsedElseIf: "no-lonely-if",
|
|
982
|
+
useCollapsedIf: "unicorn/no-lonely-if",
|
|
946
983
|
useConsistentArrayType: "typescript/array-type",
|
|
984
|
+
useConsistentArrowReturn: "arrow-body-style",
|
|
985
|
+
useConsistentBuiltinInstantiation: "no-new-wrappers",
|
|
947
986
|
useConsistentCurlyBraces: "curly",
|
|
987
|
+
useConsistentEnumValueType: "typescript/no-mixed-enums",
|
|
948
988
|
useConsistentMethodSignatures: "typescript/method-signature-style",
|
|
989
|
+
useConsistentTypeDefinitions: "typescript/consistent-type-definitions",
|
|
949
990
|
useConsistentMemberAccessibility: "typescript/explicit-member-accessibility",
|
|
950
991
|
useConsistentTestIt: ["jest/consistent-test-it", "vitest/consistent-test-it"],
|
|
951
992
|
useConst: "prefer-const",
|
|
@@ -957,6 +998,7 @@ const BIOME_TO_OXLINT_RULE_MAP = {
|
|
|
957
998
|
useDomNodeTextContent: "unicorn/prefer-dom-node-text-content",
|
|
958
999
|
useDomQuerySelector: "unicorn/prefer-query-selector",
|
|
959
1000
|
useEnumInitializers: "typescript/prefer-enum-initializers",
|
|
1001
|
+
useErrorCause: "preserve-caught-error",
|
|
960
1002
|
useErrorMessage: "unicorn/error-message",
|
|
961
1003
|
useExpect: ["jest/expect-expect", "vitest/expect-expect"],
|
|
962
1004
|
useExplicitLengthCheck: "unicorn/explicit-length-check",
|
|
@@ -968,6 +1010,7 @@ const BIOME_TO_OXLINT_RULE_MAP = {
|
|
|
968
1010
|
useFilenamingConvention: "unicorn/filename-case",
|
|
969
1011
|
useFind: "typescript/prefer-find",
|
|
970
1012
|
useFlatMap: "unicorn/prefer-array-flat-map",
|
|
1013
|
+
useFragmentSyntax: "react/jsx-fragments",
|
|
971
1014
|
useFocusableInteractive: "jsx-a11y/interactive-supports-focus",
|
|
972
1015
|
useForOf: "typescript/prefer-for-of",
|
|
973
1016
|
useGetterReturn: "getter-return",
|
|
@@ -975,27 +1018,36 @@ const BIOME_TO_OXLINT_RULE_MAP = {
|
|
|
975
1018
|
useGoogleFontDisplay: "nextjs/google-font-display",
|
|
976
1019
|
useGoogleFontPreconnect: "nextjs/google-font-preconnect",
|
|
977
1020
|
useGuardForIn: "guard-for-in",
|
|
1021
|
+
useGroupedAccessorPairs: "grouped-accessor-pairs",
|
|
978
1022
|
useHeadingContent: "jsx-a11y/heading-has-content",
|
|
979
1023
|
useHtmlLang: "jsx-a11y/html-has-lang",
|
|
980
1024
|
useHookAtTopLevel: "react/rules-of-hooks",
|
|
1025
|
+
useIframeSandbox: "react/iframe-missing-sandbox",
|
|
981
1026
|
useIframeTitle: "jsx-a11y/iframe-has-title",
|
|
982
1027
|
useImportsFirst: "import/first",
|
|
983
1028
|
useImportType: "typescript/consistent-type-imports",
|
|
1029
|
+
useIncludes: "typescript/prefer-includes",
|
|
984
1030
|
useIndexOf: "unicorn/prefer-array-index-of",
|
|
985
1031
|
useInlineScriptId: "nextjs/inline-script-id",
|
|
986
1032
|
useIterableCallbackReturn: "array-callback-return",
|
|
987
1033
|
useIsNan: "use-isnan",
|
|
1034
|
+
useIsArray: "unicorn/no-instanceof-array",
|
|
988
1035
|
useJsxKeyInIterable: "react/jsx-key",
|
|
989
1036
|
useKeyWithClickEvents: "jsx-a11y/click-events-have-key-events",
|
|
990
1037
|
useKeyWithMouseEvents: "jsx-a11y/mouse-events-have-key-events",
|
|
991
1038
|
useLiteralEnumMembers: "typescript/prefer-literal-enum-member",
|
|
992
1039
|
useLiteralKeys: "typescript/dot-notation",
|
|
993
1040
|
useMathMinMax: "unicorn/prefer-math-min-max",
|
|
1041
|
+
useMaxParams: "max-params",
|
|
994
1042
|
useMediaCaption: "jsx-a11y/media-has-caption",
|
|
995
1043
|
useNamedCaptureGroup: "prefer-named-capture-group",
|
|
1044
|
+
useNamespaceKeyword: "typescript/prefer-namespace-keyword",
|
|
996
1045
|
useNodejsImportProtocol: "unicorn/prefer-node-protocol",
|
|
997
1046
|
useNullishCoalescing: "typescript/prefer-nullish-coalescing",
|
|
1047
|
+
useNumberNamespace: "unicorn/prefer-number-properties",
|
|
1048
|
+
useNumberToFixedDigitsArgument: "unicorn/require-number-to-fixed-digits-argument",
|
|
998
1049
|
useNumericLiterals: "prefer-numeric-literals",
|
|
1050
|
+
useNumericSeparators: "unicorn/numeric-separators-style",
|
|
999
1051
|
useObjectSpread: "prefer-object-spread",
|
|
1000
1052
|
useOptionalChain: "typescript/prefer-optional-chain",
|
|
1001
1053
|
useParseIntRadix: "radix",
|
|
@@ -1006,14 +1058,18 @@ const BIOME_TO_OXLINT_RULE_MAP = {
|
|
|
1006
1058
|
useRegexpExec: "typescript/prefer-regexp-exec",
|
|
1007
1059
|
useRegexpTest: "unicorn/prefer-regexp-test",
|
|
1008
1060
|
useSemanticElements: "jsx-a11y/prefer-tag-over-role",
|
|
1061
|
+
useSelfClosingElements: "react/self-closing-comp",
|
|
1062
|
+
useShorthandAssign: "operator-assignment",
|
|
1009
1063
|
useShorthandFunctionType: "typescript/prefer-function-type",
|
|
1010
1064
|
useSimplifiedLogicExpression: "unicorn/prefer-logical-operator-over-ternary",
|
|
1011
1065
|
useSpread: "prefer-spread",
|
|
1066
|
+
useSpreadOverApply: "prefer-spread",
|
|
1012
1067
|
useStringStartsEndsWith: "typescript/prefer-string-starts-ends-with",
|
|
1013
1068
|
useSymbolDescription: "symbol-description",
|
|
1014
1069
|
useTemplate: "prefer-template",
|
|
1015
1070
|
useTestHooksInOrder: ["jest/prefer-hooks-in-order", "vitest/prefer-hooks-in-order"],
|
|
1016
1071
|
useTestHooksOnTop: ["jest/prefer-hooks-on-top", "vitest/prefer-hooks-on-top"],
|
|
1072
|
+
useThisInClassMethods: "class-methods-use-this",
|
|
1017
1073
|
useThrowNewError: "unicorn/throw-new-error",
|
|
1018
1074
|
useThrowOnlyError: "typescript/only-throw-error",
|
|
1019
1075
|
useTrimStartEnd: "unicorn/prefer-string-trim-start-end",
|
|
@@ -1050,12 +1106,38 @@ function normalizeOxlintRuleName(ruleName) {
|
|
|
1050
1106
|
if (ruleName.startsWith("react_perf/")) return ruleName.replace("react_perf/", "react-perf/");
|
|
1051
1107
|
return ruleName;
|
|
1052
1108
|
}
|
|
1053
|
-
function mapBiomeRuleOptionsToOxlintSeverity(biomeName, severity, biomeSeverity) {
|
|
1054
|
-
if (biomeName === "useVueNextTickPromise") return typeof severity === "string" ? [severity, "promise"] : severity;
|
|
1109
|
+
function mapBiomeRuleOptionsToOxlintSeverity(biomeName, severity, biomeSeverity, reporter) {
|
|
1055
1110
|
if (typeof severity !== "string") return severity;
|
|
1056
|
-
if (
|
|
1057
|
-
const
|
|
1058
|
-
if (
|
|
1111
|
+
if (biomeName === "useVueNextTickPromise") return [severity, "promise"];
|
|
1112
|
+
const options = getBiomeRuleOptions(biomeSeverity);
|
|
1113
|
+
if (biomeName === "noExcessiveNestedCallbacks") return [severity, { max: options && isNonNegativeInteger(options.max) ? options.max : 5 }];
|
|
1114
|
+
if (biomeName === "useErrorCause") return [severity, { requireCatchParameter: options && typeof options.requireCatchParameter === "boolean" ? options.requireCatchParameter : true }];
|
|
1115
|
+
if (biomeName === "useMaxParams") return [severity, { max: options && isNonNegativeInteger(options.max) ? options.max : 4 }];
|
|
1116
|
+
if (!options) return severity;
|
|
1117
|
+
if (biomeName === "noAmbiguousAnchorText") {
|
|
1118
|
+
const { words } = options;
|
|
1119
|
+
return Array.isArray(words) && words.every((value) => typeof value === "string") ? [severity, { words }] : severity;
|
|
1120
|
+
}
|
|
1121
|
+
if (biomeName === "noEmptySource") {
|
|
1122
|
+
if (options.allowComments === true) reporter.warn("Biome rule noEmptySource option \"allowComments\" is not supported by Oxlint unicorn/no-empty-file and was not migrated.");
|
|
1123
|
+
return severity;
|
|
1124
|
+
}
|
|
1125
|
+
if (biomeName === "noExcessiveClassesPerFile") return isNonNegativeInteger(options.maxClasses) ? [severity, { max: options.maxClasses }] : severity;
|
|
1126
|
+
if (biomeName === "noIncrementDecrement") return typeof options.allowForLoopAfterthoughts === "boolean" ? [severity, { allowForLoopAfterthoughts: options.allowForLoopAfterthoughts }] : severity;
|
|
1127
|
+
if (biomeName === "noRestrictedElements") {
|
|
1128
|
+
const { elements } = options;
|
|
1129
|
+
if (!isRecord(elements)) return severity;
|
|
1130
|
+
const entries = Object.entries(elements);
|
|
1131
|
+
if (entries.length === 0 || !entries.every(([, message]) => typeof message === "string")) return severity;
|
|
1132
|
+
return [severity, { forbid: entries.map(([element, message]) => ({
|
|
1133
|
+
element,
|
|
1134
|
+
message
|
|
1135
|
+
})) }];
|
|
1136
|
+
}
|
|
1137
|
+
if (biomeName === "noUnknownAttribute") {
|
|
1138
|
+
const { ignore } = options;
|
|
1139
|
+
return Array.isArray(ignore) && ignore.every((value) => typeof value === "string") ? [severity, { ignore }] : severity;
|
|
1140
|
+
}
|
|
1059
1141
|
if (biomeName === "noJsxLiterals") {
|
|
1060
1142
|
const { allowedStrings, ignoreProps, noStrings } = options;
|
|
1061
1143
|
const oxlintOptions = {};
|
|
@@ -1067,10 +1149,63 @@ function mapBiomeRuleOptionsToOxlintSeverity(biomeName, severity, biomeSeverity)
|
|
|
1067
1149
|
}
|
|
1068
1150
|
return Object.keys(oxlintOptions).length > 0 ? [severity, oxlintOptions] : severity;
|
|
1069
1151
|
}
|
|
1070
|
-
if (biomeName
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1152
|
+
if (biomeName === "useConsistentArrowReturn") {
|
|
1153
|
+
const mode = options.style === "always" || options.style === "never" ? options.style : options.style === "asNeeded" || options.requireForObjectLiteral !== void 0 ? "as-needed" : null;
|
|
1154
|
+
if (!mode) return severity;
|
|
1155
|
+
return typeof options.requireForObjectLiteral === "boolean" ? [
|
|
1156
|
+
severity,
|
|
1157
|
+
mode,
|
|
1158
|
+
{ requireReturnForObjectLiteral: options.requireForObjectLiteral }
|
|
1159
|
+
] : [severity, mode];
|
|
1160
|
+
}
|
|
1161
|
+
if (biomeName === "useConsistentMethodSignatures") {
|
|
1162
|
+
const { style } = options;
|
|
1163
|
+
return style === "method" || style === "property" ? [severity, style] : severity;
|
|
1164
|
+
}
|
|
1165
|
+
if (biomeName === "useConsistentTypeDefinitions") {
|
|
1166
|
+
const { style } = options;
|
|
1167
|
+
return style === "interface" || style === "type" ? [severity, style] : severity;
|
|
1168
|
+
}
|
|
1169
|
+
if (biomeName === "useNumericSeparators") {
|
|
1170
|
+
const oxlintOptions = {};
|
|
1171
|
+
for (const [biomeKey, oxlintKey] of [
|
|
1172
|
+
["binary", "binary"],
|
|
1173
|
+
["decimal", "number"],
|
|
1174
|
+
["hexadecimal", "hexadecimal"],
|
|
1175
|
+
["octal", "octal"]
|
|
1176
|
+
]) {
|
|
1177
|
+
const numericOptions = mapNumericSeparatorOptions(options[biomeKey]);
|
|
1178
|
+
if (numericOptions) oxlintOptions[oxlintKey] = numericOptions;
|
|
1179
|
+
}
|
|
1180
|
+
return Object.keys(oxlintOptions).length > 0 ? [severity, oxlintOptions] : severity;
|
|
1181
|
+
}
|
|
1182
|
+
if (biomeName === "useThisInClassMethods") {
|
|
1183
|
+
const oxlintOptions = {};
|
|
1184
|
+
if (options.ignoreClassesWithImplements === "all" || options.ignoreClassesWithImplements === "public-fields") oxlintOptions.ignoreClassesWithImplements = options.ignoreClassesWithImplements;
|
|
1185
|
+
if (Array.isArray(options.ignoreMethods) && options.ignoreMethods.every((value) => typeof value === "string")) oxlintOptions.exceptMethods = options.ignoreMethods;
|
|
1186
|
+
if (typeof options.ignoreOverrideMethods === "boolean") oxlintOptions.ignoreOverrideMethods = options.ignoreOverrideMethods;
|
|
1187
|
+
return Object.keys(oxlintOptions).length > 0 ? [severity, oxlintOptions] : severity;
|
|
1188
|
+
}
|
|
1189
|
+
return severity;
|
|
1190
|
+
}
|
|
1191
|
+
function getBiomeRuleOptions(biomeSeverity) {
|
|
1192
|
+
if (typeof biomeSeverity !== "object" || biomeSeverity === null) return null;
|
|
1193
|
+
const { options } = biomeSeverity;
|
|
1194
|
+
return isRecord(options) ? options : null;
|
|
1195
|
+
}
|
|
1196
|
+
function isRecord(value) {
|
|
1197
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
1198
|
+
}
|
|
1199
|
+
function isNonNegativeInteger(value) {
|
|
1200
|
+
return typeof value === "number" && Number.isInteger(value) && value >= 0;
|
|
1201
|
+
}
|
|
1202
|
+
function mapNumericSeparatorOptions(value) {
|
|
1203
|
+
if (!isRecord(value)) return null;
|
|
1204
|
+
const mapped = {};
|
|
1205
|
+
if (isNonNegativeInteger(value.groupLength) && value.groupLength > 0) mapped.groupLength = value.groupLength;
|
|
1206
|
+
if (isNonNegativeInteger(value.minimumDigits)) mapped.minimumDigits = value.minimumDigits;
|
|
1207
|
+
if (Object.keys(mapped).length === 0) return null;
|
|
1208
|
+
return mapped;
|
|
1074
1209
|
}
|
|
1075
1210
|
function mapBiomeRuleSeverity(severity, reporter, biomeRuleName) {
|
|
1076
1211
|
const rawSeverity = typeof severity === "string" ? severity : typeof severity === "object" && severity !== null && "level" in severity ? String(severity.level) : "";
|
|
@@ -1132,7 +1267,7 @@ function extractRulesFromBiomeConfig(linterRules, reporter) {
|
|
|
1132
1267
|
if (typeof ruleSeverity === "boolean" || ruleSeverity === void 0) continue;
|
|
1133
1268
|
const oxlintRuleNames = mapBiomeRuleToOxlintRules(ruleName, reporter);
|
|
1134
1269
|
if (oxlintRuleNames.length > 0) {
|
|
1135
|
-
const oxlintSeverity = mapBiomeRuleOptionsToOxlintSeverity(ruleName, mapBiomeRuleSeverity(ruleSeverity, reporter, ruleName), ruleSeverity);
|
|
1270
|
+
const oxlintSeverity = mapBiomeRuleOptionsToOxlintSeverity(ruleName, mapBiomeRuleSeverity(ruleSeverity, reporter, ruleName), ruleSeverity, reporter);
|
|
1136
1271
|
for (const oxlintRuleName of oxlintRuleNames) rules[oxlintRuleName] = oxlintSeverity;
|
|
1137
1272
|
}
|
|
1138
1273
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "biome-to-oxc",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.8",
|
|
4
4
|
"description": "Migrate from Biome to Oxc ecosystem (oxlint + oxfmt + oxlint-tsgolint)",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"biome",
|
|
@@ -42,16 +42,16 @@
|
|
|
42
42
|
"@types/node": "^26.1.1",
|
|
43
43
|
"@typescript/native-preview": "latest",
|
|
44
44
|
"@vitest/coverage-v8": "^4.1.10",
|
|
45
|
-
"oxfmt": "^0.
|
|
46
|
-
"oxlint": "^1.
|
|
45
|
+
"oxfmt": "^0.59.0",
|
|
46
|
+
"oxlint": "^1.74.0",
|
|
47
47
|
"oxlint-tsgolint": "^0.24.0",
|
|
48
|
-
"tsdown": "^0.22.
|
|
48
|
+
"tsdown": "^0.22.7",
|
|
49
49
|
"typescript": "7.0.2",
|
|
50
50
|
"vitest": "^4.1.10"
|
|
51
51
|
},
|
|
52
52
|
"engines": {
|
|
53
53
|
"node": ">=22.22.3",
|
|
54
|
-
"pnpm": ">=11.
|
|
54
|
+
"pnpm": ">=11.13.0"
|
|
55
55
|
},
|
|
56
56
|
"scripts": {
|
|
57
57
|
"test": "vitest",
|