Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

336 строки
10 KiB

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