Eslint-plugin-jsx-a11y: label-has-associated-control controlComponents should allow regex

Created on 29 Jun 2020  Â·  6Comments  Â·  Source: jsx-eslint/eslint-plugin-jsx-a11y

See the title. :^)

Ideally, I'd like to be able to specify "controlComponents": "Input$" to match any component that ends with Input (e.g., <TextInput />, <EmailInput />, <BirthdateInput />, etc.).

enhancement help wanted

All 6 comments

I'd prefer a glob to a regex string; ie, *Input.

2 cents: I would vote for regex over glob. Regexes are more powerful and I think they're more common in this kind of thing (I've only ever seen globs used for file paths). How would you express .+(Input|Area|Box) using a glob (e.g., if we wanted to allow TextInput or TextBox or TextArea as valid "input" components)? The downside is that regexes are a bit harder to use. ¯_(ツ)_/¯

"More powerful" is a downside, not an upside.

I'd expect that example to be ["*Input", "*Area", "*Box"].

You say potato, I say potato. 😉

I don't have super strong feelings either way, but the eslint core rules use regexes over globs.
e.g. https://eslint.org/docs/rules/no-unused-vars

Depends on which rules you look at.

Accepting a regex string opens us up to a host of potential CVEs id rather avoid.

I created https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/pull/749 to add glob support 😄

Was this page helpful?
0 / 5 - 0 ratings

Related issues

davidleger95 picture davidleger95  Â·  4Comments

pixieduhst picture pixieduhst  Â·  3Comments

zcs19871221 picture zcs19871221  Â·  5Comments

JosephNK picture JosephNK  Â·  4Comments

theAdhocracy picture theAdhocracy  Â·  5Comments