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.

258 lines
8.4 KiB

  1. {
  2. "env": {
  3. "es6": true,
  4. "node": true
  5. },
  6. "extends": [
  7. "eslint:recommended",
  8. "plugin:@typescript-eslint/recommended",
  9. "plugin:@typescript-eslint/recommended-requiring-type-checking",
  10. "plugin:import/errors",
  11. "plugin:import/warnings",
  12. "plugin:import/typescript",
  13. "prettier"
  14. ],
  15. "parser": "@typescript-eslint/parser",
  16. "parserOptions": {
  17. "ecmaVersion": 2019,
  18. "sourceType": "module",
  19. "ecmaFeatures": {
  20. "impliedStrict": true
  21. },
  22. "project": "tsconfig.json"
  23. },
  24. "plugins": ["import", "@typescript-eslint"],
  25. "reportUnusedDisableDirectives": true,
  26. "root": true,
  27. "rules": {
  28. "arrow-parens": ["off"],
  29. "brace-style": ["off", "stroustrup"],
  30. "consistent-return": "error",
  31. "curly": ["error", "multi-line", "consistent"],
  32. "eol-last": "error",
  33. "linebreak-style": ["error", "unix"],
  34. "new-parens": "error",
  35. "no-console": "off",
  36. "no-constant-condition": ["warn", { "checkLoops": false }],
  37. "no-caller": "error",
  38. "no-debugger": "warn",
  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. // Turn off until fix for: https://github.com/typescript-eslint/typescript-eslint/issues/239
  50. "no-inner-declarations": "off",
  51. "no-lone-blocks": "error",
  52. "no-lonely-if": "error",
  53. "no-loop-func": "error",
  54. "no-multi-spaces": "error",
  55. "no-return-assign": "error",
  56. "no-return-await": "warn",
  57. "no-self-compare": "error",
  58. "no-sequences": "error",
  59. "no-template-curly-in-string": "warn",
  60. "no-throw-literal": "error",
  61. "no-unmodified-loop-condition": "warn",
  62. "no-unneeded-ternary": "error",
  63. "no-use-before-define": "off",
  64. "no-useless-call": "error",
  65. "no-useless-catch": "error",
  66. "no-useless-computed-key": "error",
  67. "no-useless-concat": "error",
  68. "no-useless-rename": "error",
  69. "no-useless-return": "error",
  70. "no-var": "error",
  71. "no-with": "error",
  72. "object-shorthand": ["error", "never"],
  73. "one-var": ["error", "never"],
  74. "prefer-arrow-callback": "error",
  75. "prefer-const": [
  76. "error",
  77. {
  78. "destructuring": "all",
  79. "ignoreReadBeforeAssign": false
  80. }
  81. ],
  82. "prefer-numeric-literals": "error",
  83. "prefer-object-spread": "error",
  84. "prefer-rest-params": "error",
  85. "prefer-spread": "error",
  86. "prefer-template": "error",
  87. "quotes": ["error", "single", { "avoidEscape": true, "allowTemplateLiterals": true }],
  88. // Turn off until fix for: https://github.com/eslint/eslint/issues/11899
  89. "require-atomic-updates": "off",
  90. "semi": ["error", "always"],
  91. "semi-style": ["error", "last"],
  92. "sort-imports": [
  93. "error",
  94. {
  95. "ignoreCase": true,
  96. "ignoreDeclarationSort": true,
  97. "ignoreMemberSort": false,
  98. "memberSyntaxSortOrder": ["none", "all", "multiple", "single"]
  99. }
  100. ],
  101. "yoda": "error",
  102. "import/export": "off",
  103. "import/extensions": ["error", "never"],
  104. "import/named": "off",
  105. "import/namespace": "off",
  106. "import/newline-after-import": "warn",
  107. "import/no-cycle": "off",
  108. "import/no-dynamic-require": "error",
  109. "import/no-default-export": "error",
  110. "import/no-self-import": "error",
  111. "import/no-unresolved": ["warn", { "ignore": ["vscode"] }],
  112. "import/order": [
  113. "warn",
  114. {
  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-assignment": "off",
  224. "@typescript-eslint/no-unsafe-call": "off",
  225. "@typescript-eslint/no-unsafe-member-access": "off",
  226. "@typescript-eslint/no-unsafe-return": "off",
  227. "@typescript-eslint/no-unused-expressions": ["warn", { "allowShortCircuit": true }],
  228. "@typescript-eslint/no-unused-vars": [
  229. "warn",
  230. {
  231. "args": "after-used",
  232. "argsIgnorePattern": "^_",
  233. "ignoreRestSiblings": true,
  234. "varsIgnorePattern": "^_$"
  235. }
  236. ],
  237. "@typescript-eslint/no-use-before-define": "off",
  238. "@typescript-eslint/prefer-nullish-coalescing": "off",
  239. "@typescript-eslint/prefer-optional-chain": "warn",
  240. "@typescript-eslint/restrict-template-expressions": [
  241. "error",
  242. { "allowAny": true, "allowBoolean": true, "allowNumber": true, "allowNullish": true }
  243. ],
  244. "@typescript-eslint/strict-boolean-expressions": [
  245. "warn",
  246. {
  247. "allowString": true,
  248. "allowNumber": true,
  249. "allowNullableObject": false,
  250. "allowNullableBoolean": true,
  251. "allowNullableNumber": true,
  252. "allowNullableString": true,
  253. "allowAny": false
  254. }
  255. ],
  256. "@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
  257. }
  258. }