首页
学习
活动
专区
工具
TVP
发布
社区首页 >问答首页 >规则“缩进”的配置无效:值"[object Object]“不应具有其他属性

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

Stack Overflow用户
提问于 2018-09-07 23:04:02
回答 1查看 1.5K关注 0票数 1

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

代码语言:javascript
复制
{
  "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/ validateRuleOptions -app/.eslintrc at Object.keys.forEach.id (/tmp/tmp.yJi2DRuG5q/test-app/node_modules/eslint/lib/config/config-validator.js:153:9) at Array.forEach () at validateRules (/tmp/tmp.yJi2DRuG5q/validateRuleOptions-app/node_modules/eslint/lib/config/config-validator.js:152:30) at Object.validate (/tmp/tmp.yJi2DRuG5q/test-app/node_modules/eslint/lib/config/config-file.js:549:19) at (/tmp/tmp.yJi2DRuG5q/test-app/node_modules/eslint/lib/config/config at Object.validate loadFromDisk at load (/tmp/tmp.yJi2DRuG5q/test-app/node_modules/eslint/lib/config/config-file.js:592:20) at configExtends.reduceRight (/tmp/tmp.yJi2DRuG5q/test-app/node_modules/eslint/lib/config/config-file.js:403:28) at applyExtends () at applyExtends

我的.eslintrc

代码语言:javascript
复制
{
  "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"
  }
}

知道这是什么原因吗?

EN

回答 1

Stack Overflow用户

发布于 2018-09-19 06:49:39

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

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/52225247

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档