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.

261 lines
8.6 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. "alphabetize": { "order": "asc", "caseInsensitive": true },
  116. "groups": ["builtin", "external", "internal", ["parent", "sibling", "index"]],
  117. // "groups": ["builtin", "external", "internal", ["index", "sibling", "parent"]],
  118. "newlines-between": "never"
  119. }
  120. ],
  121. "@typescript-eslint/ban-types": [
  122. "error",
  123. {
  124. "extendDefaults": false,
  125. "types": {
  126. "String": {
  127. "message": "Use string instead",
  128. "fixWith": "string"
  129. },
  130. "Boolean": {
  131. "message": "Use boolean instead",
  132. "fixWith": "boolean"
  133. },
  134. "Number": {
  135. "message": "Use number instead",
  136. "fixWith": "number"
  137. },
  138. "Symbol": {
  139. "message": "Use symbol instead",
  140. "fixWith": "symbol"
  141. },
  142. // "Function": {
  143. // "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."
  144. // },
  145. "Object": {
  146. "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."
  147. },
  148. "{}": {
  149. "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.",
  150. "fixWith": "object"
  151. }
  152. // "object": {
  153. // "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."
  154. // }
  155. }
  156. }
  157. ],
  158. "@typescript-eslint/consistent-type-assertions": [
  159. "error",
  160. {
  161. "assertionStyle": "as",
  162. "objectLiteralTypeAssertions": "allow-as-parameter"
  163. }
  164. ],
  165. "@typescript-eslint/explicit-function-return-type": "off",
  166. "@typescript-eslint/explicit-member-accessibility": "off",
  167. "@typescript-eslint/explicit-module-boundary-types": "off", // TODO@eamodio revisit
  168. "@typescript-eslint/naming-convention": [
  169. "error",
  170. {
  171. "selector": "variable",
  172. "format": ["camelCase", "PascalCase"],
  173. "leadingUnderscore": "allow",
  174. "filter": {
  175. "regex": "^_$",
  176. "match": false
  177. }
  178. },
  179. {
  180. "selector": "variableLike",
  181. "format": ["camelCase"],
  182. "leadingUnderscore": "allow",
  183. "filter": {
  184. "regex": "^_$",
  185. "match": false
  186. }
  187. },
  188. {
  189. "selector": "memberLike",
  190. "modifiers": ["private"],
  191. "format": ["camelCase"],
  192. "leadingUnderscore": "allow"
  193. },
  194. {
  195. "selector": "memberLike",
  196. "modifiers": ["private", "readonly"],
  197. "format": ["camelCase", "PascalCase"],
  198. "leadingUnderscore": "allow"
  199. },
  200. {
  201. "selector": "memberLike",
  202. "modifiers": ["static", "readonly"],
  203. "format": ["camelCase", "PascalCase"]
  204. },
  205. {
  206. "selector": "interface",
  207. "format": ["PascalCase"],
  208. "custom": {
  209. "regex": "^I[A-Z]",
  210. "match": false
  211. }
  212. }
  213. ],
  214. "@typescript-eslint/no-duplicate-imports": "error",
  215. "@typescript-eslint/no-empty-function": "off",
  216. "@typescript-eslint/no-empty-interface": "error",
  217. "@typescript-eslint/no-explicit-any": "off",
  218. "@typescript-eslint/no-floating-promises": "error",
  219. "@typescript-eslint/no-inferrable-types": ["warn", { "ignoreParameters": true, "ignoreProperties": true }],
  220. "@typescript-eslint/no-misused-promises": ["error", { "checksVoidReturn": false }],
  221. "@typescript-eslint/no-namespace": "off",
  222. "@typescript-eslint/no-non-null-assertion": "off",
  223. "@typescript-eslint/no-parameter-properties": "off",
  224. "@typescript-eslint/no-unnecessary-condition": "off",
  225. "@typescript-eslint/no-unsafe-argument": "off",
  226. "@typescript-eslint/no-unsafe-assignment": "off",
  227. "@typescript-eslint/no-unsafe-call": "off",
  228. "@typescript-eslint/no-unsafe-member-access": "off",
  229. "@typescript-eslint/no-unsafe-return": "off",
  230. "@typescript-eslint/no-unused-expressions": ["warn", { "allowShortCircuit": true }],
  231. "@typescript-eslint/no-unused-vars": [
  232. "warn",
  233. {
  234. "args": "after-used",
  235. "argsIgnorePattern": "^_",
  236. "ignoreRestSiblings": true,
  237. "varsIgnorePattern": "^_$"
  238. }
  239. ],
  240. "@typescript-eslint/no-use-before-define": "off",
  241. "@typescript-eslint/prefer-nullish-coalescing": "off",
  242. "@typescript-eslint/prefer-optional-chain": "warn",
  243. "@typescript-eslint/restrict-template-expressions": [
  244. "error",
  245. { "allowAny": true, "allowBoolean": true, "allowNumber": true, "allowNullish": true }
  246. ],
  247. "@typescript-eslint/strict-boolean-expressions": [
  248. "warn",
  249. {
  250. "allowString": true,
  251. "allowNumber": true,
  252. "allowNullableObject": false,
  253. "allowNullableBoolean": true,
  254. "allowNullableNumber": true,
  255. "allowNullableString": true,
  256. "allowAny": false
  257. }
  258. ],
  259. "@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
  260. }
  261. }