|
| 1 | +// @ts-check |
| 2 | +import eslint from "@eslint/js"; |
| 3 | +import simpleImportSort from "eslint-plugin-simple-import-sort"; |
| 4 | +import eslintPluginUnicorn from "eslint-plugin-unicorn"; |
| 5 | +import globals from "globals"; |
| 6 | +import tseslint from "typescript-eslint"; |
| 7 | + |
| 8 | +export default tseslint.config( |
| 9 | + { |
| 10 | + files: ["**/*.{ts,tsx,cts,mts,js,cjs,mjs}"], |
| 11 | + }, |
| 12 | + { |
| 13 | + ignores: [ |
| 14 | + "**/node_modules/**", |
| 15 | + "**/dist/**", |
| 16 | + "vitest.workspace.mjs", |
| 17 | + "cases/**", |
| 18 | + ], |
| 19 | + }, |
| 20 | + eslint.configs.recommended, |
| 21 | + ...tseslint.configs.recommended, |
| 22 | + ...tseslint.configs.stylistic, |
| 23 | + { |
| 24 | + plugins: { |
| 25 | + "simple-import-sort": simpleImportSort, |
| 26 | + "unicorn": eslintPluginUnicorn, |
| 27 | + }, |
| 28 | + rules: { |
| 29 | + "simple-import-sort/imports": "error", |
| 30 | + "simple-import-sort/exports": "error", |
| 31 | + }, |
| 32 | + }, |
| 33 | + // regexpPlugin.configs["flat/recommended"], |
| 34 | + { |
| 35 | + languageOptions: { |
| 36 | + parserOptions: { |
| 37 | + warnOnUnsupportedTypeScriptVersion: false, |
| 38 | + }, |
| 39 | + globals: globals.node, |
| 40 | + }, |
| 41 | + }, |
| 42 | + { |
| 43 | + rules: { |
| 44 | + // eslint |
| 45 | + // "dot-notation": "error", |
| 46 | + "eqeqeq": "error", |
| 47 | + "no-caller": "error", |
| 48 | + "no-constant-condition": ["error", { checkLoops: false }], |
| 49 | + "no-eval": "error", |
| 50 | + "no-extra-bind": "error", |
| 51 | + "no-new-func": "error", |
| 52 | + "no-new-wrappers": "error", |
| 53 | + // "no-return-await": "error", |
| 54 | + // "no-template-curly-in-string": "error", |
| 55 | + "no-throw-literal": "error", |
| 56 | + "no-undef-init": "error", |
| 57 | + "no-var": "error", |
| 58 | + "object-shorthand": "error", |
| 59 | + "prefer-const": "error", |
| 60 | + "prefer-object-spread": "error", |
| 61 | + "unicode-bom": ["error", "never"], |
| 62 | + |
| 63 | + // "no-restricted-syntax": [ |
| 64 | + // "error", |
| 65 | + // { |
| 66 | + // selector: "Literal[raw=null]", |
| 67 | + // message: "Avoid using null; use undefined instead.", |
| 68 | + // }, |
| 69 | + // { |
| 70 | + // selector: "TSNullKeyword", |
| 71 | + // message: "Avoid using null; use undefined instead.", |
| 72 | + // }, |
| 73 | + // ], |
| 74 | + |
| 75 | + // Enabled in eslint:recommended, but not applicable here |
| 76 | + "no-extra-boolean-cast": "off", |
| 77 | + "no-case-declarations": "off", |
| 78 | + "no-cond-assign": "off", |
| 79 | + "no-control-regex": "off", |
| 80 | + "no-inner-declarations": "off", |
| 81 | + "no-empty": "off", |
| 82 | + |
| 83 | + // @typescript-eslint/eslint-plugin |
| 84 | + // "@typescript-eslint/unified-signatures": "error", |
| 85 | + "no-unused-expressions": "off", |
| 86 | + // "@typescript-eslint/no-unused-expressions": ["error", { allowTernary: true }], |
| 87 | + "@typescript-eslint/no-unused-expressions": "off", |
| 88 | + |
| 89 | + // Rules enabled in typescript-eslint configs that are not applicable here |
| 90 | + "@typescript-eslint/ban-ts-comment": "off", |
| 91 | + "@typescript-eslint/class-literal-property-style": "off", |
| 92 | + "@typescript-eslint/consistent-indexed-object-style": "off", |
| 93 | + "@typescript-eslint/consistent-generic-constructors": "off", |
| 94 | + "@typescript-eslint/no-duplicate-enum-values": "off", |
| 95 | + "@typescript-eslint/no-empty-function": "off", |
| 96 | + "@typescript-eslint/no-namespace": "off", |
| 97 | + "@typescript-eslint/no-non-null-asserted-optional-chain": "off", |
| 98 | + "@typescript-eslint/no-var-requires": "off", |
| 99 | + "@typescript-eslint/no-empty-interface": "off", |
| 100 | + "@typescript-eslint/no-explicit-any": "off", |
| 101 | + "@typescript-eslint/no-empty-object-type": "off", // {} is a totally useful and valid type. |
| 102 | + "@typescript-eslint/no-require-imports": "off", |
| 103 | + // "@typescript-eslint/no-unused-vars": [ |
| 104 | + // "warn", |
| 105 | + // { |
| 106 | + // // Ignore: (solely underscores | starting with exactly one underscore) |
| 107 | + // argsIgnorePattern: "^(_+$|_[^_])", |
| 108 | + // varsIgnorePattern: "^(_+$|_[^_])", |
| 109 | + // // Not setting an ignore pattern for caught errors; those can always be safely removed. |
| 110 | + // }, |
| 111 | + // ], |
| 112 | + "@typescript-eslint/no-unused-vars": "off", |
| 113 | + "@typescript-eslint/no-inferrable-types": "off", |
| 114 | + |
| 115 | + // Pending https://github.com/typescript-eslint/typescript-eslint/issues/4820 |
| 116 | + "@typescript-eslint/prefer-optional-chain": "off", |
| 117 | + |
| 118 | + // eslint-plugin-unicorn |
| 119 | + "unicorn/prefer-node-protocol": "error", |
| 120 | + }, |
| 121 | + }, |
| 122 | + { |
| 123 | + files: ["**/*.mjs", "**/*.mts"], |
| 124 | + rules: { |
| 125 | + // These globals don't exist outside of CJS files. |
| 126 | + "no-restricted-globals": [ |
| 127 | + "error", |
| 128 | + { name: "__filename" }, |
| 129 | + { name: "__dirname" }, |
| 130 | + { name: "require" }, |
| 131 | + { name: "module" }, |
| 132 | + { name: "exports" }, |
| 133 | + ], |
| 134 | + }, |
| 135 | + }, |
| 136 | +); |
0 commit comments