Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extend "jsx-boolean-value" to support optional "ignore" list #1249

Closed
mehdivk opened this issue Jun 10, 2017 · 7 comments
Closed

Extend "jsx-boolean-value" to support optional "ignore" list #1249

mehdivk opened this issue Jun 10, 2017 · 7 comments

Comments

@mehdivk
Copy link

mehdivk commented Jun 10, 2017

It would be great if we could configure jsx-boolean-value to ignore a list of props.

Example

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

This allows the following expression to be valid

<Toggle value={true} />

And if you wonder why I'm not using a prop like toggled instead of value, it's because we want to have a set of components that support the same prop.

I'm more than happy to support the idea with a PR.

@ljharb
Copy link
Member

ljharb commented Jun 10, 2017

why wouldn't you want to do <Toggle value />?

@mehdivk
Copy link
Author

mehdivk commented Jun 10, 2017

why wouldn't you want to do ?

Good question. I think <Toggle value /> has some readability issues. For props that ends with ed (E.g. checked, toggled, disabled etc) it makes sense to drop {true} but not for something like value.

@ljharb
Copy link
Member

ljharb commented Jun 10, 2017

It sounds like then you wouldn't want "ignore", you'd instead want a setting that enforced "always" for that prop.

@mehdivk
Copy link
Author

mehdivk commented Jun 11, 2017

It sounds like then you wouldn't want "ignore", you'd instead want a setting that enforced "always" for that prop.

Yes, I want to use a mix of always and never in my project.

This should cause lint error

<Toggle toggled={true} />

but this should pass the linting

<CheckBox value={true} />

and this should cause lint error

<CheckBox value />

@ljharb
Copy link
Member

ljharb commented Jun 11, 2017

Although I don't personally agree with that style, an option to the rule to allow this works.

What about, only with "always", a "never" option - and only with "never", an "always" option? Both options would be a unique array of prop names.

@ljharb
Copy link
Member

ljharb commented Jun 11, 2017

PR up: #1250

ljharb added a commit to ljharb/eslint-plugin-react that referenced this issue Jun 11, 2017
@mehdivk
Copy link
Author

mehdivk commented Jun 11, 2017

Thanks for the PR @ljharb

ljharb added a commit to ljharb/eslint-plugin-react that referenced this issue Jun 11, 2017
ljharb added a commit to ljharb/eslint-plugin-react that referenced this issue Jun 11, 2017
ljharb added a commit to ljharb/eslint-plugin-react that referenced this issue Jun 13, 2017
ljharb added a commit to ljharb/eslint-plugin-react that referenced this issue Jun 14, 2017
ljharb added a commit to ljharb/eslint-plugin-react that referenced this issue Jun 14, 2017
ljharb added a commit to ljharb/eslint-plugin-react that referenced this issue Jun 14, 2017
ljharb added a commit to ljharb/eslint-plugin-react that referenced this issue Jun 15, 2017
ljharb added a commit to ljharb/eslint-plugin-react that referenced this issue Jun 17, 2017
ljharb added a commit to ljharb/eslint-plugin-react that referenced this issue Jun 21, 2017
ljharb added a commit to ljharb/eslint-plugin-react that referenced this issue Jun 22, 2017
ljharb added a commit to ljharb/eslint-plugin-react that referenced this issue Jun 26, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

2 participants