1
0

.eslintrc.js 3.5 KB

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