代码之家  ›  专栏  ›  技术社区  ›  Kevin Amiranoff

eslint:“jsx-a11y/label has for”无效

  •  1
  • Kevin Amiranoff  · 技术社区  · 6 年前

    在Webstorm中,我无法消除这个错误:

    error:/users/kamiranoff/dev/myapp/node eu modules/eslint config rallycoding/rules/react-a11y.js:
    规则“JSX-A11Y/LABEL HAS FOR”的配置无效:
    值[“label”]应为对象。
    
    引用自:/users/kamiranoff/dev/myapp/node_modules/eslint config rallycoding/index.js
    引用自:/users/kamiranoff/dev/myapp/.eslintrc
    
    错误:/users/kamiranoff/dev/myapp/node_modules/eslint config rallycoding/rules/react-a11y.js:
    规则“JSX-A11Y/LABEL HAS FOR”的配置无效:
    值[“label”]应为对象。
    
    引用自:/users/kamiranoff/dev/myapp/node_modules/eslint config rallycoding/index.js
    引用自:/users/kamiranoff/dev/myapp/.eslintrc
    AT验证程序选项(/users/kamiranoff/dev/myapp/node_modules/eslint/lib/config/config validator.js:115:15)
    at object.keys.foreach.id(/users/kamiranoff/dev/myapp/node ou modules/eslint/lib/config/config validator.js:155:9)
    at array.foreach(<匿名>)
    at validaterules(/users/kamiranoff/dev/myapp/node_modules/eslint/lib/config/config validator.js:154:30)
    at object.validate(/users/kamiranoff/dev/myapp/node_modules/eslint/lib/config/config validator.js:232:5)
    在loadfromdisk上(/users/kamiranoff/dev/myapp/node_modules/eslint/lib/config/config file.js:507:19)
    加载时(/users/kamiranoff/dev/myapp/node_modules/eslint/lib/config/config file.js:550:20)
    at configextends.reducceright(/users/kamiranoff/dev/myapp/node_modules/eslint/lib/config/config file.js:421:36)
    at array.reducceright(<匿名>)
    at applyextends(/users/kamiranoff/dev/myapp/node ou modules/eslint/lib/config/config file.js:403:28)
    

    我确实尝试过用以下方法覆盖本地的.eslintrc

    。{
    “extends”:“重新编码”,
    “规则”:。{
    “箭头体样式”:0,
    “Quote Props”:0,
    “全局要求”:0,
    “max len”:最大长度[
    “错误”,
    一百二十
    ,
    “react/require extension”:“关闭”,
    “JSX-A11Y/LABEL有用于”:0
    }
    “全局”:。{
    “开发”是真的,
    “获取”:正确,
    “headers”:正确,
    “请求”:真
    }
    }
    

    并设置webstorm配置(我只是为了隐私更改文件夹名):

    在我的包裹上。

    “dependencies”:。{
    “as”:“0.4.1”,
    “axios”:“0.16.2”,
    “babel plugin transform remove console”:“6.8.5”,
    “contentful”:“4.6.4”,
    “eil cid”:“~1.0.0”,
    “eslint config rallycoding”:“3.2.0”,
    “eslint插件导入”:“^2.13.0”,
    “eslint-plugin-jsx-a11y”:“6.0.3”,
    “eslint plugin react”:“^7.10.0”,
    “listify”:“1.0.0”,
    “localytics react native”:“2.1.1”,
    “lodash”:“4.17.5”,
    “lottie react native”:“2.2.7”,
    “矩”:“2.19.3”,
    “矩时区”:“0.5.14”,
    “prop types”:“15.6.0”,
    “react”:“16.0.0”,
    “react dom”:“16.2.0”,
    “react native”:“0.51.0”,
    “react native add calendar event”:“0.3.0”,
    “react native calendars”:“1.9.3”,
    “react本机可折叠”:“0.9.0”,
    “react native config”:“0.8.1”,
    “react native dash”:“^0.0.8”,
    “react native fabric”:“0.5.1”,
    “react native firebase”:“2.2.3”,
    “react-native-i18n”:“2.0.9”,
    “react-native-iphone-x-helper”:“1.0.1”,
    “React Native Keyboard Aware Scroll View”:“0.5.0”,
    “react native navigation”:“1.1.462”,
    “react native picker”:“4.3.5”,
    “react native showmedia”:“文件:packages/react native showmedia”,
    “React Native Swiper”:“1.5.13”,
    “react native timeline listview”:“0.2.2”,
    “react native triangle”:“0.0.8”,
    “react native webview bridge”:“github:eurostardigital/react native webview bridge”,
    “react native wkwebview reborn”:“1.10.0”,
    “react redux”:“5.0.6”,
    “redux”:“3.7.2”,
    “redux logger”:“3.0.6”,
    “redux persist”:“4.10.2”,
    “redux thunk”:“2.2.0”,
    “tai密码强度”:“1.1.1”
    }
    “devdependencies”:。{
    “babel jest”:“20.0.3”,
    “babel preset react native”:“1.9.2”,
    “codecov”:“3.0.0”,
    “dotenv”:“4.0.0”,
    “eil content”:“~2.2.2”,
    “酶”:“3.3.0”,
    “酶-适配器-反应-16”:“1.1.1”,
    “eslint”:“4.11.0”,
    “google spreadsheet”:“2.0.4”,
    “husky”:“0.14.1”,
    “jest”:“20.0.4”,
    “lint stepped”:“4.0.0”,
    “prettier”:“~1.8.2”,
    “react native mock”:“0.3.1”,
    “react test renderer”:“16.0.0-alpha.12”,
    “redux logger”:“3.0.6”,
    “Redux模拟存储”:“^1.5.1”
    }
    “笑话”:。{
    “preset”:“本地响应”,
    “TransformIgnorePatterns”:。[
    “节点模块/(?!react native react navigation)/“
    ,
    “设置文件”:。[
    “/config/testenvironment.js”
    ,
    “CollectCoverageFrom”:。[
    “src/**/*.js”
    ]
    }
    “lint-staged”:。{
    “gitdir”:“.”/“,
    “*.js”:。[
    “prettier--单引号--打印宽度120--制表宽度2--写入”,
    “/node_modules/eslint config rallycoding/node_modules/eslint/bin/eslint.js”,
    “Git添加”
    ]
    }
    

    我怎样才能消除这个错误?

    我确实尝试过覆盖本地.eslintrc用:

    {
      "extends": "rallycoding",
      "rules": {
        "arrow-body-style": 0,
        "quote-props": 0,
        "global-require": 0,
        "max-len": [
          "error",
          120
        ],
        "react/require-extension": "off",
        "jsx-a11y/label-has-for": 0
      },
      "globals": {
        "__DEV__": true,
        "fetch": true,
        "Headers": true,
        "Request": true
      }
    }
    

    并设置webstorm配置(我只是为了隐私更改文件夹名): enter image description here

    在我的包上。

    "dependencies": {
        "as": "0.4.1",
        "axios": "0.16.2",
        "babel-plugin-transform-remove-console": "6.8.5",
        "contentful": "4.6.4",
        "eil-cid": "~1.0.0",
        "eslint-config-rallycoding": "3.2.0",
        "eslint-plugin-import": "^2.13.0",
        "eslint-plugin-jsx-a11y": "6.0.3",
        "eslint-plugin-react": "^7.10.0",
        "listify": "1.0.0",
        "localytics-react-native": "2.1.1",
        "lodash": "4.17.5",
        "lottie-react-native": "2.2.7",
        "moment": "2.19.3",
        "moment-timezone": "0.5.14",
        "prop-types": "15.6.0",
        "react": "16.0.0",
        "react-dom": "16.2.0",
        "react-native": "0.51.0",
        "react-native-add-calendar-event": "0.3.0",
        "react-native-calendars": "1.9.3",
        "react-native-collapsible": "0.9.0",
        "react-native-config": "0.8.1",
        "react-native-dash": "^0.0.8",
        "react-native-fabric": "0.5.1",
        "react-native-firebase": "2.2.3",
        "react-native-i18n": "2.0.9",
        "react-native-iphone-x-helper": "1.0.1",
        "react-native-keyboard-aware-scroll-view": "0.5.0",
        "react-native-navigation": "1.1.462",
        "react-native-picker": "4.3.5",
        "react-native-showmedia": "file:packages/react-native-showmedia",
        "react-native-swiper": "1.5.13",
        "react-native-timeline-listview": "0.2.2",
        "react-native-triangle": "0.0.8",
        "react-native-webview-bridge": "github:EurostarDigital/react-native-webview-bridge",
        "react-native-wkwebview-reborn": "1.10.0",
        "react-redux": "5.0.6",
        "redux": "3.7.2",
        "redux-logger": "3.0.6",
        "redux-persist": "4.10.2",
        "redux-thunk": "2.2.0",
        "tai-password-strength": "1.1.1"
      },
      "devDependencies": {
        "babel-jest": "20.0.3",
        "babel-preset-react-native": "1.9.2",
        "codecov": "3.0.0",
        "dotenv": "4.0.0",
        "eil-content": "~2.2.2",
        "enzyme": "3.3.0",
        "enzyme-adapter-react-16": "1.1.1",
        "eslint": "4.11.0",
        "google-spreadsheet": "2.0.4",
        "husky": "0.14.1",
        "jest": "20.0.4",
        "lint-staged": "4.0.0",
        "prettier": "~1.8.2",
        "react-native-mock": "0.3.1",
        "react-test-renderer": "16.0.0-alpha.12",
        "redux-logger": "3.0.6",
        "redux-mock-store": "^1.5.1"
      },
      "jest": {
        "preset": "react-native",
        "transformIgnorePatterns": [
          "node_modules/(?!react-native|react-navigation)/"
        ],
        "setupFiles": [
          "./config/testEnvironment.js"
        ],
        "collectCoverageFrom": [
          "src/**/*.js"
        ]
      },
      "lint-staged": {
        "gitDir": "./",
        "*.js": [
          "prettier --single-quote --print-width 120 --tab-width 2 --write",
          "./node_modules/eslint-config-rallycoding/node_modules/eslint/bin/eslint.js",
          "git add"
        ]
      }
    

    我怎样才能消除这个错误?

    1 回复  |  直到 6 年前
        1
  •  2
  •   lena    6 年前

    "eslint-config-rallycoding" "jsx-a11y/label-has-for" https://github.com/StephenGrider/ESLint-Rallycoding/issues

    "eslint-plugin-jsx-a11y" "eslint"

    "eslint-plugin-jsx-a11y": "^2.2.3",
    ...
    "eslint": "^3.19.0",
    

    https://github.com/sweth/react-native-udemy/commit/2dd74ca887e8b32b82ee1e37e5a290edaa657b82