Nie możesz wybrać więcej, niż 25 tematów Tematy muszą się zaczynać od litery lub cyfry, mogą zawierać myślniki ('-') i mogą mieć do 35 znaków.

254 wiersze
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. "prettier/@typescript-eslint"
  15. ],
  16. "parser": "@typescript-eslint/parser",
  17. "parserOptions": {
  18. "ecmaVersion": 2019,
  19. "sourceType": "module",
  20. "ecmaFeatures": {
  21. "impliedStrict": true
  22. },
  23. "project": "tsconfig.json"
  24. },
  25. "plugins": ["import", "@typescript-eslint"],
  26. "reportUnusedDisableDirectives": true,
  27. "root": true,
  28. "rules": {
  29. "arrow-parens": ["off"],
  30. "brace-style": ["off", "stroustrup"],
  31. "consistent-return": "error",
  32. "curly": ["error", "multi-line", "consistent"],
  33. "eol-last": "error",
  34. "linebreak-style": ["error", "unix"],
  35. "new-parens": "error",
  36. "no-console": "off",
  37. "no-constant-condition": ["warn", { "checkLoops": false }],
  38. "no-caller": "error",
  39. "no-debugger": "warn",
  40. "no-dupe-class-members": "off",
  41. "no-duplicate-imports": "error",
  42. "no-else-return": "warn",
  43. "no-empty": ["warn", { "allowEmptyCatch": true }],
  44. "no-eval": "error",
  45. "no-ex-assign": "warn",
  46. "no-extend-native": "error",
  47. "no-extra-bind": "error",
  48. "no-floating-decimal": "error",
  49. "no-implicit-coercion": "error",
  50. "no-implied-eval": "error",
  51. // Turn off until fix for: https://github.com/typescript-eslint/typescript-eslint/issues/239
  52. "no-inner-declarations": "off",
  53. "no-lone-blocks": "error",
  54. "no-lonely-if": "error",
  55. "no-loop-func": "error",
  56. "no-multi-spaces": "error",
  57. "no-return-assign": "error",
  58. "no-return-await": "warn",
  59. "no-self-compare": "error",
  60. "no-sequences": "error",
  61. "no-template-curly-in-string": "warn",
  62. "no-throw-literal": "error",
  63. "no-unmodified-loop-condition": "warn",
  64. "no-unneeded-ternary": "error",
  65. "no-use-before-define": "off",
  66. "no-useless-call": "error",
  67. "no-useless-catch": "error",
  68. "no-useless-computed-key": "error",
  69. "no-useless-concat": "error",
  70. "no-useless-rename": "error",
  71. "no-useless-return": "error",
  72. "no-var": "error",
  73. "no-with": "error",
  74. "object-shorthand": ["error", "never"],
  75. "one-var": ["error", "never"],
  76. "prefer-arrow-callback": "error",
  77. "prefer-const": "error",
  78. "prefer-numeric-literals": "error",
  79. "prefer-object-spread": "error",
  80. "prefer-rest-params": "error",
  81. "prefer-spread": "error",
  82. "prefer-template": "error",
  83. "quotes": ["error", "single", { "avoidEscape": true }],
  84. // Turn off until fix for: https://github.com/eslint/eslint/issues/11899
  85. "require-atomic-updates": "off",
  86. "semi": ["error", "always"],
  87. "semi-style": ["error", "last"],
  88. "sort-imports": [
  89. "error",
  90. {
  91. "ignoreCase": true,
  92. "ignoreDeclarationSort": true,
  93. "ignoreMemberSort": false,
  94. "memberSyntaxSortOrder": ["none", "all", "multiple", "single"]
  95. }
  96. ],
  97. "yoda": "error",
  98. "import/export": "off",
  99. "import/extensions": ["error", "never"],
  100. "import/named": "off",
  101. "import/namespace": "off",
  102. "import/newline-after-import": "warn",
  103. "import/no-cycle": "off",
  104. "import/no-dynamic-require": "error",
  105. "import/no-default-export": "error",
  106. "import/no-duplicates": "error",
  107. "import/no-self-import": "error",
  108. "import/no-unresolved": ["warn", { "ignore": ["vscode"] }],
  109. "import/order": [
  110. "warn",
  111. {
  112. "groups": ["builtin", "external", "internal", ["index", "sibling", "parent"]],
  113. "newlines-between": "never"
  114. }
  115. ],
  116. "@typescript-eslint/ban-types": [
  117. "error",
  118. {
  119. "extendDefaults": false,
  120. "types": {
  121. "String": {
  122. "message": "Use string instead",
  123. "fixWith": "string"
  124. },
  125. "Boolean": {
  126. "message": "Use boolean instead",
  127. "fixWith": "boolean"
  128. },
  129. "Number": {
  130. "message": "Use number instead",
  131. "fixWith": "number"
  132. },
  133. "Symbol": {
  134. "message": "Use symbol instead",
  135. "fixWith": "symbol"
  136. },
  137. // "Function": {
  138. // "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."
  139. // },
  140. "Object": {
  141. "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."
  142. },
  143. "{}": {
  144. "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.",
  145. "fixWith": "object"
  146. }
  147. // "object": {
  148. // "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."
  149. // }
  150. }
  151. }
  152. ],
  153. "@typescript-eslint/consistent-type-assertions": [
  154. "error",
  155. {
  156. "assertionStyle": "as",
  157. "objectLiteralTypeAssertions": "allow-as-parameter"
  158. }
  159. ],
  160. "@typescript-eslint/explicit-function-return-type": "off",
  161. "@typescript-eslint/explicit-member-accessibility": "off",
  162. "@typescript-eslint/explicit-module-boundary-types": "off", // TODO@eamodio revisit
  163. "@typescript-eslint/naming-convention": [
  164. "error",
  165. {
  166. "selector": "variable",
  167. "format": ["camelCase", "PascalCase"],
  168. "leadingUnderscore": "allow",
  169. "filter": {
  170. "regex": "^_$",
  171. "match": false
  172. }
  173. },
  174. {
  175. "selector": "variableLike",
  176. "format": ["camelCase"],
  177. "leadingUnderscore": "allow",
  178. "filter": {
  179. "regex": "^_$",
  180. "match": false
  181. }
  182. },
  183. {
  184. "selector": "memberLike",
  185. "modifiers": ["private"],
  186. "format": ["camelCase"],
  187. "leadingUnderscore": "allow"
  188. },
  189. {
  190. "selector": "memberLike",
  191. "modifiers": ["private", "readonly"],
  192. "format": ["camelCase", "PascalCase"],
  193. "leadingUnderscore": "allow"
  194. },
  195. {
  196. "selector": "memberLike",
  197. "modifiers": ["static", "readonly"],
  198. "format": ["camelCase", "PascalCase"]
  199. },
  200. {
  201. "selector": "interface",
  202. "format": ["PascalCase"],
  203. "custom": {
  204. "regex": "^I[A-Z]",
  205. "match": false
  206. }
  207. }
  208. ],
  209. "@typescript-eslint/no-empty-function": ["warn", { "allow": ["constructors"] }],
  210. "@typescript-eslint/no-empty-interface": "error",
  211. "@typescript-eslint/no-explicit-any": "off",
  212. "@typescript-eslint/no-floating-promises": "error",
  213. "@typescript-eslint/no-inferrable-types": ["warn", { "ignoreParameters": true, "ignoreProperties": true }],
  214. "@typescript-eslint/no-misused-promises": ["error", { "checksVoidReturn": false }],
  215. "@typescript-eslint/no-namespace": "off",
  216. "@typescript-eslint/no-non-null-assertion": "off",
  217. "@typescript-eslint/no-parameter-properties": "off",
  218. "@typescript-eslint/no-unnecessary-condition": "off",
  219. "@typescript-eslint/no-unsafe-assignment": "off", // TODO@eamodio revisit
  220. "@typescript-eslint/no-unsafe-call": "off", // TODO@eamodio revisit
  221. "@typescript-eslint/no-unsafe-member-access": "off", // TODO@eamodio revisit
  222. "@typescript-eslint/no-unsafe-return": "off", // TODO@eamodio revisit
  223. "@typescript-eslint/no-unused-expressions": ["warn", { "allowShortCircuit": true }],
  224. "@typescript-eslint/no-unused-vars": [
  225. "warn",
  226. {
  227. "args": "after-used",
  228. "argsIgnorePattern": "^_",
  229. "ignoreRestSiblings": true,
  230. "varsIgnorePattern": "^_$"
  231. }
  232. ],
  233. "@typescript-eslint/no-use-before-define": "off",
  234. "@typescript-eslint/prefer-nullish-coalescing": "off",
  235. "@typescript-eslint/prefer-optional-chain": "warn",
  236. "@typescript-eslint/restrict-template-expressions": [
  237. "error",
  238. { "allowAny": true, "allowBoolean": true, "allowNumber": true, "allowNullish": true }
  239. ],
  240. "@typescript-eslint/strict-boolean-expressions": [
  241. "warn",
  242. {
  243. "allowString": true,
  244. "allowNumber": true,
  245. "allowNullableObject": false,
  246. "allowNullableBoolean": true,
  247. "allowNullableNumber": true,
  248. "allowNullableString": true,
  249. "allowAny": false
  250. }
  251. ],
  252. "@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
  253. }
  254. }