.eslintrc.yml 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167
  1. parser: '@typescript-eslint/parser'
  2. parserOptions:
  3. ecmaFeatures:
  4. jsx: true
  5. ecmaVersion: latest
  6. sourceType: module
  7. project: ./tsconfig.json
  8. env:
  9. browser: true
  10. es6: true
  11. node: true
  12. jest: true
  13. plugins:
  14. - import
  15. - '@typescript-eslint'
  16. extends:
  17. - eslint:recommended
  18. - plugin:prettier/recommended
  19. rules:
  20. # 0 = off, 1 = warn, 2 = error
  21. 'space-before-function-paren': 0
  22. 'no-useless-constructor': 0
  23. 'no-undef': 2
  24. 'no-console': [2, { allow: ['error', 'warn', 'info', 'assert'] }]
  25. 'comma-dangle': ['error', 'only-multiline']
  26. 'no-unused-vars': 0
  27. 'no-var': 2
  28. 'one-var-declaration-per-line': 2
  29. 'prefer-const': 2
  30. 'no-const-assign': 2
  31. 'no-duplicate-imports': 2
  32. 'no-use-before-define': [2, { 'functions': false, 'classes': false }]
  33. 'eqeqeq': [2, 'always', { 'null': 'ignore' }]
  34. 'no-case-declarations': 0
  35. 'no-restricted-syntax':
  36. [
  37. 2,
  38. {
  39. 'selector': 'BinaryExpression[operator=/(==|===|!=|!==)/][left.raw=true], BinaryExpression[operator=/(==|===|!=|!==)/][right.raw=true]',
  40. 'message': Don't compare for equality against boolean literals,
  41. },
  42. ]
  43. # https://github.com/benmosher/eslint-plugin-import/pull/334
  44. 'import/no-duplicates': 2
  45. 'import/first': 2
  46. 'import/newline-after-import': 2
  47. 'import/order':
  48. [
  49. 2,
  50. {
  51. 'newlines-between': 'always',
  52. 'alphabetize': { 'order': 'asc' },
  53. 'groups': ['builtin', 'external', 'internal', 'parent', 'sibling', 'index'],
  54. },
  55. ]
  56. overrides:
  57. - files:
  58. - ./**/*{.ts,.tsx}
  59. rules:
  60. 'no-unused-vars': [2, { varsIgnorePattern: '^_', argsIgnorePattern: '^_', ignoreRestSiblings: true }]
  61. 'no-undef': 0
  62. # TypeScript declare merge
  63. 'no-redeclare': 0
  64. 'no-useless-constructor': 0
  65. 'no-dupe-class-members': 0
  66. 'no-case-declarations': 0
  67. 'no-duplicate-imports': 0
  68. # TypeScript Interface and Type
  69. 'no-use-before-define': 0
  70. '@typescript-eslint/adjacent-overload-signatures': 2
  71. '@typescript-eslint/await-thenable': 2
  72. '@typescript-eslint/consistent-type-assertions': 2
  73. '@typescript-eslint/ban-types':
  74. [
  75. 'error',
  76. {
  77. 'types':
  78. {
  79. 'String': { 'message': 'Use string instead', 'fixWith': 'string' },
  80. 'Number': { 'message': 'Use number instead', 'fixWith': 'number' },
  81. 'Boolean': { 'message': 'Use boolean instead', 'fixWith': 'boolean' },
  82. 'Function': { 'message': 'Use explicit type instead' },
  83. },
  84. },
  85. ]
  86. '@typescript-eslint/explicit-member-accessibility':
  87. [
  88. 'error',
  89. {
  90. accessibility: 'explicit',
  91. overrides:
  92. {
  93. accessors: 'no-public',
  94. constructors: 'no-public',
  95. methods: 'no-public',
  96. properties: 'no-public',
  97. parameterProperties: 'explicit',
  98. },
  99. },
  100. ]
  101. '@typescript-eslint/method-signature-style': 2
  102. '@typescript-eslint/no-floating-promises': 2
  103. '@typescript-eslint/no-implied-eval': 2
  104. '@typescript-eslint/no-for-in-array': 2
  105. '@typescript-eslint/no-inferrable-types': 2
  106. '@typescript-eslint/no-invalid-void-type': 2
  107. '@typescript-eslint/no-misused-new': 2
  108. '@typescript-eslint/no-misused-promises': 2
  109. '@typescript-eslint/no-namespace': 2
  110. '@typescript-eslint/no-non-null-asserted-optional-chain': 2
  111. '@typescript-eslint/no-throw-literal': 2
  112. '@typescript-eslint/no-unnecessary-boolean-literal-compare': 2
  113. '@typescript-eslint/prefer-for-of': 2
  114. '@typescript-eslint/prefer-nullish-coalescing': 2
  115. '@typescript-eslint/switch-exhaustiveness-check': 2
  116. '@typescript-eslint/prefer-optional-chain': 2
  117. '@typescript-eslint/prefer-readonly': 2
  118. '@typescript-eslint/prefer-string-starts-ends-with': 0
  119. '@typescript-eslint/no-array-constructor': 2
  120. '@typescript-eslint/require-await': 2
  121. '@typescript-eslint/return-await': 2
  122. '@typescript-eslint/ban-ts-comment':
  123. [2, { 'ts-expect-error': false, 'ts-ignore': true, 'ts-nocheck': true, 'ts-check': false }]
  124. '@typescript-eslint/naming-convention':
  125. [
  126. 2,
  127. {
  128. selector: 'memberLike',
  129. format: ['camelCase', 'PascalCase'],
  130. modifiers: ['private'],
  131. leadingUnderscore: 'forbid',
  132. },
  133. ]
  134. '@typescript-eslint/no-unused-vars':
  135. [2, { varsIgnorePattern: '^_', argsIgnorePattern: '^_', ignoreRestSiblings: true }]
  136. '@typescript-eslint/member-ordering':
  137. [
  138. 2,
  139. {
  140. default:
  141. [
  142. 'public-static-field',
  143. 'protected-static-field',
  144. 'private-static-field',
  145. 'public-static-method',
  146. 'protected-static-method',
  147. 'private-static-method',
  148. 'public-instance-field',
  149. 'protected-instance-field',
  150. 'private-instance-field',
  151. 'public-constructor',
  152. 'protected-constructor',
  153. 'private-constructor',
  154. 'public-instance-method',
  155. 'protected-instance-method',
  156. 'private-instance-method',
  157. ],
  158. },
  159. ]