Skip to content

armgit / dify

Public Imported from GitHub
0

Build Agentic workflows, RAG pipelines, with rich AI model and tool support on one collaborative workspace. Deploy on cloud, VPC, or self-hosted, so teams move from prototype to production without rebuilding the stack.

feat: support accessibility checks in CI (#40137)

Joelb439b6a8008e
diff --git a/.github/workflows/accessibility-e2e.yml b/.github/workflows/accessibility-e2e.yml
new file mode 100644
index 00000000000..03a41f587ea
--- /dev/null
+++ b/.github/workflows/accessibility-e2e.yml
@@ -0,0 +1,101 @@
+name: Manual WCAG Accessibility Audit
+run-name: WCAG ${{ inputs.level }} · ${{ inputs.page }}
+
+on:
+ workflow_dispatch:
+ inputs:
+ page:
+ description: Page to scan
+ required: true
+ default: home
+ type: choice
+ options:
+ - home
+ - sign-in
+ - studio
+ - agents
+ - knowledge
+ - integrations
+ - all
+ level:
+ description: WCAG level to scan
+ required: true
+ default: aa
+ type: choice
+ options:
+ - aa
+ - a
+
+permissions:
+ contents: read
+
+concurrency:
+ group: accessibility-e2e-${{ github.ref }}-${{ inputs.page }}-${{ inputs.level }}
+ cancel-in-progress: true
+
+jobs:
+ accessibility:
+ name: WCAG Level ${{ inputs.level == 'a' && 'A' || 'AA' }} · ${{ inputs.page }}
+ runs-on: depot-ubuntu-24.04-4
+ timeout-minutes: 120
+ defaults:
+ run:
+ shell: bash
+
+ steps:
+ - name: Checkout code
+ uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
+ with:
+ persist-credentials: false
+
+ - name: Setup web dependencies
+ uses: ./.github/actions/setup-web
+
+ - name: Setup UV and Python
+ uses: astral-sh/setup-uv@c771a70e6277c0a99b617c7a806ffedaca235ff9 # v9.0.0
+ with:
+ enable-cache: true
+ python-version: '3.12'
+ cache-dependency-glob: |
+ api/uv.lock
+
+ - name: Install API dependencies
+ run: uv sync --project api --dev
+
+ - name: Install Chromium for accessibility E2E
+ timeout-minutes: 15
+ working-directory: ./e2e
+ run: vp run e2e:install:ci:chromium
+
+ - name: Run automated WCAG Level ${{ inputs.level == 'a' && 'A' || 'AA' }} checks
+ working-directory: ./e2e
+ env:
+ E2E_ADMIN_EMAIL: [email protected]
+ E2E_ADMIN_NAME: E2E Admin
+ E2E_ADMIN_PASSWORD: E2eAdmin12345
+ E2E_FORCE_WEB_BUILD: '1'
+ E2E_INIT_PASSWORD: E2eInit12345
+ WCAG_PAGE: ${{ inputs.page }}
+ run: |
+ if [[ "$WCAG_PAGE" == "all" ]]; then
+ vp run e2e:accessibility:${{ inputs.level }}
+ else
+ pnpm exec tsx ./scripts/run-cucumber.ts --full -- --tags "@axe and @wcag-${{ inputs.level }} and @wcag-page-$WCAG_PAGE"
+ fi
+
+ - name: Upload accessibility Cucumber report
+ if: ${{ !cancelled() }}
+ uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
+ with:
+ name: cucumber-report-accessibility-${{ inputs.level }}-${{ inputs.page }}
+ path: e2e/cucumber-report
+ retention-days: 7
+
+ - name: Upload accessibility E2E logs
+ if: ${{ !cancelled() }}
+ uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
+ with:
+ name: e2e-logs-accessibility-${{ inputs.level }}-${{ inputs.page }}
+ path: e2e/.logs/*.log
+ include-hidden-files: true
+ retention-days: 7
diff --git a/e2e/AGENTS.md b/e2e/AGENTS.md
index a57fd687696..fd10b188b1a 100644
--- a/e2e/AGENTS.md
+++ b/e2e/AGENTS.md
@@ -7,6 +7,9 @@ This package contains Dify's repository-level Cucumber scenarios with Playwright
Run commands from the repository root. Install dependencies and browsers once with `pnpm install` and `pnpm -C e2e e2e:install`. Run only one local `pnpm -C e2e e2e*` process at a time because runners share ports, auth state, and log paths.
- Existing initialized instance: `pnpm -C e2e e2e`
+- Standalone automated WCAG Level A scan: `pnpm -C e2e e2e:accessibility:a`
+- Standalone automated WCAG Level AA scan: `pnpm -C e2e e2e:accessibility:aa`
+- One-page automated WCAG scan: `pnpm -C e2e exec tsx ./scripts/run-cucumber.ts --full -- --tags "@axe and @wcag-a and @wcag-page-studio"` (replace the level and page tag as needed)
- Reset, initialize, and run deterministic scenarios: `pnpm -C e2e e2e:full`
- Prepare and run scenarios backed by shared fixtures: `E2E_START_AGENT_BACKEND=1 pnpm -C e2e e2e:prepared`
- Tagged subset: `pnpm -C e2e e2e -- --tags @smoke`
@@ -36,6 +39,7 @@ An uninitialized instance is installed and authenticated lazily; an initialized
## Tags And External Runtime
- Default scenarios use shared authenticated storage state. `@unauthenticated` creates a clean context; `@authenticated` is an intent and selection tag only.
+- `@axe` identifies standalone automated WCAG scans and is excluded from the default functional suite and normal CI commands. `@wcag-a` and `@wcag-aa` qualify the independent level-specific scans, and commands selecting either level must also select `@axe`. Page selectors use `@wcag-page-<slug>` and are attached to the matching Examples blocks under `features/accessibility/`. The accessibility workflow is an opt-in manual audit rather than a regression gate. The PR author should run the AA/all path before merge when changing the audit workflow, page matrix, or readiness contracts.
- `@prepared` requires the prepared fixtures; the post-merge seed profile includes them.
- `@external-model` and `@external-tool` identify scenarios that call real external runtimes. Deterministic commands exclude these tags; external commands are opt-in.
- `@microphone` uses the checked-in fake audio fixture and an isolated Chromium context.
diff --git a/e2e/cucumber.config.ts b/e2e/cucumber.config.ts
index edf96d3a0e2..81fbcacb7e2 100644
--- a/e2e/cucumber.config.ts
+++ b/e2e/cucumber.config.ts
@@ -2,7 +2,8 @@ import type { IConfiguration } from '@cucumber/cucumber'
import './scripts/env-register'
const hasCliTags = process.argv.some((arg) => arg === '--tags' || arg.startsWith('--tags='))
-const defaultNonExternalTags = 'not @prepared and not @external-model and not @external-tool'
+const defaultNonExternalTags =
+ 'not @axe and not @prepared and not @external-model and not @external-tool'
const defaultTags =
process.env.E2E_CUCUMBER_TAGS || (hasCliTags ? undefined : defaultNonExternalTags)
diff --git a/e2e/features/accessibility/main-pages.feature b/e2e/features/accessibility/main-pages.feature
new file mode 100644
index 00000000000..4ae6a71f8e1
--- /dev/null
+++ b/e2e/features/accessibility/main-pages.feature
@@ -0,0 +1,59 @@
+@accessibility @axe @authenticated
+Feature: Main page automated WCAG checks
+ Axe checks only automatically detectable issues and does not establish WCAG conformance.
+
+ Scenario Outline: <page> page has no automatically detectable WCAG Level <level> violations
+ Given I am signed in as the default E2E admin
+ When I open the "<page>" main page
+ Then I should be on the "<page>" main page
+ And the current page should have no automatically detectable WCAG Level <level> violations
+
+ @wcag-a @wcag-page-agents
+ Examples: Agents at Level A
+ | page | level |
+ | Agents | A |
+
+ @wcag-aa @wcag-page-agents
+ Examples: Agents at Level AA
+ | page | level |
+ | Agents | AA |
+
+ @wcag-a @wcag-page-home
+ Examples: Home at Level A
+ | page | level |
+ | Home | A |
+
+ @wcag-aa @wcag-page-home
+ Examples: Home at Level AA
+ | page | level |
+ | Home | AA |
+
+ @wcag-a @wcag-page-integrations
+ Examples: Integrations at Level A
+ | page | level |
+ | Integrations | A |
+
+ @wcag-aa @wcag-page-integrations
+ Examples: Integrations at Level AA
+ | page | level |
+ | Integrations | AA |
+
+ @wcag-a @wcag-page-knowledge
+ Examples: Knowledge at Level A
+ | page | level |
+ | Knowledge | A |
+
+ @wcag-aa @wcag-page-knowledge
+ Examples: Knowledge at Level AA
+ | page | level |
+ | Knowledge | AA |
+
+ @wcag-a @wcag-page-studio
+ Examples: Studio at Level A
+ | page | level |
+ | Studio | A |
+
+ @wcag-aa @wcag-page-studio
+ Examples: Studio at Level AA
+ | page | level |
+ | Studio | AA |
diff --git a/e2e/features/accessibility/sign-in.feature b/e2e/features/accessibility/sign-in.feature
new file mode 100644
index 00000000000..3080229ef01
--- /dev/null
+++ b/e2e/features/accessibility/sign-in.feature
@@ -0,0 +1,19 @@
+@accessibility @axe @unauthenticated
+Feature: Sign-in page automated WCAG checks
+ Axe checks only automatically detectable issues and does not establish WCAG conformance.
+
+ Scenario Outline: Sign-in page has no automatically detectable WCAG Level <level> violations
+ Given I am not signed in
+ When I open the sign-in page
+ Then I should see the "Sign in" button
+ And the current page should have no automatically detectable WCAG Level <level> violations
+
+ @wcag-a @wcag-page-sign-in
+ Examples: Level A
+ | level |
+ | A |
+
+ @wcag-aa @wcag-page-sign-in
+ Examples: Level AA
+ | level |
+ | AA |
diff --git a/e2e/features/step-definitions/accessibility/axe.steps.ts b/e2e/features/step-definitions/accessibility/axe.steps.ts
new file mode 100644
index 00000000000..12bbe95d01a
--- /dev/null
+++ b/e2e/features/step-definitions/accessibility/axe.steps.ts
@@ -0,0 +1,69 @@
+import type { DifyWorld } from '../../support/world'
+import AxeBuilder from '@axe-core/playwright'
+import { Then } from '@cucumber/cucumber'
+import { expect } from '@playwright/test'
+
+type AxeResults = Awaited<ReturnType<AxeBuilder['analyze']>>
+type WcagLevel = 'A' | 'AA'
+
+const wcagTagsByLevel = {
+ A: ['wcag2a', 'wcag21a'],
+ AA: ['wcag2a', 'wcag2aa', 'wcag21a', 'wcag21aa', 'wcag22aa'],
+} satisfies Record<WcagLevel, string[]>
+
+const formatFindings = (findings: AxeResults['violations']) =>
+ findings
+ .map(
+ (violation) =>
+ `${violation.id} (${violation.impact ?? 'unknown impact'}): ${violation.help}\n${violation.helpUrl}\n${violation.nodes.map((node) => ` - ${node.target.join(' > ')}${node.failureSummary ? `\n ${node.failureSummary.replaceAll('\n', '\n ')}` : ''}`).join('\n')}`,
+ )
+ .join('\n\n')
+
+const checkCurrentPage = async (world: DifyWorld, level: WcagLevel) => {
+ const results = await new AxeBuilder({ page: world.getPage() })
+ .withTags(wcagTagsByLevel[level])
+ .analyze()
+ const formattedViolations = formatFindings(results.violations)
+ const formattedIncomplete = formatFindings(results.incomplete)
+
+ if (results.violations.length > 0) {
+ world.attach(
+ `WCAG Level ${level} violations for ${results.url}:\n\n${formattedViolations}`,
+ 'text/plain',
+ )
+ }
+
+ if (results.incomplete.length > 0) {
+ world.attach(
+ `WCAG Level ${level} items requiring manual review for ${results.url}:\n\n${formattedIncomplete}`,
+ 'text/plain',
+ )
+ }
+
+ if (results.violations.length > 0 || results.incomplete.length > 0)
+ world.attach(
+ JSON.stringify(
+ {
+ incomplete: results.incomplete,
+ level,
+ url: results.url,
+ violations: results.violations,
+ },
+ null,
+ 2,
+ ),
+ 'application/json',
+ )
+
+ expect(results.violations, formattedViolations).toEqual([])
+}
+
+Then(
+ 'the current page should have no automatically detectable WCAG Level {word} violations',
+ async function (this: DifyWorld, level: string) {
+ if (!Object.hasOwn(wcagTagsByLevel, level))
+ throw new Error(`Unsupported WCAG level "${level}". Expected A or AA.`)
+
+ await checkCurrentPage(this, level as WcagLevel)
+ },
+)
diff --git a/e2e/features/step-definitions/accessibility/navigation.steps.ts b/e2e/features/step-definitions/accessibility/navigation.steps.ts
new file mode 100644
index 00000000000..af37b1ca6d1
--- /dev/null
+++ b/e2e/features/step-definitions/accessibility/navigation.steps.ts
@@ -0,0 +1,42 @@
+import type { Page } from '@playwright/test'
+import type { DifyWorld } from '../../support/world'
+import { Then, When } from '@cucumber/cucumber'
+import { waitForAgentsConsole } from '../../../support/agents'
+import { waitForAppsConsole } from '../../../support/apps'
+import { waitForConsoleHome } from '../../../support/home'
+import { waitForModelProviderIntegrations } from '../../../support/integrations'
+import { waitForKnowledgeConsole } from '../../../support/knowledge'
+
+type AccessibilityPageConfig = {
+ path: string
+ waitUntilReady: (page: Page) => Promise<void>
+}
+
+const accessibilityPages = {
+ Agents: { path: '/agents', waitUntilReady: waitForAgentsConsole },
+ Home: { path: '/', waitUntilReady: waitForConsoleHome },
+ Integrations: {
+ path: '/integrations/model-provider',
+ waitUntilReady: waitForModelProviderIntegrations,
+ },
+ Knowledge: { path: '/datasets', waitUntilReady: waitForKnowledgeConsole },
+ Studio: { path: '/apps', waitUntilReady: waitForAppsConsole },
+} satisfies Record<string, AccessibilityPageConfig>
+
+const getAccessibilityPage = (pageName: string): AccessibilityPageConfig => {
+ const config = accessibilityPages[pageName as keyof typeof accessibilityPages]
+ if (!config)
+ throw new Error(
+ `Unknown accessibility page "${pageName}". Expected one of: ${Object.keys(accessibilityPages).join(', ')}.`,
+ )
+
+ return config
+}
+
+When('I open the {string} main page', async function (this: DifyWorld, pageName: string) {
+ await this.getPage().goto(getAccessibilityPage(pageName).path)
+})
+
+Then('I should be on the {string} main page', async function (this: DifyWorld, pageName: string) {
+ await getAccessibilityPage(pageName).waitUntilReady(this.getPage())
+})
diff --git a/e2e/package.json b/e2e/package.json
index 6b28fa5070b..f936f76f383 100644
--- a/e2e/package.json
+++ b/e2e/package.json
@@ -4,6 +4,9 @@
"type": "module",
"scripts": {
"e2e": "tsx ./scripts/run-cucumber.ts",
+ "e2e:accessibility": "pnpm run e2e:accessibility:aa",
+ "e2e:accessibility:a": "tsx ./scripts/run-cucumber.ts --full -- --tags \"@axe and @wcag-a\"",
+ "e2e:accessibility:aa": "tsx ./scripts/run-cucumber.ts --full -- --tags \"@axe and @wcag-aa\"",
"e2e:external": "tsx ./scripts/run-external-runtime.ts",
"e2e:external:prepare": "tsx ./scripts/run-cucumber.ts --seed-only --profile external-runtime",
"e2e:full": "tsx ./scripts/run-cucumber.ts --full",
@@ -24,6 +27,7 @@
"type-check": "tsc"
},
"devDependencies": {
+ "@axe-core/playwright": "catalog:",
"@cucumber/cucumber": "catalog:",
"@dify/contracts": "workspace:*",
"@dify/tsconfig": "workspace:*",
diff --git a/e2e/scripts/run-cucumber.ts b/e2e/scripts/run-cucumber.ts
index 145fab3db9d..74f93b6d2b3 100644
--- a/e2e/scripts/run-cucumber.ts
+++ b/e2e/scripts/run-cucumber.ts
@@ -15,7 +15,8 @@ import './env-register'
const hasCustomTags = (forwardArgs: string[]) =>
forwardArgs.some((arg) => arg === '--tags' || arg.startsWith('--tags='))
-const fullNonExternalTags = 'not @prepared and not @external-model and not @external-tool'
+const fullNonExternalTags =
+ 'not @axe and not @prepared and not @external-model and not @external-tool'
const seedCeleryQueues = 'dataset,priority_dataset,workflow_based_app_execution'
const readLogTail = async (logFilePath: string) => {
diff --git a/e2e/support/agents.ts b/e2e/support/agents.ts
new file mode 100644
index 00000000000..d5363f8ca21
--- /dev/null
+++ b/e2e/support/agents.ts
@@ -0,0 +1,20 @@
+import type { Page } from '@playwright/test'
+import { expect } from '@playwright/test'
+
+const getExpectOptions = (timeout?: number) => (timeout === undefined ? undefined : { timeout })
+
+export const waitForAgentsConsole = async (page: Page, timeout?: number) => {
+ const options = getExpectOptions(timeout)
+
+ await expect(page).toHaveURL(/\/agents(?:\?.*)?$/, options)
+ await expect(page.getByRole('link', { name: 'Agents', exact: true })).toHaveAttribute(
+ 'aria-current',
+ 'page',
+ options,
+ )
+ await expect(page.getByRole('heading', { name: 'Agents', exact: true })).toBeVisible(options)
+
+ const roster = page.getByRole('region', { name: 'Agent list' })
+ await expect(roster).toBeVisible(options)
+ await expect(roster).not.toHaveAttribute('aria-busy', 'true', options)
+}
diff --git a/e2e/support/apps.ts b/e2e/support/apps.ts
index 95f0687f647..c26033ee7de 100644
--- a/e2e/support/apps.ts
+++ b/e2e/support/apps.ts
@@ -8,6 +8,7 @@ export const waitForAppsConsole = async (page: Page, timeout?: number) => {
await expect(page).toHaveURL(/\/apps(?:\?.*)?$/, options)
await expect(page.getByRole('heading', { name: 'Studio' })).toBeVisible(options)
+ await expect(page.getByRole('status', { name: 'Loading' })).toBeHidden(options)
}
export const openBlankAppCreation = async (page: Page) => {
diff --git a/e2e/support/home.ts b/e2e/support/home.ts
index f6729eb277d..1f37ed184c9 100644
--- a/e2e/support/home.ts
+++ b/e2e/support/home.ts
@@ -6,10 +6,11 @@ const getExpectOptions = (timeout?: number) => (timeout === undefined ? undefine
export const waitForConsoleHome = async (page: Page, timeout?: number) => {
const options = getExpectOptions(timeout)
- await expect.poll(() => new URL(page.url()).pathname, options).toBe('/')
+ await expect(page).toHaveURL(/\/(?:\?.*)?$/, options)
await expect(page.getByRole('link', { name: 'Home' })).toHaveAttribute(
'aria-current',
'page',
options,
)
+ await expect(page.getByRole('heading', { name: 'Templates', exact: true })).toBeVisible(options)
}
diff --git a/e2e/support/integrations.ts b/e2e/support/integrations.ts
new file mode 100644
index 00000000000..37275a724bf
--- /dev/null
+++ b/e2e/support/integrations.ts
@@ -0,0 +1,16 @@
+import type { Page } from '@playwright/test'
+import { expect } from '@playwright/test'
+
+const getExpectOptions = (timeout?: number) => (timeout === undefined ? undefined : { timeout })
+
+export const waitForModelProviderIntegrations = async (page: Page, timeout?: number) => {
+ const options = getExpectOptions(timeout)
+
+ await expect(page).toHaveURL(/\/integrations\/model-provider(?:\?.*)?$/, options)
+ await expect(page.getByRole('link', { name: 'Integrations', exact: true })).toHaveAttribute(
+ 'aria-current',
+ 'page',
+ options,
+ )
+ await expect(page.getByRole('region', { name: 'Model Provider' })).toBeVisible(options)
+}
diff --git a/e2e/support/knowledge.ts b/e2e/support/knowledge.ts
new file mode 100644
index 00000000000..0a63bd33970
--- /dev/null
+++ b/e2e/support/knowledge.ts
@@ -0,0 +1,17 @@
+import type { Page } from '@playwright/test'
+import { expect } from '@playwright/test'
+
+const getExpectOptions = (timeout?: number) => (timeout === undefined ? undefined : { timeout })
+
+export const waitForKnowledgeConsole = async (page: Page, timeout?: number) => {
+ const options = getExpectOptions(timeout)
+
+ await expect(page).toHaveURL(/\/datasets(?:\?.*)?$/, options)
+ await expect(page.getByRole('link', { name: 'Knowledge', exact: true })).toHaveAttribute(
+ 'aria-current',
+ 'page',
+ options,
+ )
+ await expect(page.getByRole('heading', { name: 'Knowledge', exact: true })).toBeVisible(options)
+ await expect(page.getByRole('status', { name: 'Loading' })).toBeHidden(options)
+}
diff --git a/lint.config.ts b/lint.config.ts
index 367f6c55165..b8d7d7f9a04 100644
--- a/lint.config.ts
+++ b/lint.config.ts
@@ -1,3 +1,5 @@
+/// <reference types="node" />
+
import type { OxlintConfig } from 'vite-plus/lint'
import path from 'node:path'
@@ -20,6 +22,94 @@ const tailwindCanonicalClassesOverride = {
},
} satisfies NonNullable<OxlintConfig['overrides']>[number]
+export const webJsxA11yRules = {
+ 'jsx-a11y/alt-text': 'error',
+ 'jsx-a11y/anchor-ambiguous-text': 'off',
+ 'jsx-a11y/anchor-has-content': 'error',
+ 'jsx-a11y/anchor-is-valid': 'error',
+ 'jsx-a11y/aria-activedescendant-has-tabindex': 'error',
+ 'jsx-a11y/aria-props': 'error',
+ 'jsx-a11y/aria-proptypes': 'error',
+ 'jsx-a11y/aria-role': 'error',
+ 'jsx-a11y/aria-unsupported-elements': 'error',
+ 'jsx-a11y/autocomplete-valid': 'error',
+ 'jsx-a11y/click-events-have-key-events': 'error',
+ 'jsx-a11y/heading-has-content': 'error',
+ 'jsx-a11y/html-has-lang': 'error',
+ 'jsx-a11y/iframe-has-title': 'error',
+ 'jsx-a11y/img-redundant-alt': 'error',
+ 'jsx-a11y/interactive-supports-focus': [
+ 'error',
+ {
+ tabbable: ['button', 'checkbox', 'link', 'searchbox', 'spinbutton', 'switch', 'textbox'],
+ },
+ ],
+ 'jsx-a11y/label-has-associated-control': 'error',
+ 'jsx-a11y/media-has-caption': 'error',
+ 'jsx-a11y/mouse-events-have-key-events': 'error',
+ 'jsx-a11y/no-access-key': 'error',
+ 'jsx-a11y/no-autofocus': 'error',
+ 'jsx-a11y/no-distracting-elements': 'error',
+ 'jsx-a11y/no-interactive-element-to-noninteractive-role': [
+ 'error',
+ {
+ tr: ['none', 'presentation'],
+ canvas: ['img'],
+ },
+ ],
+ 'jsx-a11y/no-noninteractive-element-interactions': [
+ 'error',
+ {
+ handlers: [
+ 'onClick',
+ 'onError',
+ 'onLoad',
+ 'onMouseDown',
+ 'onMouseUp',
+ 'onKeyPress',
+ 'onKeyDown',
+ 'onKeyUp',
+ ],
+ alert: ['onKeyUp', 'onKeyDown', 'onKeyPress'],
+ body: ['onError', 'onLoad'],
+ dialog: ['onKeyUp', 'onKeyDown', 'onKeyPress'],
+ iframe: ['onError', 'onLoad'],
+ img: ['onError', 'onLoad'],
+ },
+ ],
+ 'jsx-a11y/no-noninteractive-element-to-interactive-role': [
+ 'error',
+ {
+ ul: ['listbox', 'menu', 'menubar', 'radiogroup', 'tablist', 'tree', 'treegrid'],
+ ol: ['listbox', 'menu', 'menubar', 'radiogroup', 'tablist', 'tree', 'treegrid'],
+ li: ['menuitem', 'menuitemradio', 'menuitemcheckbox', 'option', 'row', 'tab', 'treeitem'],
+ table: ['grid'],
+ td: ['gridcell'],
+ fieldset: ['radiogroup', 'presentation'],
+ },
+ ],
+ 'jsx-a11y/no-noninteractive-tabindex': [
+ 'error',
+ {
+ tags: [],
+ roles: ['tabpanel'],
+ allowExpressionValues: true,
+ },
+ ],
+ 'jsx-a11y/no-redundant-roles': 'error',
+ 'jsx-a11y/no-static-element-interactions': [
+ 'error',
+ {
+ allowExpressionValues: true,
+ handlers: ['onClick', 'onMouseDown', 'onMouseUp', 'onKeyPress', 'onKeyDown', 'onKeyUp'],
+ },
+ ],
+ 'jsx-a11y/role-has-required-aria-props': 'error',
+ 'jsx-a11y/role-supports-aria-props': 'error',
+ 'jsx-a11y/scope': 'error',
+ 'jsx-a11y/tabindex-no-positive': 'error',
+} satisfies NonNullable<OxlintConfig['rules']>
+
/**
* Oxlint equivalent of the ESLint configurations that were active before the migration.
* Keep rules explicit so changes in upstream presets do not silently alter the lint baseline.
@@ -694,109 +784,7 @@ export const lintConfig = {
},
{
files: ['web/**/*.tsx'],
- rules: {
- 'jsx-a11y/alt-text': 'error',
- 'jsx-a11y/anchor-ambiguous-text': 'off',
- 'jsx-a11y/anchor-has-content': 'error',
- 'jsx-a11y/anchor-is-valid': 'error',
- 'jsx-a11y/aria-activedescendant-has-tabindex': 'error',
- 'jsx-a11y/aria-props': 'error',
- 'jsx-a11y/aria-proptypes': 'error',
- 'jsx-a11y/aria-role': 'error',
- 'jsx-a11y/aria-unsupported-elements': 'error',
- 'jsx-a11y/autocomplete-valid': 'error',
- 'jsx-a11y/click-events-have-key-events': 'error',
- 'jsx-a11y/heading-has-content': 'error',
- 'jsx-a11y/html-has-lang': 'error',
- 'jsx-a11y/iframe-has-title': 'error',
- 'jsx-a11y/img-redundant-alt': 'error',
- 'jsx-a11y/interactive-supports-focus': [
- 'error',
- {
- tabbable: [
- 'button',
- 'checkbox',
- 'link',
- 'searchbox',
- 'spinbutton',
- 'switch',
- 'textbox',
- ],
- },
- ],
- 'jsx-a11y/label-has-associated-control': 'error',
- 'jsx-a11y/media-has-caption': 'error',
- 'jsx-a11y/mouse-events-have-key-events': 'error',
- 'jsx-a11y/no-access-key': 'error',
- 'jsx-a11y/no-autofocus': 'error',
- 'jsx-a11y/no-distracting-elements': 'error',
- 'jsx-a11y/no-interactive-element-to-noninteractive-role': [
- 'error',
- {
- tr: ['none', 'presentation'],
- canvas: ['img'],
- },
- ],
- 'jsx-a11y/no-noninteractive-element-interactions': [
- 'error',
- {
- handlers: [
- 'onClick',
- 'onError',
- 'onLoad',
- 'onMouseDown',
- 'onMouseUp',
- 'onKeyPress',
- 'onKeyDown',
- 'onKeyUp',
- ],
- alert: ['onKeyUp', 'onKeyDown', 'onKeyPress'],
- body: ['onError', 'onLoad'],
- dialog: ['onKeyUp', 'onKeyDown', 'onKeyPress'],
- iframe: ['onError', 'onLoad'],
- img: ['onError', 'onLoad'],
- },
- ],
- 'jsx-a11y/no-noninteractive-element-to-interactive-role': [
- 'error',
- {
- ul: ['listbox', 'menu', 'menubar', 'radiogroup', 'tablist', 'tree', 'treegrid'],
- ol: ['listbox', 'menu', 'menubar', 'radiogroup', 'tablist', 'tree', 'treegrid'],
- li: [
- 'menuitem',
- 'menuitemradio',
- 'menuitemcheckbox',
- 'option',
- 'row',
- 'tab',
- 'treeitem',
- ],
- table: ['grid'],
- td: ['gridcell'],
- fieldset: ['radiogroup', 'presentation'],
- },
- ],
- 'jsx-a11y/no-noninteractive-tabindex': [
- 'error',
- {
- tags: [],
- roles: ['tabpanel'],
- allowExpressionValues: true,
- },
- ],
- 'jsx-a11y/no-redundant-roles': 'error',
- 'jsx-a11y/no-static-element-interactions': [
- 'error',
- {
- allowExpressionValues: true,
- handlers: ['onClick', 'onMouseDown', 'onMouseUp', 'onKeyPress', 'onKeyDown', 'onKeyUp'],
- },
- ],
- 'jsx-a11y/role-has-required-aria-props': 'error',
- 'jsx-a11y/role-supports-aria-props': 'error',
- 'jsx-a11y/scope': 'error',
- 'jsx-a11y/tabindex-no-positive': 'error',
- },
+ rules: webJsxA11yRules,
},
{
files: ['web/**/*.stories.{js,cjs,mjs,jsx,ts,tsx}', 'web/**/*.story.{js,cjs,mjs,jsx,ts,tsx}'],
diff --git a/package.json b/package.json
index 8302ae8ca50..736d6afac10 100644
--- a/package.json
+++ b/package.json
@@ -26,6 +26,7 @@
"@iconify-json/heroicons": "catalog:",
"@iconify-json/ri": "catalog:",
"@tanstack/eslint-plugin-query": "catalog:",
+ "@types/node": "catalog:",
"@typescript-eslint/parser": "catalog:",
"@typescript/native": "catalog:",
"concurrently": "catalog:",
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index a001d73a85e..a142f579fed 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -12,6 +12,9 @@ catalogs:
'@amplitude/plugin-session-replay-browser':
specifier: 1.33.7
version: 1.33.7
+ '@axe-core/playwright':
+ specifier: 4.12.1
+ version: 4.12.1
'@base-ui/react':
specifier: 1.7.0
version: 1.7.0
@@ -677,6 +680,9 @@ importers:
'@tanstack/eslint-plugin-query':
specifier: 'catalog:'
+ '@types/node':
+ specifier: 'catalog:'
+ version: 25.9.5
'@typescript-eslint/parser':
specifier: 'catalog:'
@@ -697,7 +703,7 @@ importers:
eslint-plugin-better-tailwindcss:
specifier: 'catalog:'
eslint-plugin-command:
specifier: 'catalog:'
@@ -733,7 +739,7 @@ importers:
eslint-plugin-storybook:
specifier: 'catalog:'
eslint-plugin-toml:
specifier: 'catalog:'
@@ -754,10 +760,10 @@ importers:
version: '@typescript/[email protected]'
vite:
specifier: npm:@voidzero-dev/[email protected]
vite-plus:
specifier: 'catalog:'
cli:
dependencies:
@@ -843,6 +849,9 @@ importers:
e2e:
devDependencies:
+ '@axe-core/playwright':
+ specifier: 'catalog:'
+ version: 4.12.1([email protected])
'@cucumber/cucumber':
specifier: 'catalog:'
version: 13.2.1
@@ -977,7 +986,7 @@ importers:
'@chromatic-com/storybook':
specifier: 'catalog:'
'@dify/tsconfig':
specifier: workspace:*
version: link:../tsconfig
@@ -989,22 +998,22 @@ importers:
version: 1.2.10
'@storybook/addon-a11y':
specifier: 'catalog:'
'@storybook/addon-docs':
specifier: 'catalog:'
'@storybook/addon-links':
specifier: 'catalog:'
'@storybook/addon-themes':
specifier: 'catalog:'
'@storybook/addon-vitest':
specifier: 'catalog:'
'@storybook/react-vite':
specifier: 'catalog:'
'@tailwindcss/vite':
specifier: 'catalog:'
@@ -1049,7 +1058,7 @@ importers:
version: 19.2.8([email protected])
storybook:
specifier: 'catalog:'
tailwindcss:
specifier: 'catalog:'
version: 4.3.3
@@ -1061,7 +1070,7 @@ importers:
vite-plus:
specifier: 'catalog:'
vitest:
specifier: 'catalog:'
@@ -1100,7 +1109,7 @@ importers:
vite-plus:
specifier: 'catalog:'
vitest:
specifier: 'catalog:'
@@ -1747,6 +1756,11 @@ packages:
resolution: {integrity: sha512-Mex9nXf9vR6AhcXmMrlz/HVgYYZpVGJ6YlPgwl7UnaFpnshXs6EK/oa5Gpf3CzENMjkvEx2tQtntGnb7UtSTOQ==}
+ '@axe-core/[email protected]':
+ resolution: {integrity: sha512-rMd7xriptqKpP+w5265i4Hdkv2X5kbu6uiBi/B2I7uf3hieRBM3qDCfaKPtxfiYb2mKXfF+yLODJwIx+Jv1GDw==}
+ peerDependencies:
+ playwright-core: '>= 1.0.0'
+
resolution: {integrity: sha512-Aup7aUOfpbAUg2ROOJN6Iw5f9DMBlzu0mIkm/malLQFN/YQgO48wCj0Kxa3sEHJvPVFg7siR+qRInwXd2qhQKw==}
engines: {node: '>=6.9.0'}
@@ -9381,6 +9395,11 @@ snapshots:
'@antfu/[email protected]': {}
+ dependencies:
+ axe-core: 4.12.1
+ playwright-core: 1.62.1
+
dependencies:
'@babel/helper-validator-identifier': 7.29.7
@@ -9526,12 +9545,12 @@ snapshots:
- '@chromatic-com/playwright'
- '@chromatic-com/vitest'
dependencies:
'@neoconfetti/react': 1.0.0
chromatic: 16.10.0
jsonfile: 6.2.1
strip-ansi: 7.2.0
transitivePeerDependencies:
- '@chromatic-com/cypress'
@@ -11321,11 +11340,11 @@ snapshots:
'@standard-schema/[email protected]': {}
dependencies:
'@storybook/global': 5.0.0
axe-core: 4.12.1
dependencies:
@@ -11346,15 +11365,15 @@ snapshots:
- vite
- webpack
dependencies:
'@mdx-js/react': 3.1.1(@types/[email protected])([email protected])
'@storybook/icons': 2.1.0([email protected])
react: 19.2.8
react-dom: 19.2.8([email protected])
ts-dedent: 2.3.0
optionalDependencies:
'@types/react': 19.2.18
@@ -11373,10 +11392,10 @@ snapshots:
'@types/react': 19.2.18
react: 19.2.8
dependencies:
'@storybook/global': 5.0.0
optionalDependencies:
'@types/react': 19.2.18
react: 19.2.8
@@ -11390,16 +11409,16 @@ snapshots:
ts-dedent: 2.3.0
dependencies:
ts-dedent: 2.3.0
dependencies:
'@storybook/global': 5.0.0
'@storybook/icons': 2.1.0([email protected])
optionalDependencies:
@@ -11419,10 +11438,10 @@ snapshots:
- rollup
- webpack
dependencies:
ts-dedent: 2.3.0
transitivePeerDependencies:
@@ -11438,9 +11457,9 @@ snapshots:
esbuild: 0.28.1
dependencies:
unplugin: 2.3.11
optionalDependencies:
esbuild: 0.28.1
@@ -11485,11 +11504,11 @@ snapshots:
'@types/react': 19.2.18
'@types/react-dom': 19.2.4(@types/[email protected])
dependencies:
react: 19.2.8
react-dom: 19.2.8([email protected])
optionalDependencies:
'@types/react': 19.2.18
'@types/react-dom': 19.2.4(@types/[email protected])
@@ -11519,19 +11538,19 @@ snapshots:
- supports-color
- webpack
dependencies:
'@joshwooding/vite-plugin-react-docgen-typescript': 0.7.0(@typescript/[email protected])(@voidzero-dev/[email protected](@types/[email protected])(@typescript/[email protected])([email protected])([email protected])([email protected])([email protected]))
'@rollup/pluginutils': 5.4.0
empathic: 2.0.1
magic-string: 0.30.21
react: 19.2.8
react-docgen: 8.0.3([email protected])
react-dom: 19.2.8([email protected])
resolve: 1.22.12
tsconfig-paths: 4.2.0
optionalDependencies:
@@ -11560,15 +11579,15 @@ snapshots:
transitivePeerDependencies:
- supports-color
dependencies:
'@storybook/global': 5.0.0
react: 19.2.8
react-docgen: 8.0.3([email protected])
react-docgen-typescript: 2.4.0(@typescript/[email protected])
react-dom: 19.2.8([email protected])
optionalDependencies:
'@types/react': 19.2.18
'@types/react-dom': 19.2.4(@types/[email protected])
@@ -12598,9 +12617,9 @@ snapshots:
obug: 2.1.3
std-env: 4.1.0
tinyrainbow: 3.1.0
optionalDependencies:
'@vitest/[email protected]':
dependencies:
@@ -13781,7 +13800,7 @@ snapshots:
dependencies:
dependencies:
'@eslint/css-tree': 4.0.5
'@valibot/to-json-schema': 1.7.1([email protected](@typescript/[email protected]))
@@ -13794,7 +13813,7 @@ snapshots:
valibot: 1.4.2(@typescript/[email protected])
optionalDependencies:
transitivePeerDependencies:
- '@eslint/css'
- typescript
@@ -14030,12 +14049,12 @@ snapshots:
regexp-ast-analysis: 0.7.1
scslre: 0.3.0
dependencies:
'@typescript-eslint/types': 8.65.0
transitivePeerDependencies:
- supports-color
- typescript
@@ -15877,7 +15896,7 @@ snapshots:
'@oxfmt/binding-win32-x64-msvc': 0.61.0
dependencies:
tinypool: 2.1.0
optionalDependencies:
@@ -15900,9 +15919,9 @@ snapshots:
'@oxfmt/binding-win32-arm64-msvc': 0.61.0
'@oxfmt/binding-win32-ia32-msvc': 0.61.0
'@oxfmt/binding-win32-x64-msvc': 0.61.0
dependencies:
tinypool: 2.1.0
optionalDependencies:
@@ -15925,7 +15944,7 @@ snapshots:
'@oxfmt/binding-win32-arm64-msvc': 0.61.0
'@oxfmt/binding-win32-ia32-msvc': 0.61.0
'@oxfmt/binding-win32-x64-msvc': 0.61.0
optionalDependencies:
@@ -15960,7 +15979,7 @@ snapshots:
oxlint-tsgolint: 7.0.2001
optionalDependencies:
'@oxlint/binding-android-arm-eabi': 1.76.0
'@oxlint/binding-android-arm64': 1.76.0
@@ -15982,9 +16001,9 @@ snapshots:
'@oxlint/binding-win32-ia32-msvc': 1.76.0
'@oxlint/binding-win32-x64-msvc': 1.76.0
oxlint-tsgolint: 7.0.2001
optionalDependencies:
'@oxlint/binding-android-arm-eabi': 1.76.0
'@oxlint/binding-android-arm64': 1.76.0
@@ -16006,7 +16025,7 @@ snapshots:
'@oxlint/binding-win32-ia32-msvc': 1.76.0
'@oxlint/binding-win32-x64-msvc': 1.76.0
oxlint-tsgolint: 7.0.2001
dependencies:
@@ -16834,7 +16853,7 @@ snapshots:
- react
- utf-8-validate
dependencies:
'@storybook/global': 5.0.0
'@storybook/icons': 2.1.0([email protected])
@@ -16855,7 +16874,7 @@ snapshots:
ws: 8.21.2
optionalDependencies:
'@types/react': 19.2.18
transitivePeerDependencies:
- bufferutil
- react
@@ -17428,26 +17447,26 @@ snapshots:
- vite
- yaml
dependencies:
'@oxc-project/types': 0.142.0
'@oxlint/plugins': 1.73.0
'@vitest/expect': 4.1.10
'@vitest/pretty-format': 4.1.10
'@vitest/runner': 4.1.10
'@vitest/snapshot': 4.1.10
'@vitest/spy': 4.1.10
'@vitest/utils': 4.1.10
oxlint-tsgolint: 7.0.2001
optionalDependencies:
'@voidzero-dev/vite-plus-darwin-arm64': 0.2.8
'@voidzero-dev/vite-plus-darwin-x64': 0.2.8
'@voidzero-dev/vite-plus-linux-arm64-gnu': 0.2.8
@@ -17487,26 +17506,26 @@ snapshots:
- vite
- yaml
dependencies:
'@oxc-project/types': 0.142.0
'@oxlint/plugins': 1.73.0
'@vitest/expect': 4.1.10
'@vitest/pretty-format': 4.1.10
'@vitest/runner': 4.1.10
'@vitest/snapshot': 4.1.10
'@vitest/spy': 4.1.10
'@vitest/utils': 4.1.10
oxlint-tsgolint: 7.0.2001
optionalDependencies:
'@voidzero-dev/vite-plus-darwin-arm64': 0.2.8
'@voidzero-dev/vite-plus-darwin-x64': 0.2.8
'@voidzero-dev/vite-plus-linux-arm64-gnu': 0.2.8
@@ -17638,6 +17657,37 @@ snapshots:
transitivePeerDependencies:
- msw
+ dependencies:
+ '@vitest/expect': 4.1.10
+ '@vitest/pretty-format': 4.1.10
+ '@vitest/runner': 4.1.10
+ '@vitest/snapshot': 4.1.10
+ '@vitest/spy': 4.1.10
+ '@vitest/utils': 4.1.10
+ es-module-lexer: 2.3.1
+ expect-type: 1.4.0
+ magic-string: 0.30.21
+ obug: 2.1.3
+ pathe: 2.0.3
+ picomatch: 4.0.5
+ std-env: 4.1.0
+ tinybench: 2.9.0
+ tinyexec: 1.2.4
+ tinyglobby: 0.2.17
+ tinyrainbow: 3.1.0
+ why-is-node-running: 2.3.0
+ optionalDependencies:
+ '@types/node': 25.9.5
+ '@vitest/coverage-v8': 4.1.10(@vitest/[email protected])([email protected])
+ happy-dom: 20.11.1
+ transitivePeerDependencies:
+ - msw
+
dependencies:
'@vitest/expect': 4.1.10
@@ -17837,6 +17887,7 @@ snapshots:
time:
'@amplitude/[email protected]': '2026-07-28T17:38:31.802Z'
'@amplitude/[email protected]': '2026-07-28T17:39:09.673Z'
+ '@axe-core/[email protected]': '2026-06-23T15:31:17.929Z'
'@base-ui/[email protected]': '2026-08-04T09:55:20.089Z'
'@chromatic-com/[email protected]': '2026-05-14T07:49:29.364Z'
'@cucumber/[email protected]': '2026-08-04T07:20:28.681Z'
diff --git a/pnpm-workspace.yaml b/pnpm-workspace.yaml
index 279f960ad8e..8e105591abe 100644
--- a/pnpm-workspace.yaml
+++ b/pnpm-workspace.yaml
@@ -52,6 +52,7 @@ overrides:
catalog:
'@amplitude/analytics-browser': 2.45.5
'@amplitude/plugin-session-replay-browser': 1.33.7
+ '@axe-core/playwright': 4.12.1
'@base-ui/react': 1.7.0
'@chromatic-com/storybook': 5.2.1
'@cucumber/cucumber': 13.2.1
diff --git a/web/docs/lint.md b/web/docs/lint.md
index b6349080fc4..94490295e2a 100644
--- a/web/docs/lint.md
+++ b/web/docs/lint.md
@@ -25,6 +25,23 @@ vp check web/app/components packages/dify-ui/src/button
vp check --fix web/app/components packages/dify-ui/src/button
```
+Run only the Web JSX accessibility rules for selected files or directories with
+`lint:a11y`. Quote paths that contain shell metacharacters such as parentheses:
+
+```sh
+pnpm --dir web lint:a11y 'app/(commonLayout)/app/(appDetailLayout)/layout.tsx'
+```
+
+Use dependency mode to resolve an entry file's transitive local imports, including path aliases,
+re-exports, and dynamic imports, and then lint the resulting JSX and TSX files:
+
+```sh
+pnpm --dir web lint:a11y --deps 'app/(commonLayout)/app/(appDetailLayout)/layout.tsx'
+```
+
+This is a local page-scoped diagnostic. The repository-wide accessibility rule baseline remains
+owned by `lint.config.ts` and is also enforced by the normal `vp check` path.
+
Run the ESLint fallback separately when targeting JSON, JSONC, JSON5, YAML, TOML, or Markdown:
```sh
diff --git a/web/package.json b/web/package.json
index f0926746cb2..29de1656627 100644
--- a/web/package.json
+++ b/web/package.json
@@ -22,6 +22,7 @@
"i18n:check": "tsx ./scripts/check-i18n.js",
"i18n:migrate-selectors": "tsx ./scripts/migrate-i18n-selectors.ts",
"i18n:prune-unused": "tsx ./scripts/prune-unused-i18n.ts",
+ "lint:a11y": "node ./scripts/lint-a11y.mjs",
"lint:tss": "tsslint --project tsconfig.json",
"preinstall": "npx only-allow pnpm",
"start": "node ./scripts/copy-and-start.mjs",
diff --git a/web/scripts/a11y/oxlint.config.ts b/web/scripts/a11y/oxlint.config.ts
new file mode 100644
index 00000000000..7a102d810a3
--- /dev/null
+++ b/web/scripts/a11y/oxlint.config.ts
@@ -0,0 +1,10 @@
+import type { OxlintConfig } from 'vite-plus/lint'
+import { webJsxA11yRules } from '../../../lint.config.ts'
+
+export default {
+ categories: {
+ correctness: 'off',
+ },
+ plugins: ['jsx-a11y'],
+ rules: webJsxA11yRules,
+} satisfies OxlintConfig
diff --git a/web/scripts/lint-a11y.mjs b/web/scripts/lint-a11y.mjs
new file mode 100644
index 00000000000..5044ef1527d
--- /dev/null
+++ b/web/scripts/lint-a11y.mjs
@@ -0,0 +1,202 @@
+import { spawnSync } from 'node:child_process'
+import fs from 'node:fs'
+import { createRequire } from 'node:module'
+import path from 'node:path'
+import process from 'node:process'
+import ts from 'typescript'
+
+const webRoot = path.resolve(import.meta.dirname, '..')
+const repositoryRoot = path.resolve(webRoot, '..')
+const configPath = path.resolve(import.meta.dirname, 'a11y', 'oxlint.config.ts')
+const require = createRequire(import.meta.url)
+const vitePlusRequire = createRequire(require.resolve('vite-plus/package.json'))
+const oxlintPackageDirectory = path.dirname(vitePlusRequire.resolve('oxlint/package.json'))
+const oxlintEntry = path.resolve(oxlintPackageDirectory, 'bin', 'oxlint')
+const inputArguments = process.argv.slice(2)
+const dependencyMode = inputArguments.includes('--deps')
+const inputTargets = inputArguments.filter((argument) => argument !== '--deps')
+
+function printUsage() {
+ console.error(`Usage:
+ pnpm lint:a11y <page-file-or-directory> [...]
+ pnpm lint:a11y --deps <entry-file> [...]`)
+}
+
+if (inputTargets.length === 0) {
+ printUsage()
+ process.exit(2)
+}
+
+const unsupportedOption = inputTargets.find((target) => target.startsWith('-'))
+
+if (unsupportedOption) {
+ console.error(`Unknown option: ${unsupportedOption}`)
+ printUsage()
+ process.exit(2)
+}
+
+const resolvedTargets = inputTargets.map((target) => {
+ if (path.isAbsolute(target)) return target
+
+ if (target === 'web' || target.startsWith('web/') || target.startsWith('web\\'))
+ return path.resolve(repositoryRoot, target)
+
+ return path.resolve(webRoot, target)
+})
+
+const sourceExtensions = new Set(['.cjs', '.cts', '.js', '.jsx', '.mjs', '.mts', '.ts', '.tsx'])
+const jsxExtensions = new Set(['.jsx', '.tsx'])
+const ignoredDirectories = new Set([
+ '.next',
+ '.vinext',
+ 'coverage',
+ 'dist',
+ 'node_modules',
+ 'storybook-static',
+])
+
+function isWithinWebRoot(filePath) {
+ const relativePath = path.relative(webRoot, filePath)
+ return relativePath !== '' && !relativePath.startsWith('..') && !path.isAbsolute(relativePath)
+}
+
+function isTraversableSourceFile(filePath) {
+ if (!isWithinWebRoot(filePath) || !sourceExtensions.has(path.extname(filePath))) return false
+ if (/\.d\.[cm]?ts$/u.test(filePath)) return false
+
+ return !path
+ .relative(webRoot, filePath)
+ .split(path.sep)
+ .some((segment) => ignoredDirectories.has(segment))
+}
+
+function formatTypeScriptDiagnostics(diagnostics) {
+ return ts.formatDiagnostics(diagnostics, {
+ getCanonicalFileName: (fileName) => fileName,
+ getCurrentDirectory: () => webRoot,
+ getNewLine: () => ts.sys.newLine,
+ })
+}
+
+function readCompilerOptions() {
+ const tsconfigPath = ts.findConfigFile(webRoot, ts.sys.fileExists, 'tsconfig.json')
+
+ if (!tsconfigPath) throw new Error('Unable to find web/tsconfig.json.')
+
+ const configFile = ts.readConfigFile(tsconfigPath, ts.sys.readFile)
+
+ if (configFile.error) throw new Error(formatTypeScriptDiagnostics([configFile.error]))
+
+ const parsedConfig = ts.parseJsonConfigFileContent(
+ configFile.config,
+ ts.sys,
+ path.dirname(tsconfigPath),
+ undefined,
+ tsconfigPath,
+ )
+ const errors = parsedConfig.errors.filter(
+ (diagnostic) => diagnostic.category === ts.DiagnosticCategory.Error,
+ )
+
+ if (errors.length > 0) throw new Error(formatTypeScriptDiagnostics(errors))
+
+ return parsedConfig.options
+}
+
+function collectLocalDependencies(entryFiles) {
+ for (const entryFile of entryFiles) {
+ let stats
+
+ try {
+ stats = fs.statSync(entryFile)
+ } catch {
+ throw new Error(`Entry file does not exist: ${entryFile}`)
+ }
+
+ if (!stats.isFile()) throw new Error(`--deps only accepts entry files: ${entryFile}`)
+ if (!isTraversableSourceFile(entryFile))
+ throw new Error(
+ `Entry file must be a JavaScript or TypeScript source file under web/: ${entryFile}`,
+ )
+ }
+
+ const compilerOptions = readCompilerOptions()
+ const canonicalFileName = ts.sys.useCaseSensitiveFileNames
+ ? (fileName) => fileName
+ : (fileName) => fileName.toLowerCase()
+ const resolutionCache = ts.createModuleResolutionCache(
+ webRoot,
+ canonicalFileName,
+ compilerOptions,
+ )
+ const visitedFiles = new Map()
+ const pending = [...entryFiles]
+
+ while (pending.length > 0) {
+ const currentFile = path.resolve(pending.pop())
+ const canonicalCurrentFile = canonicalFileName(currentFile)
+
+ if (visitedFiles.has(canonicalCurrentFile)) continue
+ visitedFiles.set(canonicalCurrentFile, currentFile)
+
+ const sourceText = ts.sys.readFile(currentFile)
+
+ if (sourceText === undefined) throw new Error(`Unable to read imported file: ${currentFile}`)
+
+ const importedFiles = ts.preProcessFile(sourceText, true, true).importedFiles
+
+ for (const importedFile of importedFiles) {
+ const resolvedModule = ts.resolveModuleName(
+ importedFile.fileName,
+ currentFile,
+ compilerOptions,
+ ts.sys,
+ resolutionCache,
+ ).resolvedModule
+
+ if (!resolvedModule || resolvedModule.isExternalLibraryImport) continue
+
+ const dependencyPath = path.resolve(resolvedModule.resolvedFileName)
+
+ if (isTraversableSourceFile(dependencyPath)) pending.push(dependencyPath)
+ }
+ }
+
+ const files = [...visitedFiles.values()]
+ .filter((filePath) => jsxExtensions.has(path.extname(filePath)))
+ .sort()
+
+ console.log(
+ `Resolved ${files.length} JSX source ${files.length === 1 ? 'file' : 'files'} from ${entryFiles.length} ${entryFiles.length === 1 ? 'entry' : 'entries'}.`,
+ )
+
+ return files
+}
+
+let targets = resolvedTargets
+
+if (dependencyMode) {
+ try {
+ targets = collectLocalDependencies(resolvedTargets)
+ } catch (error) {
+ console.error(error instanceof Error ? error.message : String(error))
+ process.exit(2)
+ }
+}
+
+if (targets.length === 0) {
+ console.log('No JSX or TSX source files found to lint.')
+ process.exit(0)
+}
+
+const result = spawnSync(process.execPath, [oxlintEntry, '-c', configPath, ...targets], {
+ cwd: webRoot,
+ stdio: 'inherit',
+})
+
+if (result.error) {
+ console.error(`Failed to start the accessibility lint: ${result.error.message}`)
+ process.exit(1)
+}
+
+process.exit(result.status ?? 1)