|
| 1 | +import { fixupPluginRules } from "@eslint/compat"; |
| 2 | +import eslint from "@eslint/js"; |
| 3 | +import arrayFunc from "eslint-plugin-array-func"; |
| 4 | +import github from "eslint-plugin-github"; |
| 5 | +import sonarjs from "eslint-plugin-sonarjs"; |
| 6 | +import globals from "globals"; |
| 7 | +import tseslint from "typescript-eslint"; |
| 8 | + |
| 9 | +export default tseslint.config( |
| 10 | + { name: "eslint/recommended", ...eslint.configs.recommended }, |
| 11 | + ...tseslint.configs.recommendedTypeChecked, |
| 12 | + { |
| 13 | + name: "typescript-eslint/parser-options", |
| 14 | + languageOptions: { |
| 15 | + parserOptions: { |
| 16 | + project: true, |
| 17 | + tsconfigRootDir: import.meta.dirname, |
| 18 | + }, |
| 19 | + }, |
| 20 | + }, |
| 21 | + ...tseslint.configs.stylisticTypeChecked, |
| 22 | + { name: "array-func", ...arrayFunc.configs.all }, |
| 23 | + { name: "sonarjs/recommended", ...sonarjs.configs.recommended }, |
| 24 | + { |
| 25 | + // We want to choose which rules to enable from the github plugin, not use a preset. |
| 26 | + name: "github", |
| 27 | + plugins: { |
| 28 | + github: fixupPluginRules(github), |
| 29 | + }, |
| 30 | + rules: { |
| 31 | + "github/array-foreach": "error", |
| 32 | + "github/async-currenttarget": "error", |
| 33 | + "github/async-preventdefault": "error", |
| 34 | + "github/no-innerText": "error", |
| 35 | + }, |
| 36 | + }, |
| 37 | + { |
| 38 | + name: "global ignores", |
| 39 | + ignores: [], |
| 40 | + }, |
| 41 | + { |
| 42 | + name: "jsonview-custom", |
| 43 | + languageOptions: { |
| 44 | + ecmaVersion: "latest", |
| 45 | + parserOptions: { |
| 46 | + ecmaVersion: "latest", |
| 47 | + sourceType: "module", |
| 48 | + }, |
| 49 | + sourceType: "module", |
| 50 | + globals: { |
| 51 | + ...globals.browser, |
| 52 | + ...globals.serviceworker, |
| 53 | + ...globals.es2021, |
| 54 | + ...globals.webextensions, |
| 55 | + }, |
| 56 | + }, |
| 57 | + linterOptions: { |
| 58 | + reportUnusedDisableDirectives: true, |
| 59 | + }, |
| 60 | + rules: { |
| 61 | + "no-alert": "error", |
| 62 | + "no-console": "error", |
| 63 | + "no-debugger": "error", |
| 64 | + "no-empty": "off", |
| 65 | + "no-implicit-coercion": "error", |
| 66 | + "no-restricted-globals": [ |
| 67 | + "error", |
| 68 | + "name", |
| 69 | + "location", |
| 70 | + "history", |
| 71 | + "menubar", |
| 72 | + "scrollbars", |
| 73 | + "statusbar", |
| 74 | + "toolbar", |
| 75 | + "status", |
| 76 | + "closed", |
| 77 | + "frames", |
| 78 | + "length", |
| 79 | + "top", |
| 80 | + "opener", |
| 81 | + "parent", |
| 82 | + "origin", |
| 83 | + "external", |
| 84 | + "screen", |
| 85 | + "defaultstatus", |
| 86 | + "crypto", |
| 87 | + "close", |
| 88 | + "find", |
| 89 | + "focus", |
| 90 | + "open", |
| 91 | + "print", |
| 92 | + "scroll", |
| 93 | + "stop", |
| 94 | + "caches", |
| 95 | + "scheduler", |
| 96 | + ], |
| 97 | + // TODO: Switch to @stylistic/eslint-plugin-js for this one rule |
| 98 | + "spaced-comment": [ |
| 99 | + "error", |
| 100 | + "always", |
| 101 | + { exceptions: ["@__INLINE__"], block: { balanced: true } }, |
| 102 | + ], |
| 103 | + "arrow-body-style": ["error", "as-needed"], |
| 104 | + curly: ["error", "all"], |
| 105 | + eqeqeq: ["error", "always"], |
| 106 | + "no-return-await": "off", |
| 107 | + "@typescript-eslint/return-await": ["error", "in-try-catch"], |
| 108 | + "prefer-regex-literals": "error", |
| 109 | + "prefer-promise-reject-errors": "error", |
| 110 | + "prefer-spread": "error", |
| 111 | + radix: "error", |
| 112 | + yoda: "error", |
| 113 | + "class-methods-use-this": ["error", { exceptMethods: ["render"] }], |
| 114 | + "no-unmodified-loop-condition": "error", |
| 115 | + "no-unreachable-loop": "error", |
| 116 | + "no-unused-private-class-members": "error", |
| 117 | + "func-name-matching": "error", |
| 118 | + "logical-assignment-operators": "error", |
| 119 | + "no-lonely-if": "error", |
| 120 | + "no-unneeded-ternary": "error", |
| 121 | + "no-useless-call": "error", |
| 122 | + "no-useless-concat": "error", |
| 123 | + "no-useless-rename": "error", |
| 124 | + "@typescript-eslint/await-thenable": "error", |
| 125 | + "@typescript-eslint/no-misused-promises": [ |
| 126 | + "error", |
| 127 | + { |
| 128 | + checksVoidReturn: false, |
| 129 | + }, |
| 130 | + ], |
| 131 | + "@typescript-eslint/ban-types": "off", |
| 132 | + "@typescript-eslint/explicit-member-accessibility": "off", |
| 133 | + "@typescript-eslint/explicit-function-return-type": "off", |
| 134 | + "@typescript-eslint/explicit-module-boundary-types": "off", |
| 135 | + "@typescript-eslint/method-signature-style": "error", |
| 136 | + "@typescript-eslint/no-explicit-any": "off", |
| 137 | + "@typescript-eslint/no-var-requires": "off", |
| 138 | + "@typescript-eslint/no-non-null-assertion": "off", |
| 139 | + "@typescript-eslint/no-use-before-define": ["error", { functions: false }], |
| 140 | + "@typescript-eslint/no-parameter-properties": "off", |
| 141 | + "@typescript-eslint/no-extraneous-class": "error", |
| 142 | + "@typescript-eslint/no-this-alias": "error", |
| 143 | + "@typescript-eslint/no-unnecessary-type-constraint": "error", |
| 144 | + "@typescript-eslint/no-unnecessary-boolean-literal-compare": "error", |
| 145 | + "@typescript-eslint/no-unnecessary-qualifier": "error", |
| 146 | + "@typescript-eslint/no-unnecessary-type-assertion": "error", |
| 147 | + "@typescript-eslint/no-unnecessary-type-arguments": "error", |
| 148 | + "@typescript-eslint/prefer-function-type": "error", |
| 149 | + "@typescript-eslint/prefer-for-of": "error", |
| 150 | + "@typescript-eslint/prefer-optional-chain": "error", |
| 151 | + "@typescript-eslint/prefer-as-const": "error", |
| 152 | + "@typescript-eslint/prefer-reduce-type-parameter": "error", |
| 153 | + "@typescript-eslint/prefer-includes": "error", |
| 154 | + "@typescript-eslint/prefer-string-starts-ends-with": "error", |
| 155 | + "@typescript-eslint/prefer-ts-expect-error": "error", |
| 156 | + "@typescript-eslint/array-type": "error", |
| 157 | + "@typescript-eslint/no-non-null-asserted-optional-chain": "error", |
| 158 | + "@typescript-eslint/unified-signatures": "error", |
| 159 | + "@typescript-eslint/no-base-to-string": "error", |
| 160 | + "@typescript-eslint/non-nullable-type-assertion-style": "error", |
| 161 | + "@typescript-eslint/switch-exhaustiveness-check": "error", |
| 162 | + "@typescript-eslint/consistent-type-definitions": "error", |
| 163 | + "@typescript-eslint/consistent-generic-constructors": "error", |
| 164 | + "@typescript-eslint/no-duplicate-enum-values": "error", |
| 165 | + "@typescript-eslint/only-throw-error": "error", |
| 166 | + "@typescript-eslint/no-unused-vars": [ |
| 167 | + "error", |
| 168 | + { |
| 169 | + varsIgnorePattern: "^_.", |
| 170 | + argsIgnorePattern: "^_.", |
| 171 | + ignoreRestSiblings: true, |
| 172 | + }, |
| 173 | + ], |
| 174 | + "@typescript-eslint/no-for-in-array": "error", |
| 175 | + "@typescript-eslint/consistent-indexed-object-style": "off", |
| 176 | + "@typescript-eslint/no-floating-promises": "off", |
| 177 | + "@typescript-eslint/require-await": "off", |
| 178 | + "@typescript-eslint/no-unsafe-enum-comparison": "off", |
| 179 | + "@typescript-eslint/prefer-nullish-coalescing": [ |
| 180 | + "off", |
| 181 | + { |
| 182 | + ignoreConditionalTests: true, |
| 183 | + ignoreTernaryTests: false, |
| 184 | + ignoreMixedLogicalExpressions: true, |
| 185 | + ignorePrimitives: { |
| 186 | + boolean: true, |
| 187 | + number: false, |
| 188 | + string: true, |
| 189 | + }, |
| 190 | + }, |
| 191 | + ], |
| 192 | + "@typescript-eslint/no-unsafe-argument": "error", |
| 193 | + "@typescript-eslint/no-unsafe-assignment": "error", |
| 194 | + "@typescript-eslint/no-unsafe-call": "error", |
| 195 | + "@typescript-eslint/no-unsafe-member-access": "error", |
| 196 | + "@typescript-eslint/no-unsafe-return": "error", |
| 197 | + "@typescript-eslint/no-redundant-type-constituents": "off", |
| 198 | + "no-implied-eval": "off", |
| 199 | + "@typescript-eslint/no-implied-eval": "error", |
| 200 | + "array-func/prefer-array-from": "off", |
| 201 | + "sonarjs/cognitive-complexity": "off", |
| 202 | + "sonarjs/no-small-switch": "off", |
| 203 | + "sonarjs/no-duplicate-string": "off", |
| 204 | + "sonarjs/prefer-immediate-return": "off", |
| 205 | + "sonarjs/no-nested-switch": "off", |
| 206 | + "sonarjs/no-nested-template-literals": "off", |
| 207 | + }, |
| 208 | + } |
| 209 | +); |
0 commit comments