-
Notifications
You must be signed in to change notification settings - Fork 2
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
Enable rules from eslint-plugin-jsx-a11y
in @khanacademy/eslint-config/a11y
#1118
Conversation
…llow the naming convention StyledElement
…eslint-plugin-jsx-a11y` in `@khanacademy/eslint-config/a11y`
🦋 Changeset detectedLatest commit: 9d50ac1 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #1118 +/- ##
=======================================
Coverage 99.85% 99.85%
=======================================
Files 97 97
Lines 1392 1392
Branches 358 359 +1
=======================================
Hits 1390 1390
Misses 1 1
Partials 1 1 Continue to review full report in Codecov by Sentry.
|
Size Change: 0 B Total Size: 4.63 kB ℹ️ View Unchanged
|
For regulard repos, the settings will look like this: | ||
|
||
``` | ||
For monorepos the `"import/resolver"` settings will look like this: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was duplicated from line 12 and not needed (I think!)
GeraldRequired Reviewers
Don't want to be involved in this pull request? Comment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks great to me, thanks for all the thorough comments and rule settings! It will be good to hear @kevinb-khan's take on it too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. I didn't look at the specific rules though. 🎉
// Mapping for common wrappers for html elements when we can use `addStyle` | ||
StyledA: "a", | ||
StyledButton: "button", | ||
StyledImg: "img", | ||
StyledSvg: "svg", | ||
StyledUl: "ul", | ||
StyledOl: "ol", | ||
StyledLi: "li", | ||
StyledSpan: "span", | ||
StyledDiv: "div", | ||
StyledSection: "section", | ||
StyledHeader: "header", | ||
StyledFooter: "footer", | ||
StyledBlockquote: "blockquote", | ||
StyledForm: "form", | ||
StyledOutput: "output", | ||
StyledIframe: "iframe", | ||
StyledHr: "hr", | ||
StyledP: "p", | ||
StyledFieldset: "fieldset", | ||
StyledLegend: "legend", | ||
StyledCaption: "caption", | ||
StyledPre: "pre", | ||
StyledSup: "sup", | ||
StyledMark: "mark", | ||
StyledTable: "table", | ||
StyledTr: "tr", | ||
StyledTd: "td", | ||
StyledTh: "th", | ||
StyledDl: "dl", | ||
StyledDt: "dt", | ||
StyledDd: "dd", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So many. It would be nice to have a wonder-blocks package that exports this. Is that something that's on the roadmap?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you mean a WB package that exports this StyledX component mapping? Would it be useful for other cases? If not, another option would be to move this mapping to another file in this package and import it from there so the config file isn't as long! What do you think?
Or did you mean it'd be nice to have a WB package that exports the StyledX components already (as we briefly chatted about 😄)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was thinking of a WB package that does a bunch of exports like:
export const StyleP = addStyle("p");
export const styledTable = addStyle("table");
...
This suggestion is only tangentially related to this PR. It's so that people don't need to remember to use addStyle
to get these variants. Eventually we could even add lint rules to disallow non-styled variants.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for clarifying! I created https://khanacademy.atlassian.net/browse/WB-1879 for this 😄
const ERROR = "error"; | ||
const OFF = "off"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wondering if switching to tseslint.config
means we'll get property type checking for our configs. No action req'd, just something we may want to think about for the future. See https://typescript-eslint.io/packages/typescript-eslint#config for details.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for sharing, that would be helpful down the line, yes! I was following the format from our default config file 😅
…th AccordionSectionHeader tag prop in WB
I tested the config changes locally in |
// for labels to be assosciated with the control for the | ||
// jsx-a11y/label-has-associated-control rule. | ||
SingleSelect: "select", | ||
MultiSelect: "select", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice. Good find!!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is awesome!! I tested it out locally in Wonder Blocks and it worked great. One minor change in the repro steps was that I had to use lowercase -w
with pnpm.
Once I got that and the correct tarball path, it installed properly and caught non-semantic elements with addStyle
. Great work, @beaesguerra!
## Summary: This work is part of the implementation of [ADR#781 Enabling more lint rules for accessibility](https://khanacademy.atlassian.net/wiki/x/IoBVyg) These changes include: - Updating `@khanacademy/eslint-config` to the latest version to include new jsx-a11y configuration and settings - Addressed existing errors by adding `eslint-disable-next-line` - View the PR commits for a breakdown of errors by rule - Used `npx [email protected] .` to easily disable lint errors per rule - New potential a11y issues can be prevented with these lint rules! Note: In a follow up PR, I'll address the low hanging issues in WB and create tickets for more complex issues that were found A breakdown of the existing jsx-a11y errors: <img width="1027" alt="wb-linting-errors-before" src="https://github.com/user-attachments/assets/cbe4be7f-6868-48af-8474-bad0297cf8b2" /> Implementation Plan: - Khan/wonder-stuff#1114 Set up eslint a11y config and enable aphrodite-add-style-variable-name - Use this new config in WB, perseus, webapp and address lint errors from the aphrodite-add-style-variable-name rule - #2459 - Khan/perseus#2193 - Khan/webapp#29212 - Khan/wonder-stuff#1118 Update the eslint-config/a11y config with the config based on the accessibility linting rules ADR - (includes this PR) Use the updated config in projects and address existing errors by disabling the rules per line. Issue: FEI-1133 ## Test plan: - Run `pnpm lint` and make sure there are no linting errors Author: beaesguerra Reviewers: beaesguerra, jandrade Required Reviewers: Approved By: jandrade Checks: ✅ Chromatic - Get results on regular PRs (ubuntu-latest, 20.x), ✅ Lint / Lint (ubuntu-latest, 20.x), ✅ Test / Test (ubuntu-latest, 20.x, 2/2), ✅ Test / Test (ubuntu-latest, 20.x, 1/2), ✅ Check build sizes (ubuntu-latest, 20.x), ✅ Publish npm snapshot (ubuntu-latest, 20.x), ✅ Chromatic - Build and test on regular PRs / chromatic (ubuntu-latest, 20.x), ✅ Prime node_modules cache for primary configuration (ubuntu-latest, 20.x), ⏭️ Chromatic - Skip on Release PR (changesets), ✅ Check for .changeset entries for all changed files (ubuntu-latest, 20.x), ✅ gerald, ⏭️ dependabot Pull Request URL: #2471
## Summary: This work is part of the implementation of [ADR#781 Enabling more lint rules for accessibility](https://khanacademy.atlassian.net/wiki/x/IoBVyg) These changes include: - Updating `@khanacademy/eslint-config` to the latest version to include new jsx-a11y configuration and settings - Updating `esling-plugin-jsx-a11y` to the latest version so it is up to date - Addressed existing errors by adding `eslint-disable-next-line` - View the PR commits for a breakdown of errors by rule - Used `npx [email protected] .` to disable lint errors per rule - Provided custom component mapping for jsx-a11y in the eslint config since Perseus has custom components New potential a11y issues can be prevented with these lint rules and existing errors can be addressed over time by the team! The lint error messages have a link to the [rule docs](https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/tree/main/docs/rules) for more details! A breakdown of the existing jsx-a11y errors: <img width="1019" alt="perseus-linting-errors-before" src="https://github.com/user-attachments/assets/8191e551-4147-43cb-bbcf-79b0e5684c26" /> ### Implementation Plan: - Khan/wonder-stuff#1114 Set up eslint a11y config and enable aphrodite-add-style-variable-name - Use this new config in WB, perseus, webapp and address lint errors from the aphrodite-add-style-variable-name rule - Khan/wonder-blocks#2459 - #2193 - Khan/webapp#29212 - Khan/wonder-stuff#1118 Update the eslint-config/a11y config with the config based on the accessibility linting rules ADR - (includes this PR) Use the updated config in projects and address existing errors by disabling the rules per line. Issue: FEI-1133 ## Test plan: - Run `yarn lint` and make sure there are no linting errors Author: beaesguerra Reviewers: catandthemachines, beaesguerra, #frontend-infra-web Required Reviewers: Approved By: catandthemachines Checks: ✅ Publish npm snapshot (ubuntu-latest, 20.x), ✅ Lint, Typecheck, Format, and Test (ubuntu-latest, 20.x), ✅ Cypress (ubuntu-latest, 20.x), ✅ Check for .changeset entries for all changed files (ubuntu-latest, 20.x), ✅ Check builds for changes in size (ubuntu-latest, 20.x), ✅ Publish Storybook to Chromatic (ubuntu-latest, 20.x) Pull Request URL: #2232
Summary:
This work is part of the implementation of ADR#781 Enabling more lint rules for accessibility
These changes includes:
eslint-plugin-jsx-a11y
dependencyeslint-plugin-jsx-a11y
based on the proposed rules and settings in the ADR and the POC@khanacademy/eslint-config/a11y
Issue: FEI-1133
Implementation Plan:
Test plan:
Testing the new config locally:
packages/eslint-config-khan
. This will create a.tgz
file in the directoryyarn add -D -W /Users/beaesguerra/khan/wonder-stuff/packages/eslint-config-khan/khanacademy-eslint-config-v5.1.0.tgz
node_modules/@khanacademy/eslint-config/a11y.js
in the project to see if the new config is there@khanacademy/eslint-config/a11y
in the project's eslint config fileyarn lint
/pnpm lint
in the project and restart the ESLint server. It should show errors from thejsx-a11y
pluginNote: Before merging and releasing these changes, I'll test these changes locally with the different projects and evaluate the errors to make sure the config changes are still relevant and helpful!