1
0

.eslintrc.js 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  1. /* eslint-disable */
  2. module.exports = {
  3. env: {
  4. 'jest/globals': true,
  5. 'browser': true,
  6. 'node': true
  7. },
  8. settings: {
  9. react: {
  10. "version": "detect"
  11. }
  12. },
  13. extends: ["plugin:markdown/recommended"],
  14. overrides: [
  15. {
  16. files: ['*.js', '*.jsx'],
  17. extends: ['jest-enzyme', 'plugin:react/recommended', 'plugin:import/recommended', 'plugin:import/errors', 'plugin:import/warnings', 'plugin:jsx-a11y/recommended'],
  18. parser: '@babel/eslint-parser',
  19. plugins: ['react', 'react-hooks', 'jest', 'import'],
  20. rules: {
  21. // 因为历史原因,现有项目基本全部是4个空格
  22. indent: ['error', 4, {'SwitchCase': 1}],
  23. 'comma-spacing': ["error", {"before": false, "after": true}],
  24. 'no-multi-spaces': ["error", {ignoreEOLComments: true}],
  25. 'no-unused-vars': 'off', // We need to consider many scenarios of deconstruction and rest, this rule is not reasonable in component library scenarios, so turn it off globally
  26. 'react/display-name': 'off',
  27. 'key-spacing': ["error", {"beforeColon": false}],
  28. 'react/jsx-indent': ['error', 4],
  29. 'react/jsx-indent-props': ['error', 4],
  30. 'react/no-find-dom-node': 'off',
  31. 'react/prop-types': 'off',
  32. 'react/prefer-stateless-function': 'off',
  33. 'jsx-a11y/alt-text': ["warn"],
  34. 'operator-linebreak': ['warn', 'after', {'overrides': {'?': 'before', ':': 'before'}}],
  35. 'import/no-unresolved': 'off',
  36. 'semi': ['error', 'always'],
  37. 'keyword-spacing': ["error", {"before": true, "after": true}],
  38. 'jsx-a11y/click-events-have-key-events': ['warn'],
  39. 'jsx-a11y/no-noninteractive-element-interactions': ['warn'],
  40. 'jsx-a11y/no-autofocus': ['warn'],
  41. 'jsx-a11y/no-static-element-interactions': ['warn'],
  42. 'jsx-a11y/html-has-lang': ['warn'],
  43. 'jsx-a11y/mouse-events-have-key-events': ['warn'],
  44. 'object-curly-spacing': ['error', 'always'],
  45. 'space-before-blocks': ['error', 'always'],
  46. "space-infix-ops": "error",
  47. 'max-len': 'off',
  48. 'react/forbid-foreign-prop-types': ['error', { "allowInPropTypes": true }]
  49. },
  50. globals: {
  51. "sinon": "readonly",
  52. },
  53. },
  54. {
  55. files: ['*.ts', '*.tsx'],
  56. excludedFiles: ['content/**'],
  57. extends: ['jest-enzyme', 'plugin:@typescript-eslint/recommended', 'plugin:import/typescript', 'plugin:react/recommended', 'plugin:jsx-a11y/recommended'],
  58. parser: '@typescript-eslint/parser',
  59. parserOptions: {
  60. project: ['./tsconfig.eslint.json'],
  61. },
  62. plugins: ['react', 'jest', 'react-hooks', 'import', '@typescript-eslint', 'semi-design'],
  63. rules: {
  64. // 因为历史原因,现有项目基本全部是4个空格
  65. "arrow-spacing": ["error", { "before": true, "after": true }],
  66. indent: 'off',
  67. 'comma-spacing': ["error", {"before": false, "after": true}],
  68. 'no-multi-spaces': ["error", {ignoreEOLComments: true}],
  69. 'no-unused-vars': 'off', // We need to consider many scenarios of deconstruction and rest, this rule is not reasonable in component library scenarios, so turn it off globally
  70. 'key-spacing': ["error", {"beforeColon": false, "afterColon": true}],
  71. '@typescript-eslint/indent': ['error', 4],
  72. 'react/display-name': 'off',
  73. 'react/jsx-indent': ['error', 4],
  74. 'react/jsx-indent-props': ['error', 4],
  75. 'react/no-find-dom-node': 'off',
  76. 'react/prop-types': 'off',
  77. "react/no-unknown-property": ['error', {
  78. ignore: [
  79. 'x-semi-prop',
  80. 'x-placement',
  81. 'x-type',
  82. 'x-label-pos',
  83. 'x-prompt-pos',
  84. 'x-field-id',
  85. 'x-extra-pos',
  86. 'x-open-type',
  87. 'x-panel-yearandmonth-open-type',
  88. 'x-insetinput',
  89. 'x-preset-position',
  90. 'x-form-id'
  91. ]}],
  92. 'react-hooks/rules-of-hooks': 'error',
  93. 'react-hooks/exhaustive-deps': 'warn',
  94. 'react/prefer-stateless-function': 'off',
  95. '@typescript-eslint/explicit-module-boundary-types': 'off',
  96. '@typescript-eslint/explicit-function-return-type': 'off',
  97. '@typescript-eslint/no-empty-interface': 'off',
  98. '@typescript-eslint/no-explicit-any': 'off',
  99. '@typescript-eslint/naming-convention': 'off',
  100. '@typescript-eslint/ban-ts-comment': 'off',
  101. '@typescript-eslint/no-var-requires': 'warn',
  102. '@typescript-eslint/no-inferrable-types': 'off',
  103. '@typescript-eslint/no-this-alias': 'off',
  104. '@typescript-eslint/no-empty-function': 'off',
  105. // In scenarios where specific rest props need to be passed, some keys may be taken out first, so set 'no-unused-vars' to off
  106. '@typescript-eslint/no-unused-vars': 'off',
  107. 'import/no-unresolved': 'off',
  108. 'max-len': 'off',
  109. 'semi': ['error', 'always'],
  110. 'keyword-spacing': ["error", {"before": true, "after": true}],
  111. 'jsx-a11y/click-events-have-key-events': ['warn'],
  112. 'jsx-a11y/no-noninteractive-element-interactions': ['warn'],
  113. 'jsx-a11y/no-autofocus': ['warn'],
  114. 'jsx-a11y/no-static-element-interactions': ['warn'],
  115. 'jsx-a11y/alt-text': ["warn"],
  116. 'jsx-a11y/mouse-events-have-key-events': ["warn"],
  117. 'jsx-a11y/html-has-lang': ['warn'],
  118. 'object-curly-spacing': ['error', 'always'],
  119. 'prefer-const': 'off',
  120. 'semi-design/no-import': 'error',
  121. "space-infix-ops": ["error", { "int32Hint": false }],
  122. 'space-before-blocks': ['error', 'always'],
  123. "space-infix-ops": "error",
  124. '@typescript-eslint/prefer-as-const': 'off',
  125. '@typescript-eslint/no-namespace': 'off',
  126. "@typescript-eslint/type-annotation-spacing": ['error', {"after": true}],
  127. "@typescript-eslint/member-delimiter-style": [
  128. "error",
  129. {
  130. "multiline": {
  131. "delimiter": "semi",
  132. "requireLast": false
  133. },
  134. "singleline": {
  135. "delimiter": "semi",
  136. "requireLast": false
  137. }
  138. }
  139. ],
  140. 'react/forbid-foreign-prop-types': ['error', { "allowInPropTypes": true }]
  141. }
  142. },
  143. ],
  144. };