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

Enable rules from eslint-plugin-jsx-a11y in @khanacademy/eslint-config/a11y #1118

Open
wants to merge 8 commits into
base: main
Choose a base branch
from

Conversation

beaesguerra
Copy link
Member

@beaesguerra beaesguerra commented Feb 5, 2025

Summary:

This work is part of the implementation of ADR#781 Enabling more lint rules for accessibility

These changes includes:

  • Updating the eslint-plugin-jsx-a11y dependency
  • Configuring rules and settings (including custom component mapping, attribute mapping, polymorphic components) for eslint-plugin-jsx-a11y based on the proposed rules and settings in the ADR and the POC
  • Updating the README to include instructions for using @khanacademy/eslint-config/a11y

Issue: FEI-1133

Implementation Plan:

Test plan:

Testing the new config locally:

  • Run yarn pack in packages/eslint-config-khan. This will create a .tgz file in the directory
  • In another project, install the package: ex: yarn add -D -W /Users/beaesguerra/khan/wonder-stuff/packages/eslint-config-khan/khanacademy-eslint-config-v5.1.0.tgz
    • Note: you might need to remove the node_modules first to make sure it installed the correct package. You can check by checking node_modules/@khanacademy/eslint-config/a11y.js in the project to see if the new config is there
  • Make sure the project already extends @khanacademy/eslint-config/a11y in the project's eslint config file
  • Run yarn lint/pnpm lint in the project and restart the ESLint server. It should show errors from the jsx-a11y plugin

Note: 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!

@beaesguerra beaesguerra self-assigned this Feb 5, 2025
Copy link

changeset-bot bot commented Feb 5, 2025

🦋 Changeset detected

Latest commit: c58d9e2

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@khanacademy/eslint-config Minor

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

Copy link

codecov bot commented Feb 5, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 99.85%. Comparing base (046f326) to head (c58d9e2).

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##             main    #1118   +/-   ##
=======================================
  Coverage   99.85%   99.85%           
=======================================
  Files          97       97           
  Lines        1392     1392           
  Branches      358      358           
=======================================
  Hits         1390     1390           
  Misses          1        1           
  Partials        1        1           

Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 046f326...c58d9e2. Read the comment docs.

Copy link
Contributor

github-actions bot commented Feb 5, 2025

Size Change: 0 B

Total Size: 4.63 kB

ℹ️ View Unchanged
Filename Size
packages/wonder-stuff-core/dist/browser/es/index.js 1.85 kB
packages/wonder-stuff-sentry/dist/browser/es/index.js 1.65 kB
packages/wonder-stuff-testing/dist/browser/es/index.js 1.12 kB

compressed-size-action

For regulard repos, the settings will look like this:

```
For monorepos the `"import/resolver"` settings will look like this:
Copy link
Member Author

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!)

@beaesguerra beaesguerra marked this pull request as ready for review February 5, 2025 23:39
@khan-actions-bot khan-actions-bot requested a review from a team February 5, 2025 23:39
@khan-actions-bot
Copy link
Contributor

Gerald

Required Reviewers
  • @Khan/frontend-infra for changes to package.json, yarn.lock, .changeset/quiet-snails-cheer.md, packages/eslint-config-khan/README.md, packages/eslint-config-khan/a11y.js, packages/eslint-config-khan/package.json

Don't want to be involved in this pull request? Comment #removeme and we won't notify you of further changes.

Copy link
Member

@marcysutton marcysutton left a 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.

Copy link
Contributor

@kevinb-khan kevinb-khan left a 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. 🎉

Comment on lines +39 to +70
// 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",
Copy link
Contributor

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?

Comment on lines 2 to +3
const ERROR = "error";
const OFF = "off";
Copy link
Contributor

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.

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

Successfully merging this pull request may close these issues.

4 participants