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.

269 line
8.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": "error",
  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": "warn",
  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-return-assign": "error",
  54. "no-return-await": "warn",
  55. "no-self-compare": "error",
  56. "no-sequences": "error",
  57. "no-template-curly-in-string": "warn",
  58. "no-throw-literal": "error",
  59. "no-unmodified-loop-condition": "warn",
  60. "no-unneeded-ternary": "error",
  61. "no-use-before-define": "off",
  62. "no-useless-call": "error",
  63. "no-useless-catch": "error",
  64. "no-useless-computed-key": "error",
  65. "no-useless-concat": "error",
  66. "no-useless-rename": "error",
  67. "no-useless-return": "error",
  68. "no-var": "error",
  69. "no-with": "error",
  70. "object-shorthand": ["error", "never"],
  71. "one-var": ["error", "never"],
  72. "prefer-arrow-callback": "error",
  73. "prefer-const": [
  74. "error",
  75. {
  76. "destructuring": "all",
  77. "ignoreReadBeforeAssign": false
  78. }
  79. ],
  80. "prefer-numeric-literals": "error",
  81. "prefer-object-spread": "error",
  82. "prefer-rest-params": "error",
  83. "prefer-spread": "error",
  84. "prefer-template": "error",
  85. "quotes": ["error", "single", { "avoidEscape": true, "allowTemplateLiterals": true }],
  86. // Turn off until fix for: https://github.com/eslint/eslint/issues/11899
  87. "require-atomic-updates": "off",
  88. "semi": ["error", "always"],
  89. "semi-style": ["error", "last"],
  90. "sort-imports": [
  91. "error",
  92. {
  93. "ignoreCase": true,
  94. "ignoreDeclarationSort": true,
  95. "ignoreMemberSort": false,
  96. "memberSyntaxSortOrder": ["none", "all", "multiple", "single"]
  97. }
  98. ],
  99. "yoda": "error",
  100. "import/export": "off",
  101. "import/extensions": ["error", "never"],
  102. "import/named": "off",
  103. "import/namespace": "off",
  104. "import/newline-after-import": "warn",
  105. "import/no-cycle": "off",
  106. "import/no-dynamic-require": "error",
  107. "import/no-default-export": "error",
  108. "import/no-self-import": "error",
  109. "import/no-unresolved": ["warn", { "ignore": ["vscode", "@env"] }],
  110. "import/order": [
  111. "warn",
  112. {
  113. "alphabetize": { "order": "asc", "caseInsensitive": true },
  114. "groups": ["builtin", "external", "internal", ["parent", "sibling", "index"]],
  115. // "groups": ["builtin", "external", "internal", ["index", "sibling", "parent"]],
  116. "newlines-between": "never"
  117. }
  118. ],
  119. "@typescript-eslint/ban-types": [
  120. "error",
  121. {
  122. "extendDefaults": false,
  123. "types": {
  124. "String": {
  125. "message": "Use string instead",
  126. "fixWith": "string"
  127. },
  128. "Boolean": {
  129. "message": "Use boolean instead",
  130. "fixWith": "boolean"
  131. },
  132. "Number": {
  133. "message": "Use number instead",
  134. "fixWith": "number"
  135. },
  136. "Symbol": {
  137. "message": "Use symbol instead",
  138. "fixWith": "symbol"
  139. },
  140. // "Function": {
  141. // "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."
  142. // },
  143. "Object": {
  144. "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."
  145. },
  146. "{}": {
  147. "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.",
  148. "fixWith": "object"
  149. }
  150. // "object": {
  151. // "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."
  152. // }
  153. }
  154. }
  155. ],
  156. "@typescript-eslint/consistent-type-assertions": [
  157. "error",
  158. {
  159. "assertionStyle": "as",
  160. "objectLiteralTypeAssertions": "allow-as-parameter"
  161. }
  162. ],
  163. "@typescript-eslint/explicit-function-return-type": "off",
  164. "@typescript-eslint/explicit-member-accessibility": "off",
  165. "@typescript-eslint/explicit-module-boundary-types": "off", // TODO@eamodio revisit
  166. "@typescript-eslint/naming-convention": [
  167. "error",
  168. {
  169. "selector": "variable",
  170. "format": ["camelCase", "PascalCase"],
  171. "leadingUnderscore": "allow",
  172. "filter": {
  173. "regex": "^_$",
  174. "match": false
  175. }
  176. },
  177. {
  178. "selector": "variableLike",
  179. "format": ["camelCase"],
  180. "leadingUnderscore": "allow",
  181. "filter": {
  182. "regex": "^_$",
  183. "match": false
  184. }
  185. },
  186. {
  187. "selector": "memberLike",
  188. "modifiers": ["private"],
  189. "format": ["camelCase"],
  190. "leadingUnderscore": "allow"
  191. },
  192. {
  193. "selector": "memberLike",
  194. "modifiers": ["private", "readonly"],
  195. "format": ["camelCase", "PascalCase"],
  196. "leadingUnderscore": "allow"
  197. },
  198. {
  199. "selector": "memberLike",
  200. "modifiers": ["static", "readonly"],
  201. "format": ["camelCase", "PascalCase"]
  202. },
  203. {
  204. "selector": "interface",
  205. "format": ["PascalCase"],
  206. "custom": {
  207. "regex": "^I[A-Z]",
  208. "match": false
  209. }
  210. }
  211. ],
  212. "@typescript-eslint/no-duplicate-imports": "error",
  213. "@typescript-eslint/no-empty-function": "off",
  214. "@typescript-eslint/no-empty-interface": "error",
  215. "@typescript-eslint/no-explicit-any": "off",
  216. "@typescript-eslint/no-floating-promises": "error",
  217. "@typescript-eslint/no-inferrable-types": ["warn", { "ignoreParameters": true, "ignoreProperties": true }],
  218. "@typescript-eslint/no-misused-promises": ["error", { "checksVoidReturn": false }],
  219. "@typescript-eslint/no-namespace": "off",
  220. "@typescript-eslint/no-non-null-assertion": "off",
  221. "@typescript-eslint/no-parameter-properties": "off",
  222. "@typescript-eslint/no-unnecessary-condition": "off",
  223. "@typescript-eslint/no-unsafe-argument": "off",
  224. "@typescript-eslint/no-unsafe-assignment": "off",
  225. "@typescript-eslint/no-unsafe-call": "off",
  226. "@typescript-eslint/no-unsafe-member-access": "off",
  227. "@typescript-eslint/no-unsafe-return": "off",
  228. "@typescript-eslint/no-unused-expressions": ["warn", { "allowShortCircuit": true }],
  229. "@typescript-eslint/no-unused-vars": [
  230. "warn",
  231. {
  232. "args": "after-used",
  233. "argsIgnorePattern": "^_",
  234. "ignoreRestSiblings": true,
  235. "varsIgnorePattern": "^_$"
  236. }
  237. ],
  238. "@typescript-eslint/no-use-before-define": "off",
  239. "@typescript-eslint/prefer-nullish-coalescing": "off",
  240. "@typescript-eslint/prefer-optional-chain": "warn",
  241. "@typescript-eslint/restrict-template-expressions": [
  242. "error",
  243. { "allowAny": true, "allowBoolean": true, "allowNumber": true, "allowNullish": true }
  244. ],
  245. "@typescript-eslint/strict-boolean-expressions": [
  246. "warn",
  247. {
  248. "allowString": true,
  249. "allowNumber": true,
  250. "allowNullableObject": false,
  251. "allowNullableBoolean": true,
  252. "allowNullableNumber": true,
  253. "allowNullableString": true,
  254. "allowAny": false
  255. }
  256. ],
  257. "@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
  258. },
  259. "settings": {
  260. "import/parsers": {
  261. "@typescript-eslint/parser": [".ts", ".tsx"]
  262. },
  263. "import/resolver": {
  264. "typescript": {
  265. "alwaysTryTypes": true // always try to resolve types under `<root>@types` directory even it doesn't contain any source code, like `@types/unist`
  266. }
  267. }
  268. }
  269. }