Giter VIP home page Giter VIP logo

Comments (10)

sverona avatar sverona commented on June 14, 2024 1

Oh, it's just a semver thing. Okay, well, that makes sense. As someone in another thread said, you're a beast. Thank you for what you do.

from eslint-plugin-jsx-a11y.

ljharb avatar ljharb commented on June 14, 2024

by "strict mode" do you mean, in the strict config? included configs aren't documented anywhere, you'd have to check the code: https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/blob/main/src/index.js#L202-L293

from eslint-plugin-jsx-a11y.

sverona avatar sverona commented on June 14, 2024

I see. I assumed the behavior was different between configs for some reason, but your link tells me that both behave exactly the same way.

Either way, I'm showing errors on a <label> that wraps an <input> XOR has a htmlFor. This differs from the documented behavior:

This rule checks that any label tag (or an indicated custom component that will output a label tag) either (1) wraps an input element (or an indicated custom component that will output an input tag) or (2) has an htmlFor attribute and that the label tag has text content.

My guess is a recent pull request changed the behavior but not the documentation.

from eslint-plugin-jsx-a11y.

ljharb avatar ljharb commented on June 14, 2024

In which version do you see this changing? Are you using the plugin directly, or via the airbnb config?

from eslint-plugin-jsx-a11y.

sverona avatar sverona commented on June 14, 2024

I believe it traces to #457. It doesn't mention a specific commit, but I do see the same XOR verbiage in the initial documentation commit: d8ff542#diff-3ebaf3198dc642deb25323844e832cb908e0cfd2ffe0ae03578af74dae81aa81.

The rule changed at least by #759.

from eslint-plugin-jsx-a11y.

ljharb avatar ljharb commented on June 14, 2024

PRs don't land in order, so the important thing is to figure out if this behavior actually changed in a specific release.

from eslint-plugin-jsx-a11y.

sverona avatar sverona commented on June 14, 2024

I see the trouble now. The documentation does mention assert: "both", and it appears this is the default. Since assert: "both" is in fact the correct behavior, I feel the paragraph I cited earlier should read something like

By default, this rule checks that any label tag (or an indicated custom component that will output a label tag) both (1) wraps an input element (or an indicated custom component that will output an input tag) and (2) has an htmlFor attribute and that the label tag has text content.

I'd be willing to submit a PR to this effect.

from eslint-plugin-jsx-a11y.

ljharb avatar ljharb commented on June 14, 2024

The default is "either", per https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/blob/main/src/rules/label-has-associated-control.js#L57. This suggests that the docs are correct.

Can you share your eslint config? Something must be setting it to "both".

from eslint-plugin-jsx-a11y.

sverona avatar sverona commented on June 14, 2024

Oh, heck, you're correct. It's airbnb. I was going to mention this in a prior comment, but got lost copy-pasting to a new one.

#718 indicates that I'm not the only one who has been caught by this. I appreciate that documentation is not the place for debate that goes into issues, but the configuration difference is buried in a different repository. I wish now that I hadn't gotten caught in this maze.

Of course a11y linting != a11y but finding disparate best practices for something so seemingly simple says something regrettable about the current state of things. But nothing I can do about that.

from eslint-plugin-jsx-a11y.

ljharb avatar ljharb commented on June 14, 2024

"Both" is the better and more accessible setting, so if we ever do a major version, I'll want to change the default to match.

from eslint-plugin-jsx-a11y.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.