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.

335 regels
10 KiB

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