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

Implement global settings #174

Closed
beefancohen opened this issue Feb 4, 2017 · 16 comments
Closed

Implement global settings #174

beefancohen opened this issue Feb 4, 2017 · 16 comments

Comments

@beefancohen
Copy link
Contributor

Discussed in #65. We can provide global settings API for users to specify mappings from low-level DOM elements to their associated wrapper component. This allows us to better apply the ruleset over a codebase. It can also have configuration options for ARIA convention for props (i.e. camel-casing like ariaExpanded or just expanded) that map to respective ARIA properties. Also contains a special property for role since that sometimes has conflicts (as seen in #166).

Can look something like this:

{
	"settings": {
		"components": {
			"a": ["Link"],
			"abbr": [],
			"address": [],
			"area": [],
			"article": [],
			"aside": [],
			"audio": [],
			"b": [],
			"base": [],
			"bdi": [],
			"bdo": [],
			"big": [],
			"blockquote": [],
			"body": [],
			"br": [],
			"button": ["Button"],
			"canvas": [],
			"caption": [],
			"cite": [],
			"code": [],
			"col": [],
			"colgroup": [],
			"data": [],
			"datalist": [],
			"dd": [],
			"del": [],
			"details": [],
			"dfn": [],
			"dialog": [],
			"div": [],
			"dl": [],
			"dt": [],
			"em": [],
			"embed": [],
			"fieldset": [],
			"figcaption": [],
			"figure": [],
			"footer": ["Footer"],
			"form": [],
			"h1": [],
			"h2": [],
			"h3": [],
			"h4": [],
			"h5": [],
			"h6": [],
			"head": [],
			"header": ["Header"],
			"hgroup": [],
			"hr": [],
			"html": [],
			"i": [],
			"iframe": [],
			"img": ["Image"],
			"input": ["Input"],
			"ins": [],
			"kbd": [],
			"keygen": [],
			"label": ["Label"],
			"legend": [],
			"li": [],
			"link": [],
			"main": [],
			"map": [],
			"mark": [],
			"menu": [],
			"menuitem": [],
			"meta": [],
			"meter": [],
			"nav": [],
			"noscript": [],
			"object": [],
			"ol": [],
			"optgroup": [],
			"option": [],
			"output": [],
			"p": [],
			"param": [],
			"picture": [],
			"pre": [],
			"progress": [],
			"q": [],
			"rp": [],
			"rt": [],
			"ruby": [],
			"s": [],
			"samp": [],
			"script": [],
			"section": [],
			"select": [],
			"small": [],
			"source": [],
			"span": [],
			"strong": [],
			"style": [],
			"sub": [],
			"summary": [],
			"sup": [],
			"table": [],
			"tbody": [],
			"td": [],
			"textarea": [],
			"tfoot": [],
			"th": [],
			"thead": [],
			"time": [],
			"title": [],
			"tr": [],
			"track": [],
			"u": [],
			"ul": [],
			"var": [],
			"video": [],
			"wbr": []
		},
		"props": {
			"aria": "kebab",
			"role": "ariaRole"
		}
	}
}
@jessebeach
Copy link
Collaborator

hoohoo! Are you thinking that we could map custom components to html elements? like

"button": ['AbstractButton', 'FancyButton', 'PopoverButton']

@ljharb
Copy link
Member

ljharb commented Jan 19, 2018

I’d still find value in this, fwiw.

@eps1lon
Copy link
Contributor

eps1lon commented Feb 8, 2019

@evcohen Was this abandoned? I see that you closed this with without referencing any commit, PR or other explanation.

@karltaylor
Copy link

This would really help when using jsx-a11y with styled-components. I hope this can be re-opened and looked at!

@jessebeach
Copy link
Collaborator

@karltaylor code examples would really help frame the enhancement. Could you post a few here?

@gabeodess
Copy link

Would love to see this working. Currently having trouble with jsx-a11y/label-has-for:

<label htmlFor={id}>
  <Checkbox id={id}/> Click Me!
</label>

Could be solved by:

settings:
  components:
    input: ["Checkbox"]

@ljharb
Copy link
Member

ljharb commented Apr 3, 2019

Considering this was closed without explanation, and I'd still like to see it happen, I'm going to reopen - @evcohen please feel free to re-close, but it'd be great to understand why :-)

@talentlessguy
Copy link

any progress on this?

@madalynrose
Copy link

Any updates on this?

I really love this tool and recommend it everywhere I can. Establishing an API for mapping custom components and attributes to their equivalent semantic element would add a lot of power. I'd love a way to lint Gatsby's components (e.g.<Link/>, which expects a to attribute instead of an href). This is also especially useful for styled components, which are becoming increasingly popular with usage in frameworks like Gatsby. The discussion around explicit mapping in #466 touches on a specific use case for this feature and I hope it gets picked back up.

@heylookltsme
Copy link

Bump! Our company would love this for usage with styled components.

It looks like individual rules support a mapping of the HTML element to custom components, but maintaining those maps on a per-rule basis is prohibitively tedious and difficult to scale/maintain.

The solution proposed here - a global mapping of elements to components - would be fantastic. 🎉

@eps1lon
Copy link
Contributor

eps1lon commented Mar 30, 2020

I'd love a way to lint Gatsby's components (e.g., which expects a to attribute instead of an href).

This is a really good point. Any implementation should not only consider element mappings but also attribute mappings for custom props (per component) as well as disabling certain rules. Certain required aria attributes might be already set for custom components.

@pcorpet
Copy link
Contributor

pcorpet commented Mar 24, 2022

I've started a change in #844, if anyone wants to comment on the API I've chosen and my implementation. If you like it, I'll finish the remaining rules and add proper documentation.

pcorpet added a commit to pcorpet/eslint-plugin-jsx-a11y that referenced this issue Mar 25, 2022
pcorpet added a commit to pcorpet/eslint-plugin-jsx-a11y that referenced this issue Mar 25, 2022
pcorpet added a commit to pcorpet/eslint-plugin-jsx-a11y that referenced this issue Mar 27, 2022
pcorpet added a commit to pcorpet/eslint-plugin-jsx-a11y that referenced this issue Mar 27, 2022
pcorpet added a commit to pcorpet/eslint-plugin-jsx-a11y that referenced this issue Mar 27, 2022
pcorpet added a commit to pcorpet/eslint-plugin-jsx-a11y that referenced this issue Mar 28, 2022
pcorpet added a commit to pcorpet/eslint-plugin-jsx-a11y that referenced this issue Apr 8, 2022
@smithki
Copy link

smithki commented May 3, 2022

Love to see that #844 is merged! I'm very much looking forward to seeing those changes land in a published release. Any thoughts on when that might happen? As of now, the README documentation reflects support for global settings, but that's not yet the case 😞

@ljharb
Copy link
Member

ljharb commented May 3, 2022

@smithki on every repo on github, the readme on the default branch won't necessarily match the last published version, and you have to Just Know to change to a tag to see that version's docs.

There's no planned release time, but hopefully soon.

@ljharb
Copy link
Member

ljharb commented Jun 24, 2022

v6.6.0 is released.

@ljharb
Copy link
Member

ljharb commented Sep 16, 2022

I think #844 has resolved this, so I'm going to close.

If I'm wrong, what would be most helpful is filing a new issue that details any gaps, and why they're needed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests