.eslintrc.js 4.5 KB

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