eslint.config.mjs 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285
  1. import { defineConfig } from "eslint/config";
  2. import typescriptEslint from "@typescript-eslint/eslint-plugin";
  3. import globals from "globals";
  4. import tsParser from "@typescript-eslint/parser";
  5. import path from "node:path";
  6. import { fileURLToPath } from "node:url";
  7. import js from "@eslint/js";
  8. import { FlatCompat } from "@eslint/eslintrc";
  9. const __filename = fileURLToPath(import.meta.url);
  10. const __dirname = path.dirname(__filename);
  11. const compat = new FlatCompat({
  12. baseDirectory: __dirname,
  13. recommendedConfig: js.configs.recommended,
  14. allConfig: js.configs.all
  15. });
  16. export default defineConfig([{
  17. extends: compat.extends(
  18. "eslint:recommended",
  19. "plugin:@typescript-eslint/eslint-recommended",
  20. "plugin:@typescript-eslint/recommended",
  21. ),
  22. plugins: {
  23. "@typescript-eslint": typescriptEslint,
  24. },
  25. languageOptions: {
  26. globals: {
  27. ...globals.browser,
  28. ...globals.jasmine,
  29. Uint8Array: true,
  30. Promise: true,
  31. define: true,
  32. require: true,
  33. sinon: true,
  34. window: true,
  35. },
  36. parser: tsParser,
  37. ecmaVersion: 2020,
  38. sourceType: "module",
  39. parserOptions: {
  40. allowImportExportEverywhere: true,
  41. },
  42. },
  43. rules: {
  44. "accessor-pairs": "error",
  45. "array-bracket-spacing": "off",
  46. "array-callback-return": "error",
  47. "arrow-body-style": "off",
  48. "arrow-parens": "off",
  49. "arrow-spacing": "error",
  50. "block-scoped-var": "off",
  51. "block-spacing": "off",
  52. "brace-style": "off",
  53. "callback-return": "off",
  54. camelcase: "off",
  55. "capitalized-comments": "off",
  56. "class-methods-use-this": "off",
  57. "comma-dangle": "off",
  58. "comma-spacing": "off",
  59. "comma-style": "off",
  60. complexity: "off",
  61. "computed-property-spacing": ["error", "never"],
  62. "consistent-return": "off",
  63. "consistent-this": "off",
  64. curly: "off",
  65. "default-case": "off",
  66. "dot-location": ["error", "property"],
  67. "dot-notation": ["off", {
  68. allowKeywords: true,
  69. }],
  70. "eol-last": "error",
  71. eqeqeq: "off",
  72. "func-call-spacing": "off",
  73. "no-spaced-func": "off",
  74. "no-redeclare": "off",
  75. "func-name-matching": "error",
  76. "func-names": "off",
  77. "func-style": "off",
  78. "generator-star-spacing": "error",
  79. "global-require": "off",
  80. "guard-for-in": "error",
  81. "handle-callback-err": "error",
  82. "id-blacklist": "error",
  83. "id-length": "off",
  84. "id-match": "error",
  85. indent: "off",
  86. "init-declarations": "off",
  87. "jsx-quotes": "error",
  88. "key-spacing": "off",
  89. "keyword-spacing": "off",
  90. "line-comment-position": "off",
  91. "linebreak-style": ["error", "unix"],
  92. "lines-around-comment": "off",
  93. "lines-around-directive": "off",
  94. "max-depth": "error",
  95. "max-len": ["error", {
  96. code: 120,
  97. ignoreStrings: true,
  98. ignoreComments: true,
  99. ignoreUrls: true,
  100. }],
  101. "max-lines": "off",
  102. "max-nested-callbacks": "off",
  103. "max-params": "off",
  104. "max-statements": "off",
  105. "max-statements-per-line": "off",
  106. "multiline-ternary": "off",
  107. "new-parens": "error",
  108. "newline-after-var": "off",
  109. "newline-before-return": "off",
  110. "newline-per-chained-call": "off",
  111. "no-alert": "off",
  112. "no-array-constructor": "error",
  113. "no-await-in-loop": "off",
  114. "no-bitwise": "off",
  115. "no-caller": "error",
  116. "no-console": "off",
  117. "no-catch-shadow": "off",
  118. "no-cond-assign": ["off", "except-parens"],
  119. "no-confusing-arrow": "off",
  120. "no-continue": "off",
  121. "no-div-regex": "error",
  122. "no-duplicate-imports": "error",
  123. "no-else-return": "off",
  124. "no-empty-function": "off",
  125. "no-eq-null": "error",
  126. "no-eval": "error",
  127. "no-extend-native": "off",
  128. "no-extra-bind": "off",
  129. "no-extra-label": "error",
  130. "no-extra-parens": "off",
  131. "no-floating-decimal": "error",
  132. "no-implicit-globals": "off",
  133. "no-implied-eval": "error",
  134. "no-inline-comments": "off",
  135. "no-inner-declarations": ["error", "functions"],
  136. "no-invalid-this": "off",
  137. "no-iterator": "error",
  138. "no-label-var": "error",
  139. "no-labels": "error",
  140. "no-lone-blocks": "error",
  141. "no-lonely-if": "off",
  142. "no-loop-func": "error",
  143. "no-magic-numbers": "off",
  144. "no-mixed-operators": "off",
  145. "no-mixed-requires": "error",
  146. "no-multi-assign": "off",
  147. "no-multi-spaces": "off",
  148. "no-multi-str": "error",
  149. "no-multiple-empty-lines": "error",
  150. "no-native-reassign": "error",
  151. "no-negated-condition": "off",
  152. "no-negated-in-lhs": "error",
  153. "no-nested-ternary": "off",
  154. "no-new": "off",
  155. "no-new-func": "error",
  156. "no-new-object": "error",
  157. "no-new-require": "error",
  158. "no-new-wrappers": "error",
  159. "no-octal-escape": "error",
  160. "no-param-reassign": "off",
  161. "no-path-concat": "error",
  162. "no-plusplus": "off",
  163. "no-process-env": "off",
  164. "no-process-exit": "error",
  165. "no-proto": "error",
  166. "no-prototype-builtins": "error",
  167. "no-restricted-globals": "error",
  168. "no-restricted-imports": "error",
  169. "no-restricted-modules": "error",
  170. "no-restricted-properties": "error",
  171. "no-restricted-syntax": "error",
  172. "no-return-assign": "error",
  173. "no-return-await": "off",
  174. "no-script-url": "error",
  175. "no-self-compare": "error",
  176. "no-sequences": "error",
  177. "no-shadow": "off",
  178. "no-shadow-restricted-names": "error",
  179. "no-sync": "error",
  180. "no-tabs": "error",
  181. "no-template-curly-in-string": "error",
  182. "no-ternary": "off",
  183. "no-throw-literal": "error",
  184. "no-trailing-spaces": "off",
  185. "no-undef-init": "error",
  186. "no-undefined": "off",
  187. "no-underscore-dangle": "off",
  188. "no-unmodified-loop-condition": "error",
  189. "no-unneeded-ternary": "off",
  190. "no-unused-vars": ["error", {
  191. argsIgnorePattern: "^_",
  192. }],
  193. "@typescript-eslint/no-unused-vars": ["error", {
  194. args: "all",
  195. argsIgnorePattern: "^_",
  196. caughtErrors: "all",
  197. caughtErrorsIgnorePattern: "^_",
  198. destructuredArrayIgnorePattern: "^_",
  199. varsIgnorePattern: "^_",
  200. ignoreRestSiblings: true,
  201. }],
  202. "no-unused-expressions": "off",
  203. "no-use-before-define": "off",
  204. "no-useless-call": "error",
  205. "no-useless-catch": "off",
  206. "no-useless-computed-key": "error",
  207. "no-useless-concat": "off",
  208. "no-useless-constructor": "error",
  209. "no-useless-escape": "off",
  210. "no-useless-rename": "error",
  211. "no-useless-return": "off",
  212. "no-var": "off",
  213. "no-void": "error",
  214. "no-warning-comments": "off",
  215. "no-whitespace-before-property": "error",
  216. "no-with": "error",
  217. "object-curly-newline": "off",
  218. "object-curly-spacing": "off",
  219. "object-property-newline": ["off", {
  220. allowMultiplePropertiesPerLine: true,
  221. }],
  222. "object-shorthand": "off",
  223. "one-var": "off",
  224. "one-var-declaration-per-line": "off",
  225. "operator-assignment": "off",
  226. "operator-linebreak": "off",
  227. "padded-blocks": "off",
  228. "prefer-arrow-callback": "off",
  229. "prefer-const": "error",
  230. "prefer-destructuring": ["error", {
  231. array: false,
  232. object: false,
  233. }],
  234. "prefer-numeric-literals": "error",
  235. "prefer-promise-reject-errors": "off",
  236. "prefer-reflect": "off",
  237. "prefer-rest-params": "off",
  238. "prefer-spread": "off",
  239. "prefer-template": "off",
  240. "quote-props": "off",
  241. quotes: "off",
  242. radix: ["error", "always"],
  243. "require-atomic-updates": "off",
  244. "require-await": "error",
  245. "require-jsdoc": "off",
  246. "rest-spread-spacing": "error",
  247. semi: "off",
  248. "semi-spacing": "off",
  249. "sort-imports": "off",
  250. "sort-keys": "off",
  251. "sort-vars": "off",
  252. "space-before-blocks": "off",
  253. "space-before-function-paren": "off",
  254. "space-in-parens": "off",
  255. "space-infix-ops": "off",
  256. "space-unary-ops": "off",
  257. "spaced-comment": "off",
  258. strict: "off",
  259. "symbol-description": "error",
  260. "template-curly-spacing": "off",
  261. "unicode-bom": ["error", "never"],
  262. "valid-jsdoc": "off",
  263. "vars-on-top": "off",
  264. "wrap-iife": ["error", "any"],
  265. "wrap-regex": "error",
  266. "yield-star-spacing": "error",
  267. yoda: "off",
  268. },
  269. }]);