Javascript: `react/jsx-boolean-value` rule has invalid options

Created on 16 Oct 2017  路  11Comments  路  Source: airbnb/javascript

The rule is configured like this:

'react/jsx-boolean-value': ['error', 'never', { always: [] }]

However, an inspection of the rule's schema shows that its "exception schema" (that is, the third element of the array that specifies exceptions to the the second element) expects the array provided to have at least one element in it:

const exceptionsSchema = {
  type: 'array',
  items: {type: 'string', minLength: 1},
  uniqueItems: true
};

What was the rationale for changing the rule's options? It seems like

'react/jsx-boolean-value': ['error', 'never']

would achieve the same thing and be compliant with the rule's schema.

invalid question react

Most helpful comment

@llamaluvr no, I have no idea what fixed it. A good night's rest?

All 11 comments

The rationale was that I prefer our config to specify as many things as it possibly can, as a reference for when overrides are needed. You are correct here though that since the minLength is 1, we shouldn't be specifying it in this config. Thanks!

Ah, no wait - the schema says that each item has to have a minLength of 1. The array itself has no min length requirement - precisely so that an empty array is permitted (I'm the one that created the rule schema itself :-p)

Ah, okay, thanks for clarifying! Yesterday my IDE was complaining about an invalid configuration (yet, external to the IDE, eslint would still run...), but today it seems to have sorted itself out. Thanks for the rapid response.

@milotoor any idea what cleared things up for your IDE? I get this error in VSCode after upgrading to the latest airbnb eslint rules and now none of the rules flag in there. Seems like I'm up-to-date on everything (see below).

"devDependencies": {
    "babel-eslint": "^7.2.3",
    "babel-plugin-transform-decorators-legacy": "^1.3.4",
    "babel-preset-stage-2": "^6.24.1",
    "eslint": "^4.9.0",
    "eslint-config-airbnb": "^16.0.1",
    "eslint-config-universe": "^1.0.6",
    "eslint-import-resolver-react-native": "^0.0.1",
    "eslint-plugin-import": "^2.2.0",
    "eslint-plugin-jsx-a11y": "^6.0.2",
    "eslint-plugin-react": "^7.0.1",
    "jest-expo": "~21.0.0",
    "prettier": "1.7.4",
    "react-test-renderer": "16.0.0-alpha.12"
  },

EDIT: actually, I get the same error from the eslint command-line.

@llamaluvr your deps aren't correct; run npm ls to see the issues. Did you use the install command in the eslint-config-airbnb readme, which ensures the proper peer dep versions?

@llamaluvr no, I have no idea what fixed it. A good night's rest?

Edit: I've fixed the issue. See end of comment.

I'm having the same issue with @llamaluvr in Visual Studio Code, but not in command line. It happens when I open a .js file in the IDE.

[Error - 8:15:27 AM] d:\psychobolt-github\react-rollup-boilerplate\node_modules\eslint-config-airbnb\rules\react.js: Configuration for rule "react/jsx-boolean-value" is invalid: Value "never,[object Object]" should NOT have more than 1 items. Referenced from: d:\psychobolt-github\react-rollup-boilerplate\node_modules\eslint-config-airbnb\index.js Referenced from: d:\psychobolt-github\react-rollup-boilerplate\.eslintrc

npm info "eslint-config-airbnb@latest" peerDependencies

{ eslint: '^4.9.0',
'eslint-plugin-import': '^2.7.0',
'eslint-plugin-jsx-a11y': '^6.0.2',
'eslint-plugin-react': '^7.4.0' }

npm ls shows no issues or warnings.

All my dependencies:

"devDependencies": {
"babel": "^6.23.0",
"babel-eslint": "^8.0.1",
"babel-preset-env": "^1.6.1",
"babel-preset-flow": "^6.23.0",
"eslint": "^4.9.0",
"eslint-config-airbnb": "^16.1.0",
"eslint-plugin-flowtype": "^2.39.1",
"eslint-plugin-import": "^2.8.0",
"eslint-plugin-jest": "^21.2.0",
"eslint-plugin-jsx-a11y": "^6.0.2",
"eslint-plugin-react": "^7.4.0",
"flow-bin": "^0.57.3",
"flow-typed": "2.1.5",
"jest": "^21.2.1",
"rimraf": "^2.6.2",
"rollup": "^0.50.0",
"rollup-plugin-babel": "^3.0.2"
}

Running eslint cli have no problems. Also note, I have another project setup, with not up to date dependencies, which does not have this issue and so I have means to investigate the package versions.

Edit: Ok it seems the issue is coming from a nested create-react-app project. I've ended up adding a .eslintrc in the nested project as documented since they are not using airbnb's style.

i am also facing the same issue, for multiple rules. How can i resolve it? Tried the version thing.

Same here. Once I upgrade to ^16.1.0 I receive this error. The resolution here seems to remove completely the airbnb configuration or luck. I don't think this issue should be closed.

@jleslie02 @erdahhuja first, make sure you don't have any global eslint installed. then, make sure you're not using CRA, since that requires ejecting to make the kind of eslint modifications any shared config, including this one, requires.

If you're still having an issue at that point - and you can replicate it on the command line (if not, it's an issue with your editor) - then please file a new issue.

Thanks @ljharb for your reply. I have been using CRA for multiple projects with airbnb style without ejecting and for this one I just decided to upgrade all of my linting packages.
My workaround with this issue is to downgrade back to 14.0.0, add "eslint-plugin-jsx-a11y" to my package.json and resolve any "jsx-a11y/**" rule to 0. for now.
In addition, the issue is coming directly from the node_modules/eslint-config-airbnb/rules/index.js which as a developer, still have no control over, eject or no eject.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ryankask picture ryankask  路  3Comments

olalonde picture olalonde  路  3Comments

weihongyu12 picture weihongyu12  路  3Comments

ar
mbifulco picture mbifulco  路  3Comments

surfaceowl picture surfaceowl  路  3Comments