Skip to content

Comments

fix(linter): Fix empty-tags rule logic.#16873

Merged
graphite-app[bot] merged 1 commit intomainfrom
fix-empty-tags
Dec 15, 2025
Merged

fix(linter): Fix empty-tags rule logic.#16873
graphite-app[bot] merged 1 commit intomainfrom
fix-empty-tags

Conversation

@connorshea
Copy link
Member

@connorshea connorshea commented Dec 15, 2025

This corrects the implementation of the empty-tags rule to not care about the ignorePrivate setting.

Fixes #16871.

The doc comment for this setting actually explicitly says it should not be considered:

/// For all rules but NOT apply to `check-access` and `empty-tags` rule
#[serde(default, rename = "ignorePrivate")]
pub ignore_private: bool,

This was missed when porting the tests because the settings shape was incorrect and silently failed. I only noticed it while attempting to enforce a stricter config schema.

@connorshea connorshea requested a review from camc314 as a code owner December 15, 2025 06:17
Copilot AI review requested due to automatic review settings December 15, 2025 06:17
@github-actions github-actions bot added A-linter Area - Linter C-bug Category - Bug labels Dec 15, 2025
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes the empty-tags rule to correctly ignore the ignorePrivate setting, as documented in the JSDoc settings. The rule was incorrectly filtering JSDoc comments based on the ignorePrivate setting, which should not apply to this rule according to the documented behavior.

Key Changes:

  • Removed the should_ignore_as_private utility import and its usage
  • Updated iteration logic to process all JSDoc comments without filtering
  • Added explanatory comments documenting why ignorePrivate doesn't apply
  • Fixed test configuration structure to use proper settings wrapper

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link

@charliecreates charliecreates bot left a comment

Choose a reason for hiding this comment

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

The core logic change (stop honoring ignorePrivate) matches the PR intent, but there’s a small performance footgun in is_empty_tag_kind due to repeated to_string() allocations. The updated test config structure is good, but the test suite should include an explicit regression test proving that ignorePrivate: true does not suppress empty-tags diagnostics on @private blocks. Addressing these will make the rule both faster and less likely to regress.

Additional notes (1)
  • Performance | crates/oxc_linter/src/rules/jsdoc/empty_tags.rs:108-108
    The current implementation allocates on every tag check via tag_name.to_string() inside the hot path: self.0.tags.contains(&tag_name.to_string()). For large files / many tags this can be unnecessarily expensive. Consider storing configured tags as a set (e.g., FxHashSet<String>) or normalizing to Vec<String> but comparing without allocating (e.g., iterate and compare &str).
Summary of changes

What changed

  • Removed the private-filtering logic from jsdoc/empty-tags by dropping utils::should_ignore_as_private and iterating over all JSDoc blocks.
  • Added inline documentation clarifying that the ignorePrivate JSDoc setting does not apply to this rule.
  • Updated the related test configuration shape to nest ignorePrivate under settings.jsdoc (i.e., {"settings": {"jsdoc": {"ignorePrivate": true}}}) instead of a top-level jsdoc key.

Key diff points

  • crates/oxc_linter/src/rules/jsdoc/empty_tags.rs: removed filter(|jsdoc| !should_ignore_as_private(...)) and its settings dependency; updated test config JSON.

@codspeed-hq
Copy link

codspeed-hq bot commented Dec 15, 2025

CodSpeed Performance Report

Merging #16873 will not alter performance

Comparing fix-empty-tags (02fa857) with main (aafcf3e)1

Summary

✅ 4 untouched
⏩ 41 skipped2

Footnotes

  1. No successful run was found on main (e0d8001) during the generation of this report, so aafcf3e was used instead as the comparison base. There might be some changes unrelated to this pull request in this report.

  2. 41 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.

@camc314 camc314 self-assigned this Dec 15, 2025
@camc314
Copy link
Contributor

camc314 commented Dec 15, 2025

@connorshea do you mind approving this PR to make sure the change it correct? it looks ok to me, but would appreciate another pair of eyes

Oh wait ignore me, I though copilot made this PR 🙂

@camc314 camc314 added the 0-merge Merge with Graphite Merge Queue label Dec 15, 2025
Copy link
Contributor

camc314 commented Dec 15, 2025

Merge activity

This corrects the implementation of the empty-tags rule to not care about the `ignorePrivate` setting.

Fixes #16871.

The doc comment for this setting actually explicitly says it should not be considered: https://github.com/oxc-project/oxc/blob/230e34c6eb36c4265fa8ae421375884182fd6926/crates/oxc_linter/src/config/settings/jsdoc.rs#L12-L14

This was missed when porting the tests because the settings shape was incorrect and silently failed. I only noticed it while attempting to enforce a stricter config schema.
@graphite-app graphite-app bot merged commit bb86e0e into main Dec 15, 2025
20 checks passed
@graphite-app graphite-app bot deleted the fix-empty-tags branch December 15, 2025 09:31
@graphite-app graphite-app bot removed the 0-merge Merge with Graphite Merge Queue label Dec 15, 2025
graphite-app bot pushed a commit that referenced this pull request Dec 16, 2025
… file (#16874)

This adds a `$schema` field to the JSON Schema, but otherwise disallows any fields not explicitly defined in the Oxlintrc struct.

This ensures that we can warn the user if they have invalid config fields:

<img width="695" height="417" alt="Screenshot 2025-12-14 at 11 22 02 PM" src="https://github.com/user-attachments/assets/8dc2252e-58ad-4bb5-a84e-cd468ad35941" />

The improved enforcement ensures the correct usage of the configuration file, and this change found a bug in another rule (see #16873).
qinyuhang pushed a commit to qinyuhang/oxc that referenced this pull request Jan 22, 2026
… file (oxc-project#16874)

This adds a `$schema` field to the JSON Schema, but otherwise disallows any fields not explicitly defined in the Oxlintrc struct.

This ensures that we can warn the user if they have invalid config fields:

<img width="695" height="417" alt="Screenshot 2025-12-14 at 11 22 02 PM" src="https://github.com/user-attachments/assets/8dc2252e-58ad-4bb5-a84e-cd468ad35941" />

The improved enforcement ensures the correct usage of the configuration file, and this change found a bug in another rule (see oxc-project#16873).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-linter Area - Linter C-bug Category - Bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

linter: jsdoc/empty-tags rule has incorrect logic/test

2 participants