.eslintrc.js 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  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. overrides: [
  14. {
  15. files: ['*.js', '*.jsx'],
  16. extends: ['jest-enzyme', 'plugin:react/recommended', 'plugin:import/recommended', 'plugin:import/errors', 'plugin:import/warnings'],
  17. parser: '@babel/eslint-parser',
  18. plugins: ['react', 'react-hooks', 'jest', 'import'],
  19. rules: {
  20. // 因为历史原因,现有项目基本全部是4个空格
  21. indent: ['error', 4, { 'SwitchCase': 1 }],
  22. 'react/display-name': 'off',
  23. 'react/jsx-indent': ['error', 4],
  24. 'react/jsx-indent-props': ['error', 4],
  25. 'react/prefer-stateless-function': ['warn'],
  26. 'react/no-find-dom-node': ['warn'],
  27. 'react/prop-types': 'off',
  28. 'react/prefer-stateless-function': 'off',
  29. 'operator-linebreak': ['warn', 'after', { 'overrides': { '?': 'before', ':': 'before' } }],
  30. 'import/no-unresolved': 'off'
  31. },
  32. globals: {
  33. "sinon": "readonly",
  34. },
  35. },
  36. {
  37. files: ['*.ts', '*.tsx'],
  38. extends: ['jest-enzyme', 'plugin:@typescript-eslint/recommended', 'plugin:import/typescript', 'plugin:react/recommended'],
  39. parser: '@typescript-eslint/parser',
  40. parserOptions: {
  41. project: ['./tsconfig.eslint.json'],
  42. },
  43. plugins: ['react', 'jest', 'react-hooks', 'import', '@typescript-eslint'],
  44. rules: {
  45. // 因为历史原因,现有项目基本全部是4个空格
  46. indent: 'off',
  47. '@typescript-eslint/indent': ['error', 4],
  48. 'react/display-name': 'off',
  49. 'react/jsx-indent': ['error', 4],
  50. 'react/jsx-indent-props': ['error', 4],
  51. 'react/prefer-stateless-function': ['warn'],
  52. 'react/no-find-dom-node': ['warn'],
  53. 'react/prop-types': 'off',
  54. 'react-hooks/rules-of-hooks': 'error',
  55. 'react-hooks/exhaustive-deps': 'warn',
  56. 'react/prefer-stateless-function': 'off',
  57. '@typescript-eslint/explicit-module-boundary-types': 'off',
  58. '@typescript-eslint/explicit-function-return-type': 'off',
  59. '@typescript-eslint/no-explicit-any': 'off',
  60. '@typescript-eslint/naming-convention': 'off',
  61. '@typescript-eslint/ban-ts-comment': 'off',
  62. '@typescript-eslint/no-var-requires': 'warn',
  63. '@typescript-eslint/no-inferrable-types': 'off',
  64. '@typescript-eslint/no-this-alias': 'off',
  65. 'import/no-unresolved': 'off'
  66. }
  67. },
  68. ],
  69. };