Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@hirokiokada77
Copy link
Contributor

@hirokiokada77 hirokiokada77 commented Nov 16, 2025

Summary

Closes #8117.

This PR fixes an issue where the useValidLang rule incorrectly rejected valid BCP 47 tags that include a script subtag (such as zh-Hans-CN).

Test Plan

New rules were added to:

  • crates/biome_js_analyze/tests/specs/a11y/useValidLang/invalid.jsx
  • crates/biome_js_analyze/tests/specs/a11y/useValidLang/valid.jsx

@changeset-bot
Copy link

changeset-bot bot commented Nov 16, 2025

🦋 Changeset detected

Latest commit: 208d530

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

This PR includes changesets to release 13 packages
Name Type
@biomejs/biome Patch
@biomejs/cli-win32-x64 Patch
@biomejs/cli-win32-arm64 Patch
@biomejs/cli-darwin-x64 Patch
@biomejs/cli-darwin-arm64 Patch
@biomejs/cli-linux-x64 Patch
@biomejs/cli-linux-arm64 Patch
@biomejs/cli-linux-x64-musl Patch
@biomejs/cli-linux-arm64-musl Patch
@biomejs/wasm-web Patch
@biomejs/wasm-bundler Patch
@biomejs/wasm-nodejs Patch
@biomejs/backend-jsonrpc Patch

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

@github-actions github-actions bot added A-Linter Area: linter L-JavaScript Language: JavaScript and super languages labels Nov 16, 2025
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Nov 16, 2025

Walkthrough

Parses BCP 47 lang attributes to accept optional script subtags, supporting language[-script][-region] forms and rejecting values with more than three primary subtags. Adds Script to InvalidKind, uses is_valid_script and generated ISO script data for validation, and updates diagnostics to list valid scripts. Test coverage extended with zh-Hant and zh-Hans-CN cases and new invalid-tag tests.

Suggested labels

L-HTML, A-Diagnostic

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 62.50% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the main change: fixing the useValidLang rule to accept BCP 47 language tags with script subtags.
Linked Issues check ✅ Passed The PR successfully implements all requirements from #8117: accepts three-part language tags (language-script-region), validates script subtags, and adds test coverage for valid tags like zh-Hans-CN.
Out of Scope Changes check ✅ Passed All changes are scoped to fixing the useValidLang rule for BCP 47 script subtag support; no extraneous modifications detected.
Description check ✅ Passed The pull request description clearly relates to the changeset, explaining the fix for BCP 47 language tags with script subtags and referencing the test plan.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
crates/biome_js_analyze/src/lint/a11y/use_valid_lang.rs (1)

69-103: Language-script tags like zh-Hant and sr-Latn are incorrectly rejected despite being valid BCP 47

The code lacks a dedicated match arm for two-part tags where the second component is a script. BCP 47 (RFC 5646) permits a primary language subtag followed by a script subtag with no region, yet the current implementation falls through to the (Some(language), Some(country), None) arm and fails the country validation on the script code.

To fix this, you'll need to distinguish scripts from country codes—likely via a heuristic (scripts are typically 4 letters, countries 2) or by importing/creating an is_valid_script() function from biome_aria_metadata. Add a dedicated arm before the country check and validate via is_valid_language("{language}-{script}") as the three-part branch does.

Include tests for <html lang="zh-Hant" /> and <html lang="sr-Latn" /> to prevent regression.

🧹 Nitpick comments (1)
crates/biome_js_analyze/tests/specs/a11y/useValidLang/valid.jsx (1)

8-9: Consider adding tests for language–script tags without region

The new zh-Hans-CN / zh-Hant-TW cases look spot‑on for language–script–region. To fully exercise the BCP 47 shape from the issue (language[-script][-region]…), it might be worth adding a couple of language-script‑only examples as valid too (e.g. <html lang="zh-Hant" />, <html lang="sr-Cyrl" />), if you intend to support those.

📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 47d940e and 82dd282.

⛔ Files ignored due to path filters (2)
  • crates/biome_js_analyze/tests/specs/a11y/useValidLang/invalid.jsx.snap is excluded by !**/*.snap and included by **
  • crates/biome_js_analyze/tests/specs/a11y/useValidLang/valid.jsx.snap is excluded by !**/*.snap and included by **
📒 Files selected for processing (2)
  • crates/biome_js_analyze/src/lint/a11y/use_valid_lang.rs (2 hunks)
  • crates/biome_js_analyze/tests/specs/a11y/useValidLang/valid.jsx (1 hunks)

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (3)
crates/biome_js_analyze/src/lint/a11y/use_valid_lang.rs (3)

70-87: Consider edge case: language-country-extra patterns.

When the input is language-country-extra (e.g., en-US-GB), line 71 validates en-US as a language code, which should fail. This results in a Language error, though the actual issue is an extraneous segment after a valid language-country pair.

Whilst this only affects invalid inputs, distinguishing this case would improve error messages. You could check whether the second component is a valid country before validating language-script.


89-103: Logic correctly distinguishes language-country from language-script.

The nested checks appropriately handle both patterns:

  • language-country (when script_or_country is a valid country)
  • language-script (when the combined form is a valid language)

The flow is correct but fairly intricate. A brief comment explaining the two cases might aid future maintainers.


70-112: Consider adding negative test cases for script subtag patterns.

Whilst the valid cases are well covered, consider adding tests for invalid script subtag patterns to ensure they're still properly rejected:

  • Invalid script: zh-Xxxx
  • Invalid region with script: zh-Hans-ZZ
  • Extra segments: en-US-GB-Extra

This would confirm the error paths work correctly for the new 3-component logic.

📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 82dd282 and c515454.

⛔ Files ignored due to path filters (2)
  • crates/biome_js_analyze/tests/specs/a11y/useValidLang/invalid.jsx.snap is excluded by !**/*.snap and included by **
  • crates/biome_js_analyze/tests/specs/a11y/useValidLang/valid.jsx.snap is excluded by !**/*.snap and included by **
📒 Files selected for processing (2)
  • crates/biome_js_analyze/src/lint/a11y/use_valid_lang.rs (2 hunks)
  • crates/biome_js_analyze/tests/specs/a11y/useValidLang/valid.jsx (1 hunks)
🔇 Additional comments (2)
crates/biome_js_analyze/tests/specs/a11y/useValidLang/valid.jsx (1)

8-9: Good test coverage for the script subtag cases.

These additions properly validate the fix for both 2-component (zh-Hant) and 3-component (zh-Hans-CN) patterns with script subtags.

crates/biome_js_analyze/src/lint/a11y/use_valid_lang.rs (1)

69-69: Match expanded to handle script subtags.

The 3-tuple match correctly supports parsing language-script-region patterns.

@codspeed-hq
Copy link

codspeed-hq bot commented Nov 16, 2025

CodSpeed Performance Report

Merging #8118 will not alter performance

Comparing hirokiokada77:script-subtags (208d530) with main (47d940e)

Summary

✅ 58 untouched
⏩ 95 skipped1

Footnotes

  1. 95 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (1)
crates/biome_js_analyze/src/lint/a11y/use_valid_lang.rs (1)

149-149: Add helpful context to the Value error diagnostic.

When InvalidKind::Value is returned (due to extra components), the diagnostic provides no specific guidance. Users would benefit from understanding that BCP 47 tags should follow a specific structure.

Consider adding a footer note:

-            InvalidKind::Value => diagnostic,
+            InvalidKind::Value => diagnostic.note(
+                markup! {
+                    "Language tags should follow the structure: language[-script][-region]."
+                }
+            ),
📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between c515454 and 4061978.

⛔ Files ignored due to path filters (2)
  • crates/biome_js_analyze/tests/specs/a11y/useValidLang/invalid.jsx.snap is excluded by !**/*.snap and included by **
  • crates/biome_js_analyze/tests/specs/a11y/useValidLang/valid.jsx.snap is excluded by !**/*.snap and included by **
📒 Files selected for processing (2)
  • crates/biome_js_analyze/src/lint/a11y/use_valid_lang.rs (2 hunks)
  • crates/biome_js_analyze/tests/specs/a11y/useValidLang/valid.jsx (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • crates/biome_js_analyze/tests/specs/a11y/useValidLang/valid.jsx
🔇 Additional comments (2)
crates/biome_js_analyze/src/lint/a11y/use_valid_lang.rs (2)

81-86: Extra component detection works correctly.

The check properly detects when more than three subtags are present and returns an appropriate error.


70-87: Review comment can be dismissed; implementation is correct.

The verification confirms the three-component logic is sound. The BCP 47 standard mandates that script subtags precede region subtags, so three-component tags must follow the language-script-region pattern. The code correctly validates zh-Hans-CN and rejects en-GB-something, as evidenced by the test suite. The is_valid_language() function properly accepts compound language-script codes like "zh-Hans".

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

♻️ Duplicate comments (1)
crates/biome_js_analyze/src/lint/a11y/use_valid_lang.rs (1)

89-105: Misleading error type when script validation fails.

This is a known issue already flagged in the previous review. When the second component is neither a valid country nor part of a valid language-script combination (lines 95-103), the code returns InvalidKind::Country. For a tag like zh-InvalidScript, users will see "Some of valid countries:" in the diagnostic, which doesn't help them understand that their script subtag is invalid.

As suggested in the previous review, consider introducing a separate InvalidKind::Script variant or a more generic error message that acknowledges both script and country possibilities.

🧹 Nitpick comments (1)
crates/biome_js_analyze/tests/specs/a11y/useValidLang/valid.jsx (1)

8-9: Test cases cover the primary fix.

The added tests for zh-Hant and zh-Hans-CN demonstrate that the fix resolves the reported issue. However, consider adding test coverage for:

  • Other script subtags mentioned in the issue (e.g., sr-Cyrl-RS)
  • Invalid script cases in a separate invalid test file (e.g., zh-InvalidScript) to verify error handling
📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 4061978 and 91f99f6.

⛔ Files ignored due to path filters (2)
  • crates/biome_js_analyze/tests/specs/a11y/useValidLang/invalid.jsx.snap is excluded by !**/*.snap and included by **
  • crates/biome_js_analyze/tests/specs/a11y/useValidLang/valid.jsx.snap is excluded by !**/*.snap and included by **
📒 Files selected for processing (2)
  • crates/biome_js_analyze/src/lint/a11y/use_valid_lang.rs (2 hunks)
  • crates/biome_js_analyze/tests/specs/a11y/useValidLang/valid.jsx (1 hunks)
🔇 Additional comments (1)
crates/biome_js_analyze/src/lint/a11y/use_valid_lang.rs (1)

70-87: Metadata coverage is incomplete for language-script combinations.

The verification confirms your concern: whilst zh-Hans and zh-Hant are present in biome_aria_metadata/src/lib.rs, Serbian script variants (sr-Cyrl, sr-Latn) are missing. Only the base language code "sr" is listed. Valid BCP 47 tags using these script subtags will be incorrectly rejected. The code logic itself is sound, but the data in the hardcoded ISO_LANGUAGES array needs expansion to cover additional language-script combinations beyond Chinese.

Copy link
Contributor

@dyc3 dyc3 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There also needs to be a changeset.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (3)
crates/biome_aria_metadata/build.rs (1)

46-50: Script enum generation looks good; minor scope nit

The new IsoScripts wiring and token emission look solid and consistent with countries/languages.

Tiny nit: ISO_SCRIPTS does not need to be pub inside build.rs, since it’s only used locally, and the other ISO constants here are private. Dropping pub would make the file a bit more self‑consistent.

Also applies to: 273-283

crates/biome_js_analyze/tests/specs/a11y/useValidLang/valid.jsx (1)

8-9: Nice targeted coverage for script subtags

These two cases neatly cover language-script and language-script-country for Chinese. If you fancy one more, adding sr-Cyrl-RS would round out the examples mentioned in the issue, but it’s not strictly necessary.

crates/biome_js_analyze/src/lint/a11y/use_valid_lang.rs (1)

70-135: 3-part parsing works, but script vs country classification could be sharper

The new 2- and 3-part handling plus InvalidKind::Script is a solid upgrade and fixes the original regression for tags like zh-Hans-CN and sr-Cyrl-RS.

One minor behavioural quirk: in the (Some(language), Some(script), Some(country)) arm the second subtag is always treated as a script. For inputs such as en-GB-typo, GB is really a region, but we now surface a Script error (and list scripts) rather than pointing at the extra/variant part. If you want diagnostics to line up more closely with BCP‑47 structure, you could first disambiguate the second token by length or by is_valid_script/is_valid_country before deciding whether to report Script, Country, or Value here—similar to what you already do in the two-part case.

Otherwise, the integration with is_valid_script and the Script footer listing looks clean.

Also applies to: 150-182

📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 91f99f6 and 685f39d.

⛔ Files ignored due to path filters (2)
  • crates/biome_js_analyze/tests/specs/a11y/useValidLang/invalid.jsx.snap is excluded by !**/*.snap and included by **
  • crates/biome_js_analyze/tests/specs/a11y/useValidLang/valid.jsx.snap is excluded by !**/*.snap and included by **
📒 Files selected for processing (6)
  • .changeset/angry-carpets-switch.md (1 hunks)
  • crates/biome_aria_metadata/build.rs (2 hunks)
  • crates/biome_aria_metadata/src/lib.rs (3 hunks)
  • crates/biome_js_analyze/src/lint/a11y/use_valid_lang.rs (4 hunks)
  • crates/biome_js_analyze/tests/specs/a11y/useValidLang/invalid.jsx (1 hunks)
  • crates/biome_js_analyze/tests/specs/a11y/useValidLang/valid.jsx (1 hunks)
✅ Files skipped from review due to trivial changes (1)
  • .changeset/angry-carpets-switch.md
🧰 Additional context used
🧬 Code graph analysis (3)
crates/biome_js_analyze/tests/specs/a11y/useValidLang/invalid.jsx (1)
crates/biome_js_analyze/tests/specs/a11y/useValidLang/valid.jsx (8)
  • a (2-2)
  • a (3-3)
  • a (4-4)
  • a (5-5)
  • a (6-6)
  • a (7-7)
  • a (8-8)
  • a (9-9)
crates/biome_js_analyze/tests/specs/a11y/useValidLang/valid.jsx (1)
crates/biome_js_analyze/tests/specs/a11y/useValidLang/invalid.jsx (6)
  • a (1-1)
  • a (2-2)
  • a (3-3)
  • a (4-4)
  • a (5-5)
  • a (6-6)
crates/biome_js_analyze/src/lint/a11y/use_valid_lang.rs (1)
crates/biome_aria_metadata/src/lib.rs (2)
  • is_valid_script (53-55)
  • scripts (68-70)
🔇 Additional comments (1)
crates/biome_js_analyze/tests/specs/a11y/useValidLang/invalid.jsx (1)

4-6: Good coverage of new failure modes

These cases nicely exercise invalid script, invalid country after a valid script, and too many subtags, so they should keep the new parsing logic honest.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (1)
crates/biome_js_analyze/src/lint/a11y/use_valid_lang.rs (1)

95-125: Two-part disambiguation logic is sound.

The length-based heuristic appropriately distinguishes scripts (4 chars) from countries (2-3 chars) when neither validation passes. This aligns with ISO 15924 and ISO 3166-1 standards.

One minor consideration: BCP 47 permits 3-digit UN M.49 numeric region codes (e.g., en-001 for world). If is_valid_country doesn't handle these, they'd be rejected as InvalidKind::Value. However, this would be a pre-existing limitation, not introduced here.

📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 685f39d and d53fb6f.

⛔ Files ignored due to path filters (2)
  • crates/biome_js_analyze/tests/specs/a11y/useValidLang/invalid.jsx.snap is excluded by !**/*.snap and included by **
  • crates/biome_js_analyze/tests/specs/a11y/useValidLang/valid.jsx.snap is excluded by !**/*.snap and included by **
📒 Files selected for processing (6)
  • .changeset/angry-carpets-switch.md (1 hunks)
  • crates/biome_aria_metadata/build.rs (2 hunks)
  • crates/biome_aria_metadata/src/lib.rs (3 hunks)
  • crates/biome_js_analyze/src/lint/a11y/use_valid_lang.rs (4 hunks)
  • crates/biome_js_analyze/tests/specs/a11y/useValidLang/invalid.jsx (1 hunks)
  • crates/biome_js_analyze/tests/specs/a11y/useValidLang/valid.jsx (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
  • crates/biome_js_analyze/tests/specs/a11y/useValidLang/valid.jsx
  • .changeset/angry-carpets-switch.md
🧰 Additional context used
🧬 Code graph analysis (2)
crates/biome_js_analyze/src/lint/a11y/use_valid_lang.rs (1)
crates/biome_aria_metadata/src/lib.rs (4)
  • is_valid_country (43-45)
  • is_valid_language (48-50)
  • is_valid_script (53-55)
  • scripts (68-70)
crates/biome_js_analyze/tests/specs/a11y/useValidLang/invalid.jsx (1)
crates/biome_js_analyze/tests/specs/a11y/useValidLang/valid.jsx (8)
  • a (2-2)
  • a (3-3)
  • a (4-4)
  • a (5-5)
  • a (6-6)
  • a (7-7)
  • a (8-8)
  • a (9-9)
🔇 Additional comments (6)
crates/biome_aria_metadata/build.rs (1)

46-50: LGTM!

The ISO_SCRIPTS constant and enum generation follow the established pattern for countries and languages. The 28 script codes are standard ISO 15924 identifiers.

Also applies to: 275-275, 282-282

crates/biome_js_analyze/tests/specs/a11y/useValidLang/invalid.jsx (1)

4-6: Excellent test coverage for script validation.

The three new test cases appropriately cover:

  • Invalid script code (Xxxx)
  • Valid script with invalid country (Hans + ZZ)
  • Excessive components (4+ parts)
crates/biome_aria_metadata/src/lib.rs (2)

36-40: LGTM! Script validation API follows established patterns.

The ISO_SCRIPTS constant, is_valid_script(), and scripts() accessor mirror the existing country/language APIs. Implementation is consistent and correct.

Also applies to: 52-55, 67-70


23-34: The review comment is based on incorrect information.

Verification shows no changes to ISO_LANGUAGES between main and the current branch—both have identical 150-entry arrays with no removals or additions. The claim of a reduction from 152 to 150 entries appears to be a miscount. This code change can be approved as-is.

Likely an incorrect or invalid review comment.

crates/biome_js_analyze/src/lint/a11y/use_valid_lang.rs (2)

70-93: LGTM! Three-part validation correctly implements BCP 47 structure.

The validation properly handles language-script-country tags by checking each component in order and returning the appropriate InvalidKind for each failure case. The check for extra components (4+) correctly rejects malformed tags.


171-180: LGTM! Diagnostic footer follows established pattern.

The InvalidKind::Script diagnostic correctly mirrors the Language and Country cases, providing helpful suggestions to users.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (2)
crates/biome_js_analyze/tests/specs/a11y/useValidLang/valid.jsx (1)

8-9: Good script-tag coverage; consider one more sample

The zh-Hant and zh-Hans-CN cases nicely exercise script-only and language–script–region. You might also add a sr-Cyrl-RS case to mirror the example from the linked issue, but this is strictly optional.

crates/biome_js_analyze/src/lint/a11y/use_valid_lang.rs (1)

70-93: Script-aware parsing behaves correctly for the targeted tag shapes

The new branches handle the key cases as expected: three-part language-script-country (zh-Hans-CN, sr-Cyrl-RS) and two-part language-script (zh-Hant) or language-country (en-US), while still rejecting extra subtags and clearly distinguishing invalid language/script/country/value. The length-based fallback in the two-part arm is a neat way to tailor the error kind without over-parsing BCP47.

Also applies to: 95-127

📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between d53fb6f and 208d530.

⛔ Files ignored due to path filters (2)
  • crates/biome_js_analyze/tests/specs/a11y/useValidLang/invalid.jsx.snap is excluded by !**/*.snap and included by **
  • crates/biome_js_analyze/tests/specs/a11y/useValidLang/valid.jsx.snap is excluded by !**/*.snap and included by **
📒 Files selected for processing (6)
  • .changeset/angry-carpets-switch.md (1 hunks)
  • crates/biome_aria_metadata/build.rs (2 hunks)
  • crates/biome_aria_metadata/src/lib.rs (3 hunks)
  • crates/biome_js_analyze/src/lint/a11y/use_valid_lang.rs (4 hunks)
  • crates/biome_js_analyze/tests/specs/a11y/useValidLang/invalid.jsx (1 hunks)
  • crates/biome_js_analyze/tests/specs/a11y/useValidLang/valid.jsx (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
  • .changeset/angry-carpets-switch.md
  • crates/biome_js_analyze/tests/specs/a11y/useValidLang/invalid.jsx
🧰 Additional context used
🧬 Code graph analysis (2)
crates/biome_js_analyze/src/lint/a11y/use_valid_lang.rs (1)
crates/biome_aria_metadata/src/lib.rs (4)
  • is_valid_country (43-45)
  • is_valid_language (48-50)
  • is_valid_script (53-55)
  • scripts (68-70)
crates/biome_js_analyze/tests/specs/a11y/useValidLang/valid.jsx (1)
crates/biome_js_analyze/tests/specs/a11y/useValidLang/invalid.jsx (6)
  • a (1-1)
  • a (2-2)
  • a (3-3)
  • a (4-4)
  • a (5-5)
  • a (6-6)
🔇 Additional comments (3)
crates/biome_aria_metadata/build.rs (1)

33-44: IsoScripts generation looks consistent; double-check language list changes

The new ISO_SCRIPTS slice and IsoScripts enum generation follow the existing countries/languages pattern and should integrate cleanly with the include!‑generated types. The only thing I’d sanity‑check is the ISO_LANGUAGES edits here (some entries were removed/reordered per the summary) to ensure no language codes were accidentally dropped compared to the previous list or lib.rs.

Also applies to: 46-50, 273-283

crates/biome_js_analyze/src/lint/a11y/use_valid_lang.rs (1)

3-4: Nice improvement in error specificity for script failures

Pulling in is_valid_script and adding InvalidKind::Script (with a dedicated footer listing scripts()) makes diagnostics much less confusing for values like zh-Xxxx or zh-Hans-ZZ. This also addresses the earlier review concern about mislabelling script errors as country issues.

Also applies to: 43-48, 171-180

crates/biome_aria_metadata/src/lib.rs (1)

23-40: Script metadata API aligns well with existing country/language helpers

ISO_SCRIPTS, is_valid_script, and scripts() mirror the existing country/language pattern nicely and give useValidLang exactly what it needs. Given that ISO_LANGUAGES was also adjusted here, it’s worth quickly cross-checking the language/script lists against whatever ISO source you’re using to confirm no desired codes went missing.

Also applies to: 52-55, 67-70

@hirokiokada77
Copy link
Contributor Author

@dyc3 I made requested changes and added a changeset.

Copy link
Contributor

@dyc3 dyc3 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!

@dyc3 dyc3 merged commit dbc7021 into biomejs:main Nov 17, 2025
19 checks passed
@github-actions github-actions bot mentioned this pull request Nov 17, 2025
@hirokiokada77 hirokiokada77 deleted the script-subtags branch November 17, 2025 03:58
ematipico pushed a commit to hamirmahal/biome that referenced this pull request Nov 19, 2025
l0ngvh pushed a commit to l0ngvh/biome that referenced this pull request Dec 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-Linter Area: linter L-JavaScript Language: JavaScript and super languages

Projects

None yet

Development

Successfully merging this pull request may close these issues.

🐛 useValidLang rule incorrectly rejects valid BCP 47 language tags that include script subtags, such as zh-Hans-CN

2 participants