You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

336 lines
9.9 KiB

пре 2 година
пре 2 година
пре 2 година
пре 2 година
пре 2 година
пре 1 година
пре 1 година
пре 1 година
пре 1 година
пре 2 година
пре 2 година
  1. {
  2. "env": {
  3. "es6": true
  4. },
  5. "extends": [
  6. "eslint:recommended",
  7. "plugin:@typescript-eslint/strict-type-checked",
  8. "plugin:import/recommended",
  9. "plugin:import/typescript",
  10. "prettier"
  11. ],
  12. "parser": "@typescript-eslint/parser",
  13. "parserOptions": {
  14. "ecmaVersion": 2022,
  15. "sourceType": "module",
  16. "ecmaFeatures": {
  17. "impliedStrict": true
  18. },
  19. "project": true
  20. },
  21. "plugins": ["anti-trojan-source", "import", "@typescript-eslint"],
  22. "reportUnusedDisableDirectives": true,
  23. "root": true,
  24. "rules": {
  25. "anti-trojan-source/no-bidi": "error",
  26. "no-constant-condition": ["warn", { "checkLoops": false }],
  27. "no-constant-binary-expression": "error",
  28. "no-caller": "error",
  29. "no-debugger": "off",
  30. "no-else-return": "warn",
  31. "no-empty": ["warn", { "allowEmptyCatch": true }],
  32. "no-eval": "error",
  33. "no-ex-assign": "warn",
  34. "no-extend-native": "error",
  35. "no-extra-bind": "error",
  36. "no-extra-semi": "off",
  37. "no-floating-decimal": "error",
  38. "no-implicit-coercion": "error",
  39. "no-implied-eval": "error",
  40. "no-inner-declarations": "off",
  41. "no-lone-blocks": "error",
  42. "no-lonely-if": "error",
  43. "no-loop-func": "error",
  44. "no-mixed-spaces-and-tabs": "off",
  45. "no-restricted-globals": ["error", "process"],
  46. "no-restricted-imports": [
  47. "error",
  48. {
  49. "paths": [
  50. // Disallow node imports below
  51. "assert",
  52. "buffer",
  53. "child_process",
  54. "cluster",
  55. "crypto",
  56. "dgram",
  57. "dns",
  58. "domain",
  59. "events",
  60. "freelist",
  61. "fs",
  62. "http",
  63. "https",
  64. "module",
  65. "net",
  66. "os",
  67. "path",
  68. "process",
  69. "punycode",
  70. "querystring",
  71. "readline",
  72. "repl",
  73. "smalloc",
  74. "stream",
  75. "string_decoder",
  76. "sys",
  77. "timers",
  78. "tls",
  79. "tracing",
  80. "tty",
  81. "url",
  82. "util",
  83. "vm",
  84. "zlib"
  85. ],
  86. "patterns": [
  87. {
  88. "group": ["**/env/**/*"],
  89. "message": "Use @env/ instead"
  90. },
  91. {
  92. "group": ["src/*"],
  93. "message": "Use relative paths instead"
  94. },
  95. {
  96. "group": ["react-dom"],
  97. "importNames": ["Container"],
  98. "message": "Use our Container instead"
  99. }
  100. ]
  101. }
  102. ],
  103. "no-return-assign": "error",
  104. "no-return-await": "warn",
  105. "no-self-compare": "error",
  106. "no-sequences": "error",
  107. "no-template-curly-in-string": "warn",
  108. "no-throw-literal": "error",
  109. "no-unmodified-loop-condition": "warn",
  110. "no-unneeded-ternary": "error",
  111. "no-unused-expressions": "error",
  112. "no-use-before-define": "off",
  113. "no-useless-call": "error",
  114. "no-useless-catch": "error",
  115. "no-useless-computed-key": "error",
  116. "no-useless-concat": "error",
  117. "no-useless-rename": "error",
  118. "no-useless-return": "error",
  119. "no-var": "error",
  120. "no-with": "error",
  121. "object-shorthand": ["error", "never"],
  122. "one-var": ["error", "never"],
  123. "prefer-arrow-callback": "error",
  124. "prefer-const": [
  125. "error",
  126. {
  127. "destructuring": "all",
  128. "ignoreReadBeforeAssign": true
  129. }
  130. ],
  131. "prefer-numeric-literals": "error",
  132. "prefer-object-spread": "error",
  133. "prefer-promise-reject-errors": ["error", { "allowEmptyReject": true }],
  134. "prefer-rest-params": "error",
  135. "prefer-spread": "error",
  136. "prefer-template": "error",
  137. "require-atomic-updates": "off",
  138. "sort-imports": [
  139. "error",
  140. {
  141. "ignoreCase": true,
  142. "ignoreDeclarationSort": true,
  143. "ignoreMemberSort": false,
  144. "memberSyntaxSortOrder": ["none", "all", "multiple", "single"]
  145. }
  146. ],
  147. "yoda": "error",
  148. "import/consistent-type-specifier-style": ["error", "prefer-top-level"],
  149. "import/extensions": "off",
  150. "import/newline-after-import": "warn",
  151. "import/no-absolute-path": "error",
  152. "import/no-cycle": "off",
  153. "import/no-default-export": "error",
  154. "import/no-duplicates": ["error", { "prefer-inline": false }],
  155. "import/no-dynamic-require": "error",
  156. "import/no-self-import": "error",
  157. "import/no-unresolved": ["warn", { "ignore": ["vscode", "@env"] }],
  158. "import/no-useless-path-segments": "error",
  159. "import/order": [
  160. "warn",
  161. {
  162. "alphabetize": {
  163. "order": "asc",
  164. "orderImportKind": "asc",
  165. "caseInsensitive": true
  166. },
  167. "groups": ["builtin", "external", "internal", "parent", "sibling", "index"],
  168. "newlines-between": "never"
  169. }
  170. ],
  171. "@typescript-eslint/ban-types": [
  172. "error",
  173. {
  174. "extendDefaults": false,
  175. "types": {
  176. "String": {
  177. "message": "Use string instead",
  178. "fixWith": "string"
  179. },
  180. "Boolean": {
  181. "message": "Use boolean instead",
  182. "fixWith": "boolean"
  183. },
  184. "Number": {
  185. "message": "Use number instead",
  186. "fixWith": "number"
  187. },
  188. "Symbol": {
  189. "message": "Use symbol instead",
  190. "fixWith": "symbol"
  191. },
  192. // "Function": {
  193. // "message": "The `Function` type accepts any function-like value.\nIt provides no type safety when calling the function, which can be a common source of bugs.\nIt also accepts things like class declarations, which will throw at runtime as they will not be called with `new`.\nIf you are expecting the function to accept certain arguments, you should explicitly define the function shape."
  194. // },
  195. "Object": {
  196. "message": "The `Object` type actually means \"any non-nullish value\", so it is marginally better than `unknown`.\n- If you want a type meaning \"any object\", you probably want `Record<string, unknown>` instead.\n- If you want a type meaning \"any value\", you probably want `unknown` instead."
  197. },
  198. "{}": {
  199. "message": "`{}` actually means \"any non-nullish value\".\n- If you want a type meaning \"any object\", you probably want `object` or `Record<string, unknown>` instead.\n- If you want a type meaning \"any value\", you probably want `unknown` instead.",
  200. "fixWith": "object"
  201. }
  202. // "object": {
  203. // "message": "The `object` type is currently hard to use ([see this issue](https://github.com/microsoft/TypeScript/issues/21732)).\nConsider using `Record<string, unknown>` instead, as it allows you to more easily inspect and use the keys."
  204. // }
  205. }
  206. }
  207. ],
  208. "@typescript-eslint/consistent-type-assertions": [
  209. "error",
  210. {
  211. "assertionStyle": "as",
  212. "objectLiteralTypeAssertions": "allow-as-parameter"
  213. }
  214. ],
  215. "@typescript-eslint/consistent-type-imports": ["error", { "disallowTypeAnnotations": false }],
  216. "@typescript-eslint/naming-convention": [
  217. "error",
  218. {
  219. "selector": "variable",
  220. "format": ["camelCase", "PascalCase"],
  221. "leadingUnderscore": "allow",
  222. "filter": {
  223. "regex": "^_$",
  224. "match": false
  225. }
  226. },
  227. {
  228. "selector": "variableLike",
  229. "format": ["camelCase"],
  230. "leadingUnderscore": "allow",
  231. "filter": {
  232. "regex": "^_$",
  233. "match": false
  234. }
  235. },
  236. {
  237. "selector": "memberLike",
  238. "modifiers": ["private"],
  239. "format": ["camelCase"],
  240. "leadingUnderscore": "allow"
  241. },
  242. {
  243. "selector": "memberLike",
  244. "modifiers": ["private", "readonly"],
  245. "format": ["camelCase", "PascalCase"],
  246. "leadingUnderscore": "allow"
  247. },
  248. {
  249. "selector": "memberLike",
  250. "modifiers": ["static", "readonly"],
  251. "format": ["camelCase", "PascalCase"]
  252. },
  253. {
  254. "selector": "interface",
  255. "format": ["PascalCase"],
  256. "custom": {
  257. "regex": "^I[A-Z]",
  258. "match": false
  259. }
  260. }
  261. ],
  262. "@typescript-eslint/no-confusing-void-expression": [
  263. "error",
  264. { "ignoreArrowShorthand": true, "ignoreVoidOperator": true }
  265. ],
  266. "@typescript-eslint/no-explicit-any": "off",
  267. "@typescript-eslint/no-inferrable-types": ["warn", { "ignoreParameters": true, "ignoreProperties": true }],
  268. "@typescript-eslint/no-invalid-void-type": "off", // Seems to error on `void` return types
  269. "@typescript-eslint/no-misused-promises": ["error", { "checksVoidReturn": false }],
  270. "@typescript-eslint/no-non-null-assertion": "off",
  271. "@typescript-eslint/no-redundant-type-constituents": "off",
  272. "@typescript-eslint/no-unnecessary-condition": "off",
  273. "@typescript-eslint/no-unnecessary-boolean-literal-compare": "off",
  274. "@typescript-eslint/no-unsafe-argument": "off",
  275. "@typescript-eslint/no-unsafe-assignment": "off",
  276. "@typescript-eslint/no-unsafe-call": "off",
  277. "@typescript-eslint/no-unsafe-enum-comparison": "off",
  278. "@typescript-eslint/no-unsafe-member-access": "off",
  279. "@typescript-eslint/no-unused-expressions": ["warn", { "allowShortCircuit": true }],
  280. "@typescript-eslint/no-unused-vars": [
  281. "warn",
  282. {
  283. "args": "after-used",
  284. "argsIgnorePattern": "^_",
  285. "ignoreRestSiblings": true,
  286. "varsIgnorePattern": "^_$"
  287. }
  288. ],
  289. "@typescript-eslint/no-use-before-define": ["error", { "functions": false, "classes": false }],
  290. "@typescript-eslint/prefer-for-of": "warn",
  291. "@typescript-eslint/prefer-includes": "warn",
  292. "@typescript-eslint/prefer-literal-enum-member": ["warn", { "allowBitwiseExpressions": true }],
  293. "@typescript-eslint/prefer-optional-chain": "warn",
  294. "@typescript-eslint/prefer-reduce-type-parameter": "warn",
  295. "@typescript-eslint/restrict-template-expressions": [
  296. "error",
  297. { "allowAny": true, "allowBoolean": true, "allowNumber": true, "allowNullish": true }
  298. ],
  299. "@typescript-eslint/unbound-method": "off", // Too many bugs right now: https://github.com/typescript-eslint/typescript-eslint/issues?utf8=%E2%9C%93&q=is%3Aissue+is%3Aopen+unbound-method
  300. "@typescript-eslint/unified-signatures": ["error", { "ignoreDifferentlyNamedParameters": true }]
  301. },
  302. "settings": {
  303. "import/parsers": {
  304. "@typescript-eslint/parser": [".ts", ".tsx"]
  305. },
  306. "import/resolver": {
  307. "typescript": {
  308. "alwaysTryTypes": true // always try to resolve types under `<root>@types` directory even it doesn't contain any source code, like `@types/unist`
  309. }
  310. }
  311. },
  312. "ignorePatterns": ["dist/*", "out/*", "**/@types/*", "emojis.json", "tsconfig*.tsbuildinfo", "webpack.config*.js"],
  313. "overrides": [
  314. {
  315. "files": ["src/env/node/**/*"],
  316. "rules": {
  317. "no-restricted-imports": [
  318. "error",
  319. {
  320. "patterns": [
  321. {
  322. "group": ["src/*"],
  323. "message": "Use relative paths instead"
  324. },
  325. {
  326. "group": ["react-dom"],
  327. "importNames": ["Container"],
  328. "message": "Use our Container instead"
  329. }
  330. ]
  331. }
  332. ]
  333. }
  334. }
  335. ]
  336. }