Repository navigation
chore(studio): add jsx-a11y ESLint ratchet rules for statically-detectable a11y issues - #47582
Conversation
…table a11y issues Adds 13 jsx-a11y rules (aria-props, aria-proptypes, role-supports-aria-props, anchor-has-content, control-has-associated-label, label-has-associated-control, aria-role, no-redundant-roles, no-aria-hidden-on-focusable, tabindex-no-positive, anchor-is-valid, heading-has-content, no-distracting-elements) at 'warn' and wires them into the existing ESLint ratchet, so new violations of the statically detectable subset of the FE-3781 axe-core audit findings fail CI while pre-existing ones are tracked and shrink over time. Resolves FE-3795
|
This pull request has been ignored for the connected project Preview Branches by Supabase. |
|
The latest updates on your projects. Learn more about Vercel for GitHub.
5 Skipped Deployments
|
📝 WalkthroughWalkthroughThis PR adds Changesjsx-a11y lint rule rollout
Estimated code review effort: 3 (Moderate) | ~20 minutes 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
apps/studio/eslint.config.cjs (1)
72-76: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winAdd
FormLabelto the jsx-a11y label list.Label/Inputare fine as-is, but the currentlabelComponentslist misses theFormLabelwrapper used throughout Studio, so those call sites won’t be checked bylabel-has-associated-control.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@apps/studio/eslint.config.cjs` around lines 72 - 76, Add FormLabel to the jsx-a11y label-has-associated-control configuration in the ESLint setup so Studio’s wrapped labels are actually checked; update the labelComponents list alongside the existing Label entry in the jsx-a11y rule config, leaving the current Input and Switch controlComponents unchanged.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@apps/studio/eslint.config.cjs`:
- Around line 72-76: Add FormLabel to the jsx-a11y label-has-associated-control
configuration in the ESLint setup so Studio’s wrapped labels are actually
checked; update the labelComponents list alongside the existing Label entry in
the jsx-a11y rule config, leaving the current Input and Switch controlComponents
unchanged.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 943360f7-d107-495e-a96f-be122ae7615e
📒 Files selected for processing (3)
apps/studio/.github/eslint-rule-baselines.jsonapps/studio/eslint.config.cjsapps/studio/package.json
🎭 Playwright Test ResultsDetails
Flaky testsFeatures › queue-table-operations.spec.ts › Queue Table Operations › pending changes persist when switching between tables Skipped testsFeatures › auth-users.spec.ts › should show web3 users as enabled when the matching web3 provider is enabled |
The lint:ratchet package.json script had grown into a single unreadable line of --rule flags. Adds a --rules-file flag to ratchet-eslint-rules.ts that reads rule ids from a JSON array (scripts/ratchet-rules.json), kept alongside the existing --rule flag for backward compatibility.
There was a problem hiding this comment.
🧹 Nitpick comments (2)
apps/studio/scripts/__tests__/ratchet-eslint-rules.test.ts (1)
86-107: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winAdd negative-path coverage for
readRulesFile.Only the happy path is tested.
readRulesFilehas three distinct failure branches (unreadable file, invalid JSON, non-array/non-string content) that all exit with code 2 — none are exercised here.As per path instructions, "PR adds a utility function without test coverage" should be flagged for
apps/studio/**.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@apps/studio/scripts/__tests__/ratchet-eslint-rules.test.ts` around lines 86 - 107, Add negative-path tests for readRulesFile in ratchet-eslint-rules.test.ts alongside the existing happy-path case. Cover the three failure branches in the readRulesFile flow: unreadable rules file, invalid JSON content, and valid JSON that is neither an array nor a string; each should cause invokeRatchet to exit with code 2. Use the existing invokeRatchet helper and the --rules-file path to keep the coverage close to the readRulesFile behavior.Source: Path instructions
apps/studio/scripts/ratchet-eslint-rules.ts (1)
73-96: 🎯 Functional Correctness | 🔵 Trivial | 💤 Low valueMinor inconsistency: no trim/filter on parsed rule IDs.
The
--ruleflag path trims and filters blank entries (Lines 119-127), butreadRulesFilereturns array entries unmodified. Sincescripts/ratchet-rules.jsonis a small, dev-maintained file, the practical risk is low.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@apps/studio/scripts/ratchet-eslint-rules.ts` around lines 73 - 96, The parsed rule IDs from readRulesFile should be normalized the same way as the --rule path in ratchet-eslint-rules.ts. Update readRulesFile to trim each string entry and filter out blank values before returning, so the behavior matches the existing handling in the rule parsing logic and stays consistent for the callers of readRulesFile.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@apps/studio/scripts/__tests__/ratchet-eslint-rules.test.ts`:
- Around line 86-107: Add negative-path tests for readRulesFile in
ratchet-eslint-rules.test.ts alongside the existing happy-path case. Cover the
three failure branches in the readRulesFile flow: unreadable rules file, invalid
JSON content, and valid JSON that is neither an array nor a string; each should
cause invokeRatchet to exit with code 2. Use the existing invokeRatchet helper
and the --rules-file path to keep the coverage close to the readRulesFile
behavior.
In `@apps/studio/scripts/ratchet-eslint-rules.ts`:
- Around line 73-96: The parsed rule IDs from readRulesFile should be normalized
the same way as the --rule path in ratchet-eslint-rules.ts. Update readRulesFile
to trim each string entry and filter out blank values before returning, so the
behavior matches the existing handling in the rule parsing logic and stays
consistent for the callers of readRulesFile.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: eb48d8b5-5c38-462f-a058-469e88927c17
📒 Files selected for processing (4)
apps/studio/package.jsonapps/studio/scripts/__tests__/ratchet-eslint-rules.test.tsapps/studio/scripts/ratchet-eslint-rules.tsapps/studio/scripts/ratchet-rules.json
Braintrust eval report
|
Summary
jsx-a11yrules toapps/studio/eslint.config.cjsat'warn':aria-props,aria-proptypes,role-supports-aria-props,anchor-has-content,control-has-associated-label(controlComponents: ['Button', 'Switch']),label-has-associated-control(labelComponents: ['Label'],controlComponents: ['Input', 'Switch']),aria-role,no-redundant-roles,no-aria-hidden-on-focusable,tabindex-no-positive,anchor-is-valid,heading-has-content,no-distracting-elements.lint:ratchetscript and initializes their baselines inapps/studio/.github/eslint-rule-baselines.json, so any new violation failsstudio-lint-ratchet.ymlwhile the pre-existing ones (mostlycontrol-has-associated-label: 274,label-has-associated-control: 37) are tracked and shrink over time via the weekly baseline-decrease cron.Resolves FE-3795.
Test plan
pnpm --filter studio run lint:ratchetpasses (exit 0, no regressions)AIAssistantChatSelector.tsx, an empty<h3>inPITRForm.tsx)studio-lint-ratchet.yml, typecheck.yml lint step) green on this PRSummary by CodeRabbit
rules-fileinstead of a long inline command.rules-file.