25개 이상의 토픽을 선택하실 수 없습니다. Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

326 lines
10 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": "off",
  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-constant-binary-expression": "error",
  36. "no-caller": "error",
  37. "no-debugger": "off",
  38. "no-dupe-class-members": "off",
  39. "no-else-return": "warn",
  40. "no-empty": ["warn", { "allowEmptyCatch": true }],
  41. "no-eval": "error",
  42. "no-ex-assign": "warn",
  43. "no-extend-native": "error",
  44. "no-extra-bind": "error",
  45. "no-floating-decimal": "error",
  46. "no-implicit-coercion": "error",
  47. "no-implied-eval": "error",
  48. // Turn off until fix for: https://github.com/typescript-eslint/typescript-eslint/issues/239
  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. }
  104. ],
  105. "no-return-assign": "error",
  106. "no-return-await": "warn",
  107. "no-self-compare": "error",
  108. "no-sequences": "error",
  109. "no-template-curly-in-string": "warn",
  110. "no-throw-literal": "error",
  111. "no-unmodified-loop-condition": "warn",
  112. "no-unneeded-ternary": "error",
  113. "no-use-before-define": "off",
  114. "no-useless-call": "error",
  115. "no-useless-catch": "error",
  116. "no-useless-computed-key": "error",
  117. "no-useless-concat": "error",
  118. "no-useless-rename": "error",
  119. "no-useless-return": "error",
  120. "no-var": "error",
  121. "no-with": "error",
  122. "object-shorthand": ["error", "never"],
  123. "one-var": ["error", "never"],
  124. "prefer-arrow-callback": "error",
  125. "prefer-const": [
  126. "error",
  127. {
  128. "destructuring": "all",
  129. "ignoreReadBeforeAssign": false
  130. }
  131. ],
  132. "prefer-numeric-literals": "error",
  133. "prefer-object-spread": "error",
  134. "prefer-rest-params": "error",
  135. "prefer-spread": "error",
  136. "prefer-template": "error",
  137. "quotes": ["error", "single", { "avoidEscape": true, "allowTemplateLiterals": true }],
  138. // Turn off until fix for: https://github.com/eslint/eslint/issues/11899
  139. "require-atomic-updates": "off",
  140. "semi": ["error", "always"],
  141. "semi-style": ["error", "last"],
  142. "sort-imports": [
  143. "error",
  144. {
  145. "ignoreCase": true,
  146. "ignoreDeclarationSort": true,
  147. "ignoreMemberSort": false,
  148. "memberSyntaxSortOrder": ["none", "all", "multiple", "single"]
  149. }
  150. ],
  151. "yoda": "error",
  152. "import/export": "off",
  153. "import/extensions": ["error", "never"],
  154. "import/named": "off",
  155. "import/namespace": "off",
  156. "import/newline-after-import": "warn",
  157. "import/no-cycle": "off",
  158. "import/no-default-export": "error",
  159. "import/no-duplicates": "error",
  160. "import/no-dynamic-require": "error",
  161. "import/no-self-import": "error",
  162. "import/no-unresolved": ["warn", { "ignore": ["vscode", "@env"] }],
  163. "import/order": [
  164. "warn",
  165. {
  166. "alphabetize": { "order": "asc", "caseInsensitive": true },
  167. "groups": ["builtin", "external", "internal", ["parent", "sibling", "index"]],
  168. // "groups": ["builtin", "external", "internal", ["index", "sibling", "parent"]],
  169. "newlines-between": "never"
  170. }
  171. ],
  172. "@typescript-eslint/ban-types": [
  173. "error",
  174. {
  175. "extendDefaults": false,
  176. "types": {
  177. "String": {
  178. "message": "Use string instead",
  179. "fixWith": "string"
  180. },
  181. "Boolean": {
  182. "message": "Use boolean instead",
  183. "fixWith": "boolean"
  184. },
  185. "Number": {
  186. "message": "Use number instead",
  187. "fixWith": "number"
  188. },
  189. "Symbol": {
  190. "message": "Use symbol instead",
  191. "fixWith": "symbol"
  192. },
  193. // "Function": {
  194. // "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."
  195. // },
  196. "Object": {
  197. "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."
  198. },
  199. "{}": {
  200. "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.",
  201. "fixWith": "object"
  202. }
  203. // "object": {
  204. // "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."
  205. // }
  206. }
  207. }
  208. ],
  209. "@typescript-eslint/consistent-type-assertions": [
  210. "error",
  211. {
  212. "assertionStyle": "as",
  213. "objectLiteralTypeAssertions": "allow-as-parameter"
  214. }
  215. ],
  216. "@typescript-eslint/consistent-type-imports": ["error", { "disallowTypeAnnotations": false }],
  217. "@typescript-eslint/explicit-function-return-type": "off",
  218. "@typescript-eslint/explicit-member-accessibility": "off",
  219. "@typescript-eslint/explicit-module-boundary-types": "off", // TODO@eamodio revisit
  220. "@typescript-eslint/naming-convention": [
  221. "error",
  222. {
  223. "selector": "variable",
  224. "format": ["camelCase", "PascalCase"],
  225. "leadingUnderscore": "allow",
  226. "filter": {
  227. "regex": "^_$",
  228. "match": false
  229. }
  230. },
  231. {
  232. "selector": "variableLike",
  233. "format": ["camelCase"],
  234. "leadingUnderscore": "allow",
  235. "filter": {
  236. "regex": "^_$",
  237. "match": false
  238. }
  239. },
  240. {
  241. "selector": "memberLike",
  242. "modifiers": ["private"],
  243. "format": ["camelCase"],
  244. "leadingUnderscore": "allow"
  245. },
  246. {
  247. "selector": "memberLike",
  248. "modifiers": ["private", "readonly"],
  249. "format": ["camelCase", "PascalCase"],
  250. "leadingUnderscore": "allow"
  251. },
  252. {
  253. "selector": "memberLike",
  254. "modifiers": ["static", "readonly"],
  255. "format": ["camelCase", "PascalCase"]
  256. },
  257. {
  258. "selector": "interface",
  259. "format": ["PascalCase"],
  260. "custom": {
  261. "regex": "^I[A-Z]",
  262. "match": false
  263. }
  264. }
  265. ],
  266. "@typescript-eslint/no-empty-function": "off",
  267. "@typescript-eslint/no-empty-interface": "error",
  268. "@typescript-eslint/no-explicit-any": "off",
  269. "@typescript-eslint/no-extraneous-class": "error",
  270. "@typescript-eslint/no-floating-promises": "error",
  271. "@typescript-eslint/no-inferrable-types": ["warn", { "ignoreParameters": true, "ignoreProperties": true }],
  272. "@typescript-eslint/no-meaningless-void-operator": "error",
  273. "@typescript-eslint/no-misused-promises": ["error", { "checksVoidReturn": false }],
  274. "@typescript-eslint/no-namespace": "off", // TODO: Should aim to enable this
  275. "@typescript-eslint/no-non-null-assertion": "off",
  276. "@typescript-eslint/no-non-null-asserted-nullish-coalescing": "error",
  277. "@typescript-eslint/no-throw-literal": "error",
  278. // "@typescript-eslint/no-unnecessary-condition": ["error", { "allowConstantLoopConditions": true }],
  279. "@typescript-eslint/no-unsafe-argument": "off",
  280. "@typescript-eslint/no-unsafe-assignment": "off",
  281. "@typescript-eslint/no-unsafe-call": "off",
  282. "@typescript-eslint/no-unsafe-member-access": "off",
  283. "@typescript-eslint/no-unsafe-return": "error",
  284. "@typescript-eslint/no-unused-expressions": ["warn", { "allowShortCircuit": true }],
  285. "@typescript-eslint/no-unused-vars": [
  286. "warn",
  287. {
  288. "args": "after-used",
  289. "argsIgnorePattern": "^_",
  290. "ignoreRestSiblings": true,
  291. "varsIgnorePattern": "^_$"
  292. }
  293. ],
  294. "@typescript-eslint/non-nullable-type-assertion-style": "error",
  295. "@typescript-eslint/prefer-for-of": "warn",
  296. "@typescript-eslint/prefer-includes": "warn",
  297. "@typescript-eslint/prefer-literal-enum-member": ["warn", { "allowBitwiseExpressions": true }],
  298. "@typescript-eslint/prefer-nullish-coalescing": "off", // warn
  299. "@typescript-eslint/prefer-optional-chain": "warn",
  300. "@typescript-eslint/prefer-reduce-type-parameter": "warn",
  301. "@typescript-eslint/restrict-template-expressions": [
  302. "error",
  303. { "allowAny": true, "allowBoolean": true, "allowNumber": true, "allowNullish": true }
  304. ],
  305. "@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
  306. },
  307. "settings": {
  308. "import/parsers": {
  309. "@typescript-eslint/parser": [".ts", ".tsx"]
  310. },
  311. "import/resolver": {
  312. "typescript": {
  313. "alwaysTryTypes": true // always try to resolve types under `<root>@types` directory even it doesn't contain any source code, like `@types/unist`
  314. }
  315. }
  316. },
  317. "ignorePatterns": ["dist/*", "out/*", "**/@types/*", "emojis.json", "tsconfig*.tsbuildinfo", "webpack.config*.js"],
  318. "overrides": [
  319. {
  320. "files": ["src/env/node/**/*"],
  321. "rules": {
  322. "no-restricted-imports": "off"
  323. }
  324. }
  325. ]
  326. }