Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

342 rindas
11 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": 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. "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-unused-expressions": "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": true
  135. }
  136. ],
  137. "prefer-numeric-literals": "error",
  138. "prefer-object-spread": "error",
  139. "prefer-promise-reject-errors": ["error", { "allowEmptyReject": true }],
  140. "prefer-rest-params": "error",
  141. "prefer-spread": "error",
  142. "prefer-template": "error",
  143. "quotes": ["error", "single", { "avoidEscape": true, "allowTemplateLiterals": true }],
  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/consistent-type-specifier-style": ["error", "prefer-top-level"],
  158. "import/extensions": ["error", "never"],
  159. "import/newline-after-import": "warn",
  160. "import/no-absolute-path": "error",
  161. "import/no-cycle": "off",
  162. "import/no-default-export": "error",
  163. "import/no-duplicates": ["error", { "prefer-inline": false }],
  164. "import/no-dynamic-require": "error",
  165. "import/no-self-import": "error",
  166. "import/no-unresolved": ["warn", { "ignore": ["vscode", "@env"] }],
  167. "import/no-useless-path-segments": "error",
  168. "import/order": [
  169. "warn",
  170. {
  171. "alphabetize": {
  172. "order": "asc",
  173. "orderImportKind": "asc",
  174. "caseInsensitive": true
  175. },
  176. "groups": ["builtin", "external", "internal", "parent", "sibling", "index"],
  177. "newlines-between": "never"
  178. }
  179. ],
  180. "@typescript-eslint/ban-types": [
  181. "error",
  182. {
  183. "extendDefaults": false,
  184. "types": {
  185. "String": {
  186. "message": "Use string instead",
  187. "fixWith": "string"
  188. },
  189. "Boolean": {
  190. "message": "Use boolean instead",
  191. "fixWith": "boolean"
  192. },
  193. "Number": {
  194. "message": "Use number instead",
  195. "fixWith": "number"
  196. },
  197. "Symbol": {
  198. "message": "Use symbol instead",
  199. "fixWith": "symbol"
  200. },
  201. // "Function": {
  202. // "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."
  203. // },
  204. "Object": {
  205. "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."
  206. },
  207. "{}": {
  208. "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.",
  209. "fixWith": "object"
  210. }
  211. // "object": {
  212. // "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."
  213. // }
  214. }
  215. }
  216. ],
  217. "@typescript-eslint/consistent-type-assertions": [
  218. "error",
  219. {
  220. "assertionStyle": "as",
  221. "objectLiteralTypeAssertions": "allow-as-parameter"
  222. }
  223. ],
  224. "@typescript-eslint/consistent-type-imports": ["error", { "disallowTypeAnnotations": false }],
  225. "@typescript-eslint/explicit-function-return-type": "off",
  226. "@typescript-eslint/explicit-member-accessibility": "off",
  227. "@typescript-eslint/explicit-module-boundary-types": "off", // TODO@eamodio revisit
  228. "@typescript-eslint/naming-convention": [
  229. "error",
  230. {
  231. "selector": "variable",
  232. "format": ["camelCase", "PascalCase"],
  233. "leadingUnderscore": "allow",
  234. "filter": {
  235. "regex": "^_$",
  236. "match": false
  237. }
  238. },
  239. {
  240. "selector": "variableLike",
  241. "format": ["camelCase"],
  242. "leadingUnderscore": "allow",
  243. "filter": {
  244. "regex": "^_$",
  245. "match": false
  246. }
  247. },
  248. {
  249. "selector": "memberLike",
  250. "modifiers": ["private"],
  251. "format": ["camelCase"],
  252. "leadingUnderscore": "allow"
  253. },
  254. {
  255. "selector": "memberLike",
  256. "modifiers": ["private", "readonly"],
  257. "format": ["camelCase", "PascalCase"],
  258. "leadingUnderscore": "allow"
  259. },
  260. {
  261. "selector": "memberLike",
  262. "modifiers": ["static", "readonly"],
  263. "format": ["camelCase", "PascalCase"]
  264. },
  265. {
  266. "selector": "interface",
  267. "format": ["PascalCase"],
  268. "custom": {
  269. "regex": "^I[A-Z]",
  270. "match": false
  271. }
  272. }
  273. ],
  274. "@typescript-eslint/no-dynamic-delete": "error",
  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-invalid-void-type": "off", // Seems to error on `void` return types
  282. "@typescript-eslint/no-meaningless-void-operator": "error",
  283. "@typescript-eslint/no-misused-promises": ["error", { "checksVoidReturn": false }],
  284. "@typescript-eslint/no-namespace": "error",
  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-unnecessary-condition": "off",
  290. "@typescript-eslint/no-unnecessary-boolean-literal-compare": "off",
  291. "@typescript-eslint/no-unnecessary-type-arguments": "error",
  292. "@typescript-eslint/no-unsafe-argument": "off",
  293. "@typescript-eslint/no-unsafe-assignment": "off",
  294. "@typescript-eslint/no-unsafe-call": "off",
  295. "@typescript-eslint/no-unsafe-member-access": "off",
  296. "@typescript-eslint/no-unsafe-return": "error",
  297. "@typescript-eslint/no-unused-expressions": ["warn", { "allowShortCircuit": true }],
  298. "@typescript-eslint/no-unused-vars": [
  299. "warn",
  300. {
  301. "args": "after-used",
  302. "argsIgnorePattern": "^_",
  303. "ignoreRestSiblings": true,
  304. "varsIgnorePattern": "^_$"
  305. }
  306. ],
  307. "@typescript-eslint/no-use-before-define": ["error", { "functions": false, "classes": false }],
  308. "@typescript-eslint/no-useless-constructor": "error",
  309. "@typescript-eslint/non-nullable-type-assertion-style": "error",
  310. "@typescript-eslint/prefer-for-of": "warn",
  311. "@typescript-eslint/prefer-includes": "warn",
  312. "@typescript-eslint/prefer-literal-enum-member": ["warn", { "allowBitwiseExpressions": true }],
  313. "@typescript-eslint/prefer-nullish-coalescing": "off", // warn
  314. "@typescript-eslint/prefer-optional-chain": "warn",
  315. "@typescript-eslint/prefer-reduce-type-parameter": "warn",
  316. "@typescript-eslint/restrict-template-expressions": [
  317. "error",
  318. { "allowAny": true, "allowBoolean": true, "allowNumber": true, "allowNullish": true }
  319. ],
  320. "@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
  321. "@typescript-eslint/unified-signatures": ["error", { "ignoreDifferentlyNamedParameters": true }]
  322. },
  323. "settings": {
  324. "import/parsers": {
  325. "@typescript-eslint/parser": [".ts", ".tsx"]
  326. },
  327. "import/resolver": {
  328. "typescript": {
  329. "alwaysTryTypes": true // always try to resolve types under `<root>@types` directory even it doesn't contain any source code, like `@types/unist`
  330. }
  331. }
  332. },
  333. "ignorePatterns": ["dist/*", "out/*", "**/@types/*", "emojis.json", "tsconfig*.tsbuildinfo", "webpack.config*.js"],
  334. "overrides": [
  335. {
  336. "files": ["src/env/node/**/*"],
  337. "rules": {
  338. "no-restricted-imports": "off"
  339. }
  340. }
  341. ]
  342. }