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.

330 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-cycle": "off",
  162. "import/no-default-export": "error",
  163. "import/no-duplicates": "error",
  164. "import/no-dynamic-require": "error",
  165. "import/no-self-import": "error",
  166. "import/no-unresolved": ["warn", { "ignore": ["vscode", "@env"] }],
  167. "import/order": [
  168. "warn",
  169. {
  170. "alphabetize": { "order": "asc", "caseInsensitive": true },
  171. "groups": ["builtin", "external", "internal", ["parent", "sibling", "index"]],
  172. // "groups": ["builtin", "external", "internal", ["index", "sibling", "parent"]],
  173. "newlines-between": "never"
  174. }
  175. ],
  176. "@typescript-eslint/ban-types": [
  177. "error",
  178. {
  179. "extendDefaults": false,
  180. "types": {
  181. "String": {
  182. "message": "Use string instead",
  183. "fixWith": "string"
  184. },
  185. "Boolean": {
  186. "message": "Use boolean instead",
  187. "fixWith": "boolean"
  188. },
  189. "Number": {
  190. "message": "Use number instead",
  191. "fixWith": "number"
  192. },
  193. "Symbol": {
  194. "message": "Use symbol instead",
  195. "fixWith": "symbol"
  196. },
  197. // "Function": {
  198. // "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."
  199. // },
  200. "Object": {
  201. "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."
  202. },
  203. "{}": {
  204. "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.",
  205. "fixWith": "object"
  206. }
  207. // "object": {
  208. // "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."
  209. // }
  210. }
  211. }
  212. ],
  213. "@typescript-eslint/consistent-type-assertions": [
  214. "error",
  215. {
  216. "assertionStyle": "as",
  217. "objectLiteralTypeAssertions": "allow-as-parameter"
  218. }
  219. ],
  220. "@typescript-eslint/consistent-type-imports": ["error", { "disallowTypeAnnotations": false }],
  221. "@typescript-eslint/explicit-function-return-type": "off",
  222. "@typescript-eslint/explicit-member-accessibility": "off",
  223. "@typescript-eslint/explicit-module-boundary-types": "off", // TODO@eamodio revisit
  224. "@typescript-eslint/naming-convention": [
  225. "error",
  226. {
  227. "selector": "variable",
  228. "format": ["camelCase", "PascalCase"],
  229. "leadingUnderscore": "allow",
  230. "filter": {
  231. "regex": "^_$",
  232. "match": false
  233. }
  234. },
  235. {
  236. "selector": "variableLike",
  237. "format": ["camelCase"],
  238. "leadingUnderscore": "allow",
  239. "filter": {
  240. "regex": "^_$",
  241. "match": false
  242. }
  243. },
  244. {
  245. "selector": "memberLike",
  246. "modifiers": ["private"],
  247. "format": ["camelCase"],
  248. "leadingUnderscore": "allow"
  249. },
  250. {
  251. "selector": "memberLike",
  252. "modifiers": ["private", "readonly"],
  253. "format": ["camelCase", "PascalCase"],
  254. "leadingUnderscore": "allow"
  255. },
  256. {
  257. "selector": "memberLike",
  258. "modifiers": ["static", "readonly"],
  259. "format": ["camelCase", "PascalCase"]
  260. },
  261. {
  262. "selector": "interface",
  263. "format": ["PascalCase"],
  264. "custom": {
  265. "regex": "^I[A-Z]",
  266. "match": false
  267. }
  268. }
  269. ],
  270. "@typescript-eslint/no-empty-function": "off",
  271. "@typescript-eslint/no-empty-interface": "error",
  272. "@typescript-eslint/no-explicit-any": "off",
  273. "@typescript-eslint/no-extraneous-class": "error",
  274. "@typescript-eslint/no-floating-promises": "error",
  275. "@typescript-eslint/no-inferrable-types": ["warn", { "ignoreParameters": true, "ignoreProperties": true }],
  276. "@typescript-eslint/no-meaningless-void-operator": "error",
  277. "@typescript-eslint/no-misused-promises": ["error", { "checksVoidReturn": false }],
  278. "@typescript-eslint/no-namespace": "off", // TODO: Should aim to enable this
  279. "@typescript-eslint/no-non-null-assertion": "off",
  280. "@typescript-eslint/no-non-null-asserted-nullish-coalescing": "error",
  281. "@typescript-eslint/no-throw-literal": "error",
  282. // "@typescript-eslint/no-unnecessary-condition": ["error", { "allowConstantLoopConditions": true }],
  283. "@typescript-eslint/no-unsafe-argument": "off",
  284. "@typescript-eslint/no-unsafe-assignment": "off",
  285. "@typescript-eslint/no-unsafe-call": "off",
  286. "@typescript-eslint/no-unsafe-member-access": "off",
  287. "@typescript-eslint/no-unsafe-return": "error",
  288. "@typescript-eslint/no-unused-expressions": ["warn", { "allowShortCircuit": true }],
  289. "@typescript-eslint/no-unused-vars": [
  290. "warn",
  291. {
  292. "args": "after-used",
  293. "argsIgnorePattern": "^_",
  294. "ignoreRestSiblings": true,
  295. "varsIgnorePattern": "^_$"
  296. }
  297. ],
  298. "@typescript-eslint/non-nullable-type-assertion-style": "error",
  299. "@typescript-eslint/prefer-for-of": "warn",
  300. "@typescript-eslint/prefer-includes": "warn",
  301. "@typescript-eslint/prefer-literal-enum-member": ["warn", { "allowBitwiseExpressions": true }],
  302. "@typescript-eslint/prefer-nullish-coalescing": "off", // warn
  303. "@typescript-eslint/prefer-optional-chain": "warn",
  304. "@typescript-eslint/prefer-reduce-type-parameter": "warn",
  305. "@typescript-eslint/restrict-template-expressions": [
  306. "error",
  307. { "allowAny": true, "allowBoolean": true, "allowNumber": true, "allowNullish": true }
  308. ],
  309. "@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
  310. },
  311. "settings": {
  312. "import/parsers": {
  313. "@typescript-eslint/parser": [".ts", ".tsx"]
  314. },
  315. "import/resolver": {
  316. "typescript": {
  317. "alwaysTryTypes": true // always try to resolve types under `<root>@types` directory even it doesn't contain any source code, like `@types/unist`
  318. }
  319. }
  320. },
  321. "ignorePatterns": ["dist/*", "out/*", "**/@types/*", "emojis.json", "tsconfig*.tsbuildinfo", "webpack.config*.js"],
  322. "overrides": [
  323. {
  324. "files": ["src/env/node/**/*"],
  325. "rules": {
  326. "no-restricted-imports": "off"
  327. }
  328. }
  329. ]
  330. }