规则“ indent”的配置无效:值“ [object Object]”不应具有其他属性

时间:2018-09-07 15:04:02

标签: node.js reactjs eslint

我有一个使用CRA创建的测试应用,其package.json如下:

{
  "name": "test-app",
  "version": "0.1.0",
  "private": true,
  "dependencies": {
    "autoprefixer": "7.1.6",
    "babel-core": "6.26.0",
    "babel-eslint": "7.2.3",
    "babel-jest": "20.0.3",
    "babel-loader": "7.1.2",
    "babel-plugin-react-intl": "^2.4.0",
    "babel-preset-react-app": "^3.1.1",
    "babel-runtime": "6.26.0",
    "case-sensitive-paths-webpack-plugin": "2.1.1",
    "chalk": "1.1.3",
    "compression-webpack-plugin": "0.3.2",
    "css-loader": "0.28.7",
    "cssnano": "^3.10.0",
    "dotenv": "4.0.0",
    "dotenv-expand": "4.2.0",
    "eslint": "4.10.0",
    "eslint-config-react-app": "^2.1.0",
    "eslint-config-standard": "^11.0.0-beta.0",
    "eslint-config-standard-jsx": "^5.0.0",
    "eslint-loader": "1.9.0",
    "eslint-plugin-flowtype": "2.39.1",
    "eslint-plugin-header": "1.0.0",
    "eslint-plugin-import": "2.8.0",
    "eslint-plugin-jsx-a11y": "5.1.1",
    "eslint-plugin-node": "^5.2.1",
    "eslint-plugin-promise": "^3.6.0",
    "eslint-plugin-react": "7.4.0",
    "eslint-plugin-standard": "^3.0.1",
    "eslint-watch": "^3.1.3",
    "eui-bootstrap": "^5.0.0",
    "eui-components": "^5.0.0",
    "eui-react-dev-utils": "file:/appdata/prod/buildagent-eui/workspace/root/build/UIF/create-react-app/origin_master/test/linux_build/packages/react-dev-utils",
    "extract-text-webpack-plugin": "3.0.2",
    "file-loader": "1.1.5",
    "fs-extra": "3.0.1",
    "glob": "^7.1.2",
    "html-webpack-plugin": "2.29.0",
    "jest": "20.0.4",
    "lodash": "^4.17.10",
    "object-assign": "4.1.1",
    "postcss-calc": "^5.3.1",
    "postcss-css-variables": "0.7.0",
    "postcss-flexbugs-fixes": "3.2.0",
    "postcss-import": "9.1.0",
    "postcss-loader": "2.0.8",
    "postcss-nested": "^1.0.0",
    "postcss-simple-vars": "3.0.0",
    "promise": "8.0.1",
    "raf": "3.4.0",
    "ramda": "^0.25.0",
    "react": "^16.5.0",
    "react-css-modules": "4.1.0",
    "react-dom": "^16.5.0",
    "react-error-overlay": "^2.0.2",
    "react-intl": "^2.4.0",
    "react-router-dom": "^4.3.1",
    "resolve": "1.6.0",
    "style-loader": "0.19.0",
    "sw-precache-webpack-plugin": "0.11.4",
    "url-loader": "0.6.2",
    "webpack": "3.8.1",
    "webpack-dev-server": "2.9.4",
    "webpack-manifest-plugin": "1.3.2",
    "webpack-node-version": "1.0.0",
    "whatwg-fetch": "2.0.3",
    "yarpm": "^0.2.1"
  },
  "engines": {
    "node": ">=4"
  },
  "scripts": {
    "start": "node scripts/start.js",
    "build": "node scripts/build.js",
    "test": "node scripts/test.js --env=jsdom",
    "lint:js": "node node_modules/eslint/bin/eslint.js --config node_modules/eslint-config-react-app/index.js src",
    "lint:i18n-file": "node scripts/i18nInit.js --lint",
    "lint:i18n": "node scripts/i18nLint.js",
    "lint": "yarpm run lint:js && yarpm run lint:i18n && yarpm run lint:i18n-file",
    "i18n:extract": "node scripts/i18nExtract.js",
    "i18n:codes": "node scripts/i18nCodes.js",
    "i18n:init": "node scripts/i18nInit.js",
    "i18n": "yarpm run i18n:extract && yarpm run i18n:init && yarpm run i18n:codes",
    "ci": "yarpm run build && yarpm run lint && yarpm run test -- --coverage"
  },
  "coverageThreshold": {
    "global": {
      "branches": 75,
      "functions": 75,
      "lines": 75,
      "statements": 75
    }
  },
  "coverageExclusions": [
    "src/(index|i18n).js",
    "src/registerServiceWorker.js"
  ],
  "i18n": {
    "locales": [
      "en"
    ]
  },
  "jest": {
    "collectCoverageFrom": [
      "src/**/*.{js,jsx,mjs}"
    ],
    "setupFiles": [
      "<rootDir>/config/polyfills.js"
    ],
    "testMatch": [
      "<rootDir>/src/**/__tests__/**/*.{js,jsx,mjs}",
      "<rootDir>/src/**/?(*.)(spec|test).{js,jsx,mjs}"
    ],
    "coveragePathIgnorePatterns": [
      "src/(index|i18n).js",
      "src/registerServiceWorker.js",
      "/node_modules/"
    ],
    "coverageThreshold": {
      "global": {
        "branches": 75,
        "functions": 75,
        "lines": 75,
        "statements": 75
      }
    },
    "testEnvironment": "node",
    "testURL": "http://localhost",
    "transform": {
      "^.+\\.(js|jsx|mjs)$": "<rootDir>/node_modules/babel-jest",
      "^.+\\.css$": "<rootDir>/config/jest/cssTransform.js",
      "^.+\\.md$": "<rootDir>/config/jest/frontMatterTransform.js",
      "^(?!.*\\.(js|jsx|mjs|css|json)$)": "<rootDir>/config/jest/fileTransform.js"
    },
    "transformIgnorePatterns": [
      "[/\\\\]node_modules[/\\\\].+\\.(js|jsx|mjs)$"
    ],
    "moduleNameMapper": {
      "^react-native$": "react-native-web"
    },
    "moduleFileExtensions": [
      "web.js",
      "js",
      "json",
      "web.jsx",
      "jsx",
      "node",
      "mjs"
    ]
  },
  "babel": {
    "presets": [
      "react-app"
    ]
  },
  "eslintConfig": {
    "extends": "react-app"
  }
}

我添加eslint之后,纱线构建就开始失败。 我不确定是什么原因引起的。

错误: 模块构建失败:错误:/tmp/tmp.yJi2DRuG5q/test-app/node_modules/eslint-config-standard/index.js:     规则“缩进”的配置无效:     值“ [object Object]”不应具有其他属性。 引用自:/tmp/tmp.yJi2DRuG5q/test-app/.eslintrc     在validateRuleOptions(/tmp/tmp.yJi2DRuG5q/test-app/node_modules/eslint/lib/config/config-validator.js:113:15)     在Object.keys.forEach.id(/tmp/tmp.yJi2DRuG5q/test-app/node_modules/eslint/lib/config/config-validator.js:153:9)     在Array.forEach()     在validateRules(/tmp/tmp.yJi2DRuG5q/test-app/node_modules/eslint/lib/config/config-validator.js:152:30)     在Object.validate(/tmp/tmp.yJi2DRuG5q/test-app/node_modules/eslint/lib/config/config-validator.js:230:5)     在loadFromDisk(/tmp/tmp.yJi2DRuG5q/test-app/node_modules/eslint/lib/config/config-file.js:549:19)     加载时(/tmp/tmp.yJi2DRuG5q/test-app/node_modules/eslint/lib/config/config-file.js:592:20)     在configExtends.reduceRight(/tmp/tmp.yJi2DRuG5q/test-app/node_modules/eslint/lib/config/config-file.js:421:36)     在Array.reduceRight()     在applyExtends(/tmp/tmp.yJi2DRuG5q/test-app/node_modules/eslint/lib/config/config-file.js:403:28)

我的.eslintrc

{
  "extends": [
    "standard",
    "standard-jsx",
    "react-app",
    "plugin:react/recommended"
  ],
  "plugins": [
    "header",
    "react"
  ],
  "parserOptions": {
    "ecmaFeatures": {
      "jsx": true
    }
  },
  "rules": {
    "header/header": [2, "block", {
      "pattern": "[\\n?\\r]\\s+\\*\\[\\n?\\r]\\s+\\*\\s+this notice\\.[\\n?\\r]\\s+$"
    }],
    "no-console": "off",
    "strict": ["error", "global"],
    "require-jsdoc": ["error", {
      "require": {
        "FunctionDeclaration": true,
        "MethodDefinition": true,
        "ClassDeclaration": true,
        "ArrowFunctionExpression": true,
        "FunctionExpression": true
      }
    }],
    "valid-jsdoc": ["error", {
      "requireReturn": false
    }],
    "react/jsx-no-bind": "error"
  }
}

你知道是什么原因造成的吗?

1 个答案:

答案 0 :(得分:1)

您的eslint版本很旧,请将其更新为5.x