.eslintrc.yml 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182
  1. parser: '@typescript-eslint/parser'
  2. parserOptions:
  3. ecmaFeatures:
  4. jsx: true
  5. ecmaVersion: latest
  6. sourceType: module
  7. env:
  8. browser: true
  9. es6: true
  10. node: true
  11. jest: true
  12. plugins:
  13. - import
  14. - sonarjs
  15. extends:
  16. - eslint:recommended
  17. - plugin:sonarjs/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. 'sonarjs/cognitive-complexity': 0
  57. 'sonarjs/no-duplicate-string': 0
  58. 'sonarjs/no-big-function': 0
  59. 'sonarjs/no-identical-functions': 0
  60. 'sonarjs/no-small-switch': 0
  61. overrides:
  62. - files:
  63. - ./**/*.{ts,tsx}
  64. rules:
  65. 'no-unused-vars': [2, { varsIgnorePattern: '^_', argsIgnorePattern: '^_', ignoreRestSiblings: true }]
  66. - files:
  67. - ./**/*{.ts,.tsx}
  68. plugins:
  69. - '@typescript-eslint'
  70. parserOptions:
  71. project: ./tsconfig.json
  72. rules:
  73. 'no-undef': 0
  74. # TypeScript declare merge
  75. 'no-redeclare': 0
  76. 'no-useless-constructor': 0
  77. 'no-unused-vars': 0
  78. 'no-dupe-class-members': 0
  79. 'no-case-declarations': 0
  80. 'no-duplicate-imports': 0
  81. # TypeScript Interface and Type
  82. 'no-use-before-define': 0
  83. '@typescript-eslint/adjacent-overload-signatures': 2
  84. '@typescript-eslint/await-thenable': 2
  85. '@typescript-eslint/consistent-type-assertions': 2
  86. '@typescript-eslint/ban-types':
  87. [
  88. 'error',
  89. {
  90. 'types':
  91. {
  92. 'String': { 'message': 'Use string instead', 'fixWith': 'string' },
  93. 'Number': { 'message': 'Use number instead', 'fixWith': 'number' },
  94. 'Boolean': { 'message': 'Use boolean instead', 'fixWith': 'boolean' },
  95. 'Function': { 'message': 'Use explicit type instead' },
  96. },
  97. },
  98. ]
  99. '@typescript-eslint/explicit-member-accessibility':
  100. [
  101. 'error',
  102. {
  103. accessibility: 'explicit',
  104. overrides:
  105. {
  106. accessors: 'no-public',
  107. constructors: 'no-public',
  108. methods: 'no-public',
  109. properties: 'no-public',
  110. parameterProperties: 'explicit',
  111. },
  112. },
  113. ]
  114. '@typescript-eslint/method-signature-style': 2
  115. '@typescript-eslint/no-floating-promises': 2
  116. '@typescript-eslint/no-implied-eval': 2
  117. '@typescript-eslint/no-for-in-array': 2
  118. '@typescript-eslint/no-inferrable-types': 2
  119. '@typescript-eslint/no-invalid-void-type': 2
  120. '@typescript-eslint/no-misused-new': 2
  121. '@typescript-eslint/no-misused-promises': 2
  122. '@typescript-eslint/no-namespace': 2
  123. '@typescript-eslint/no-non-null-asserted-optional-chain': 2
  124. '@typescript-eslint/no-throw-literal': 2
  125. '@typescript-eslint/no-unnecessary-boolean-literal-compare': 2
  126. '@typescript-eslint/prefer-for-of': 2
  127. '@typescript-eslint/prefer-nullish-coalescing': 2
  128. '@typescript-eslint/switch-exhaustiveness-check': 2
  129. '@typescript-eslint/prefer-optional-chain': 2
  130. '@typescript-eslint/prefer-readonly': 2
  131. '@typescript-eslint/prefer-string-starts-ends-with': 0
  132. '@typescript-eslint/no-array-constructor': 2
  133. '@typescript-eslint/require-await': 2
  134. '@typescript-eslint/return-await': 2
  135. '@typescript-eslint/ban-ts-comment':
  136. [2, { 'ts-expect-error': false, 'ts-ignore': true, 'ts-nocheck': true, 'ts-check': false }]
  137. '@typescript-eslint/naming-convention':
  138. [
  139. 2,
  140. {
  141. selector: 'memberLike',
  142. format: ['camelCase', 'PascalCase'],
  143. modifiers: ['private'],
  144. leadingUnderscore: 'forbid',
  145. },
  146. ]
  147. '@typescript-eslint/no-unused-vars':
  148. [2, { varsIgnorePattern: '^_', argsIgnorePattern: '^_', ignoreRestSiblings: true }]
  149. '@typescript-eslint/member-ordering':
  150. [
  151. 2,
  152. {
  153. default:
  154. [
  155. 'public-static-field',
  156. 'protected-static-field',
  157. 'private-static-field',
  158. 'public-static-method',
  159. 'protected-static-method',
  160. 'private-static-method',
  161. 'public-instance-field',
  162. 'protected-instance-field',
  163. 'private-instance-field',
  164. 'public-constructor',
  165. 'protected-constructor',
  166. 'private-constructor',
  167. 'public-instance-method',
  168. 'protected-instance-method',
  169. 'private-instance-method',
  170. ],
  171. },
  172. ]