node.js - 规则 "indent"的配置无效 : Value "[object Object]" should NOT have additional properties

标签 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 后,yarn 构建就开始失败。 我不确定是什么导致了这个问题。

错误: 模块构建失败:错误:/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"
  }
}

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

最佳答案

您的eslint版本相当旧,请将其更新到5.x

关于node.js - 规则 "indent"的配置无效 : Value "[object Object]" should NOT have additional properties,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52225247/

相关文章:

css - React Native 中的颜色文字有什么问题?

javascript - 如何在 Flow 中声明更改参数而不会出现 ESLint 错误的函数

reactjs - 在 jsx 中禁用 eslint 错误

javascript - Mongoose 找到一个并推送到文档数组

reactjs - 如何在 React 中使用组合而不是 mixin 来解决这个问题?

node.js - 如何使用 Google Cloud 函数获取 URL?要求?

reactjs - 未找到规则 'simple-import-sort/sort' 的定义 simple-import-sort/sort

mysql - mysql 种子中的异步等待不运行

node.js - ng 服务 --proxy-config proxyconfig.json 不起作用

javascript - WebSocket 未连接