.eslintrc.js 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. module.exports = {
  2. parser: '@typescript-eslint/parser', // Specifies the ESLint parser
  3. parserOptions: {
  4. ecmaVersion: 2020, // Allows for the parsing of modern ECMAScript features
  5. sourceType: 'module', // Allows for the use of imports
  6. ecmaFeatures: {
  7. impliedStrict: true, // 开启全局严格模式
  8. jsx: true // Allows for the parsing of JSX
  9. }
  10. },
  11. settings: {
  12. react: {
  13. version: 'detect' // Tells eslint-plugin-react to automatically detect the version of React to use
  14. }
  15. },
  16. extends: [
  17. 'react-app', // default from cra?
  18. 'plugin:react/recommended', // Uses the recommended rules from @eslint-plugin-react
  19. 'plugin:@typescript-eslint/recommended', // Uses the recommended rules from @typescript-eslint/eslint-plugin
  20. 'plugin:react-hooks/recommended', // Uses the recommended rules from react-hooks
  21. 'prettier', // Uses eslint-config-prettier to disable ESLint rules from @typescript-eslint/eslint-plugin that would conflict with prettier
  22. 'plugin:prettier/recommended' // Enables eslint-plugin-prettier and eslint-config-prettier. This will display prettier errors as ESLint errors. Make sure this is always the last configuration in the extends array.
  23. ],
  24. rules: {
  25. 'react/prop-types': 0,
  26. 'func-style': ['error', 'expression', { allowArrowFunctions: true }] //强制要求箭头函数函数表达式而不是函数式声明
  27. // "react-hooks/exhaustive-deps": [
  28. // "warn", {
  29. // "additionalHooks": "useRecoilCallback"
  30. // }
  31. // ]
  32. //https://github.com/typescript-eslint/typescript-eslint/blob/ca41dcf6c0fbfc19975b18ffb5b44c0cbe8adb06/packages/eslint-plugin/ROADMAP.md
  33. // Place to specify ESLint rules. Can be used to overwrite rules specified from the extended configs
  34. // e.g. "@typescript-eslint/explicit-function-return-type": "off",
  35. }
  36. }
  37. // source: https://www.robertcooper.me/using-eslint-and-prettier-in-a-typescript-project