.eslintrc.js 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  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. 'react/display-name': 'off',
  26. 'react/jsx-indent': ['error', 4],
  27. 'react/jsx-indent-props': ['error', 4],
  28. 'react/prefer-stateless-function': ['warn'],
  29. 'react/no-find-dom-node': ['warn'],
  30. 'react/prop-types': 'off',
  31. 'react/prefer-stateless-function': 'off',
  32. 'operator-linebreak': ['warn', 'after', { 'overrides': { '?': 'before', ':': 'before' } }],
  33. 'import/no-unresolved': 'off',
  34. 'semi': ['error', 'always'],
  35. 'keyword-spacing': ["error", { "before": true, "after": true }],
  36. 'jsx-a11y/click-events-have-key-events': ['warn'],
  37. 'jsx-a11y/no-noninteractive-element-interactions': ['warn'],
  38. 'jsx-a11y/no-autofocus': ['warn'],
  39. 'object-curly-spacing': ['error', 'always'],
  40. },
  41. globals: {
  42. "sinon": "readonly",
  43. },
  44. },
  45. {
  46. files: ['*.ts', '*.tsx'],
  47. excludedFiles: ['content/**'],
  48. extends: ['jest-enzyme', 'plugin:@typescript-eslint/recommended', 'plugin:import/typescript', 'plugin:react/recommended', 'plugin:jsx-a11y/recommended'],
  49. parser: '@typescript-eslint/parser',
  50. parserOptions: {
  51. project: ['./tsconfig.eslint.json'],
  52. },
  53. plugins: ['react', 'jest', 'react-hooks', 'import', '@typescript-eslint', 'semi-design'],
  54. rules: {
  55. // 因为历史原因,现有项目基本全部是4个空格
  56. indent: 'off',
  57. 'comma-spacing': ["error", { "before": false, "after": true }],
  58. 'no-multi-spaces': ["error", { ignoreEOLComments: true }],
  59. '@typescript-eslint/indent': ['error', 4],
  60. 'react/display-name': 'off',
  61. 'react/jsx-indent': ['error', 4],
  62. 'react/jsx-indent-props': ['error', 4],
  63. 'react/prefer-stateless-function': ['warn'],
  64. 'react/no-find-dom-node': ['warn'],
  65. 'react/prop-types': 'off',
  66. 'react-hooks/rules-of-hooks': 'error',
  67. 'react-hooks/exhaustive-deps': 'warn',
  68. 'react/prefer-stateless-function': 'off',
  69. '@typescript-eslint/explicit-module-boundary-types': 'off',
  70. '@typescript-eslint/explicit-function-return-type': 'off',
  71. '@typescript-eslint/no-explicit-any': 'off',
  72. '@typescript-eslint/naming-convention': 'off',
  73. '@typescript-eslint/ban-ts-comment': 'off',
  74. '@typescript-eslint/no-var-requires': 'warn',
  75. '@typescript-eslint/no-inferrable-types': 'off',
  76. '@typescript-eslint/no-this-alias': 'off',
  77. // In scenarios where specific rest props need to be passed, some keys may be taken out first, so set 'no-unused-vars' to off
  78. '@typescript-eslint/no-unused-vars': 'off',
  79. 'import/no-unresolved': 'off',
  80. 'semi': ['error', 'always'],
  81. 'keyword-spacing': ["error", { "before": true, "after": true }],
  82. 'jsx-a11y/click-events-have-key-events': ['warn'],
  83. 'jsx-a11y/no-noninteractive-element-interactions': ['warn'],
  84. 'jsx-a11y/no-autofocus': ['warn'],
  85. 'object-curly-spacing': ['error', 'always'],
  86. 'semi-design/no-import': 'error'
  87. }
  88. },
  89. ],
  90. };