.eslintrc.js 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  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. 'max-len': 'off',
  47. 'react/forbid-foreign-prop-types': ['error', { "allowInPropTypes": true }]
  48. },
  49. globals: {
  50. "sinon": "readonly",
  51. },
  52. },
  53. {
  54. files: ['*.ts', '*.tsx'],
  55. excludedFiles: ['content/**'],
  56. extends: ['jest-enzyme', 'plugin:@typescript-eslint/recommended', 'plugin:import/typescript', 'plugin:react/recommended', 'plugin:jsx-a11y/recommended'],
  57. parser: '@typescript-eslint/parser',
  58. parserOptions: {
  59. project: ['./tsconfig.eslint.json'],
  60. },
  61. plugins: ['react', 'jest', 'react-hooks', 'import', '@typescript-eslint', 'semi-design'],
  62. rules: {
  63. // 因为历史原因,现有项目基本全部是4个空格
  64. indent: 'off',
  65. 'comma-spacing': ["error", {"before": false, "after": true}],
  66. 'no-multi-spaces': ["error", {ignoreEOLComments: true}],
  67. '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
  68. 'key-spacing': ["error", {"beforeColon": false, "afterColon": true}],
  69. '@typescript-eslint/indent': ['error', 4],
  70. 'react/display-name': 'off',
  71. 'react/jsx-indent': ['error', 4],
  72. 'react/jsx-indent-props': ['error', 4],
  73. 'react/no-find-dom-node': 'off',
  74. 'react/prop-types': 'off',
  75. "react/no-unknown-property": ['error', {
  76. ignore: [
  77. 'x-semi-prop',
  78. 'x-placement',
  79. 'x-type',
  80. 'x-label-pos',
  81. 'x-prompt-pos',
  82. 'x-field-id',
  83. 'x-extra-pos',
  84. 'x-open-type',
  85. 'x-panel-yearandmonth-open-type',
  86. 'x-insetinput',
  87. 'x-preset-position',
  88. 'x-form-id'
  89. ]}],
  90. 'react-hooks/rules-of-hooks': 'error',
  91. 'react-hooks/exhaustive-deps': 'warn',
  92. 'react/prefer-stateless-function': 'off',
  93. '@typescript-eslint/explicit-module-boundary-types': 'off',
  94. '@typescript-eslint/explicit-function-return-type': 'off',
  95. '@typescript-eslint/no-empty-interface': 'off',
  96. '@typescript-eslint/no-explicit-any': 'off',
  97. '@typescript-eslint/naming-convention': 'off',
  98. '@typescript-eslint/ban-ts-comment': 'off',
  99. '@typescript-eslint/no-var-requires': 'warn',
  100. '@typescript-eslint/no-inferrable-types': 'off',
  101. '@typescript-eslint/no-this-alias': 'off',
  102. '@typescript-eslint/no-empty-function': 'off',
  103. // In scenarios where specific rest props need to be passed, some keys may be taken out first, so set 'no-unused-vars' to off
  104. '@typescript-eslint/no-unused-vars': 'off',
  105. 'import/no-unresolved': 'off',
  106. 'max-len': 'off',
  107. 'semi': ['error', 'always'],
  108. 'keyword-spacing': ["error", {"before": true, "after": true}],
  109. 'jsx-a11y/click-events-have-key-events': ['warn'],
  110. 'jsx-a11y/no-noninteractive-element-interactions': ['warn'],
  111. 'jsx-a11y/no-autofocus': ['warn'],
  112. 'jsx-a11y/no-static-element-interactions': ['warn'],
  113. 'jsx-a11y/alt-text': ["warn"],
  114. 'jsx-a11y/mouse-events-have-key-events': ["warn"],
  115. 'jsx-a11y/html-has-lang': ['warn'],
  116. 'object-curly-spacing': ['error', 'always'],
  117. 'prefer-const': 'off',
  118. 'semi-design/no-import': 'error',
  119. 'space-before-blocks': ['error', 'always'],
  120. "@typescript-eslint/type-annotation-spacing": ['error', {"after": true}],
  121. "@typescript-eslint/member-delimiter-style": [
  122. "error",
  123. {
  124. "multiline": {
  125. "delimiter": "semi",
  126. "requireLast": false
  127. },
  128. "singleline": {
  129. "delimiter": "semi",
  130. "requireLast": false
  131. }
  132. }
  133. ],
  134. 'react/forbid-foreign-prop-types': ['error', { "allowInPropTypes": true }]
  135. }
  136. },
  137. ],
  138. };