.eslintrc 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. {
  2. //文件名 .eslintrc.json
  3. "env": {
  4. "browser": true,
  5. "es6": true,
  6. "node": true,
  7. "commonjs": true
  8. },
  9. "extends": "airbnb",
  10. "installedESLint": true,
  11. "parserOptions": {
  12. "ecmaFeatures": {
  13. "experimentalObjectRestSpread": true,
  14. "jsx": true,
  15. "arrowFunctions": true,
  16. "classes": true,
  17. "modules": true,
  18. "defaultParams": true
  19. },
  20. "sourceType": "module"
  21. },
  22. "parser": "babel-eslint",
  23. "plugins": [
  24. "react"
  25. ],
  26. "rules": {
  27. // 警告
  28. "semi": 1,
  29. "no-unused-vars": 1,
  30. // 缩进调整为 4 空格,airbnb 为 2 空格
  31. "indent": [2, 4, { "SwitchCase": 1 }],
  32. "react/jsx-filename-extension": "off",
  33. // 不禁用 console
  34. "no-console": "off",
  35. // 不强制函数表达式有名字
  36. "func-names": "off",
  37. // 不禁用 amd 的 require
  38. "import/no-amd": "off",
  39. // 不禁用 ES6 import 无法解析的模块
  40. "import/no-unresolved": "off",
  41. // 不强制全局 require
  42. "global-require": "off",
  43. // 由于是 4 空格缩进,将每行最大长度放宽到 240,airbnb 为 100
  44. "max-len": [2, 240, 2, { "ignoreUrls": true, "ignoreComments": false }],
  45. // 不禁止 for in 循环
  46. "no-restricted-syntax": [2, "DebuggerStatement", "LabeledStatement", "WithStatement"],
  47. // 不禁止使用下划线作为变量名前缀
  48. "no-underscore-dangle": ["off"],
  49. // 不强制 return
  50. "consistent-return": ["off"],
  51. // 不强制使用 => 代替函数
  52. "prefer-arrow-callback": ["off"],
  53. // 不强制使用 camel case 命名
  54. "camelcase": ["error"],
  55. // 允许修改参数
  56. "no-param-reassign": ["off"],
  57. // 不强制链式操作另起一行
  58. "newline-per-chained-call": ["off"],
  59. "new-parens": "off",
  60. "arrow-parens": "off",
  61. "no-plusplus": "off",
  62. "no-mixed-operators": "off",
  63. "import/extensions": "off",
  64. "import/newline-after-import": "off",
  65. "import/no-extraneous-dependencies": "off",
  66. "import/no-dynamic-require": "off",
  67. "import/imports-first": "off",
  68. "no-unused-expressions": "off",
  69. }
  70. }