Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.

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