You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

58 lines
2.1 KiB

10 months ago
  1. module.exports = {
  2. extends: [
  3. 'eslint:all',
  4. 'react-app', // react帮配置好了一些语法,譬如箭头函数
  5. 'airbnb',
  6. 'plugin:prettier/recommended' // prettier配置
  7. ],
  8. rules: {
  9. 'import/no-extraneous-dependencies': 0,
  10. 'import/extensions': 'off',
  11. 'import/no-unresolved': 0,
  12. 'default-param-last': 0,
  13. 'react/jsx-filename-extension': [1, { extensions: ['.js', '.jsx', 'tsx'] }], // 关闭airbnb对于jsx必须写在jsx文件中的设置
  14. 'react/prop-types': 'off', // 关闭airbnb对于必须添加prop-types的校验
  15. 'react/destructuring-assignment': [
  16. 1,
  17. 'always',
  18. {
  19. ignoreClassFields: false
  20. }
  21. ],
  22. 'react/jsx-one-expression-per-line': 'off', // 关闭要求一个表达式必须换行的要求,和Prettier冲突了
  23. 'react/jsx-wrap-multilines': 0, // 关闭要求jsx属性中写jsx必须要加括号,和Prettier冲突了
  24. 'comma-dangle': ['error', 'never'],
  25. 'react/jsx-first-prop-new-line': [1, 'multiline-multiprop'],
  26. 'react/prefer-stateless-function': [0, { ignorePureComponents: true }],
  27. 'jsx-a11y/no-static-element-interactions': 'off', // 关闭非交互元素加事件必须加 role
  28. 'jsx-a11y/click-events-have-key-events': 'off', // 关闭click事件要求有对应键盘事件
  29. 'no-bitwise': 'off', // 不让用位操作符,不知道为啥,先关掉
  30. 'react/jsx-indent': [2, 2],
  31. 'react/jsx-no-undef': [2, { allowGlobals: true }],
  32. 'jsx-control-statements/jsx-use-if-tag': 0,
  33. 'react/no-array-index-key': 0,
  34. 'react/jsx-props-no-spreading': 0,
  35. // 禁止使用 var
  36. 'no-var': 'error',
  37. semi: ['error', 'never'],
  38. quotes: [2, 'single'],
  39. // @fixable 必须使用 === 或 !==,禁止使用 == 或 !=,与 null 比较时除外
  40. eqeqeq: [
  41. 'warn',
  42. 'always',
  43. {
  44. null: 'ignore'
  45. }
  46. ],
  47. 'no-use-before-define': ['error', { functions: false }],
  48. 'prettier/prettier': ['error', { parser: 'flow' }]
  49. },
  50. overrides: [
  51. {
  52. files: ['**/Mi/*.js', '**/Mi/*.jsx'],
  53. rules: {
  54. 'react/prop-types': 'error' // Mi 文件夹下的是系统组件,必须写prop-types
  55. }
  56. }
  57. ]
  58. }