Skip to content

docs(linter): Update various rules to note that they can be disabled for TS code.#16819

Merged
graphite-app[bot] merged 1 commit intomainfrom
ts-enforces-docs
Dec 14, 2025
Merged

docs(linter): Update various rules to note that they can be disabled for TS code.#16819
graphite-app[bot] merged 1 commit intomainfrom
ts-enforces-docs

Conversation

@connorshea
Copy link
Copy Markdown
Member

This is generally based on the handled_by_typescript flag in the original ESLint rule definitions. All of these are flagged in the original rules as being "handled by TypeScript", and so I deferred to that when determining which rules to note this on.

@connorshea connorshea requested a review from camc314 as a code owner December 14, 2025 04:22
Copilot AI review requested due to automatic review settings December 14, 2025 04:22
@github-actions github-actions bot added A-linter Area - Linter C-docs Category - Documentation. Related to user-facing or internal documentation labels Dec 14, 2025
Copy link
Copy Markdown

@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.

A few rules are documented as universally safe to disable under TypeScript, but at least no-undef is not reliably redundant across common TS configurations and mixed JS/TS setups. The no-unreachable doc is already conditional on allowUnreachableCode, but it could further clarify that the file must actually be type-checked by tsc. The no-import-assign doc does a good job of being nuanced; consider aligning other “can be disabled” notes to that same standard.

Additional notes (2)
  • Maintainability | crates/oxc_linter/src/rules/eslint/no_undef.rs:30-39
    The added guidance says this rule “can be disabled for TypeScript code” because tsc enforces it. That’s not reliably true in common configurations:

  • In TS, noImplicitAny: false and/or JS-file checking disabled (allowJs without checkJs) can allow undeclared identifiers to slip through.

  • Even in .ts, names can flow in via declare const ... in ambient .d.ts, global augmentations, or /// <reference ...> in ways that don’t correspond to runtime globals; tsc may be satisfied while runtime still fails.

Given this is linter-rule documentation, the doc should be more conditional (or caveated) to avoid pushing users to disable a rule that still catches real JS/TS runtime issues depending on project settings.

  • Readability | crates/oxc_linter/src/rules/eslint/no_unreachable.rs:24-31
    The new note implies the TypeScript compiler enforces this check. This is only true when allowUnreachableCode is effectively false (the default) and the code is being typechecked by tsc. In many repos, linting can run on files or build steps that TS doesn’t typecheck (e.g., mixed JS/TS, transpileOnly, isolated module builds). You already added a config condition in the doc, which is good—but it might still overpromise that the compiler will always catch it.

Given you’re already mentioning allowUnreachableCode, consider also clarifying the scope: “when the file is type-checked by TypeScript” to prevent misinterpretation in mixed-language setups.

Summary of changes

Summary

This diff is documentation-focused and updates several ESLint-rule docs within crates/oxc_linter to clarify when rules are redundant under TypeScript.

What changed

  • Added a consistent note to multiple rule docs stating they can be disabled for TypeScript because the TypeScript compiler enforces the same check:
    • constructor-super, no-class-assign, no-dupe-class-members, no-dupe-keys, no-func-assign, no-new-native-nonconstructor, no-obj-calls, no-setter-return, no-this-before-super, no-undef, no-unsafe-negation.
  • Refined the no-unreachable note to be conditional on tsconfig.json (allowUnreachableCode: false).
  • Expanded no-import-assign docs to clarify TS usually catches this, but not always, so keeping the rule can still add value.
  • Standardized capitalization in the no-import-assign diagnostic text and updated the corresponding snapshot: crates/oxc_linter/src/snapshots/eslint_no_import_assign.snap.
  • Minor punctuation/wording tweaks (e.g., adding missing periods, formatting ReferenceError as code).

Copy link
Copy Markdown
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 updates documentation for several ESLint rules to note that they can be disabled when using TypeScript, since the TypeScript compiler already enforces these checks. Additionally, it standardizes diagnostic message capitalization to use sentence case (starting with capital letters).

  • Updated 12 ESLint rules to document their TypeScript compiler equivalents
  • Standardized diagnostic messages for no-import-assign to use sentence case
  • Added conditional language for no-unreachable regarding TypeScript configuration

Reviewed changes

Copilot reviewed 14 out of 14 changed files in this pull request and generated no comments.

Show a summary per file
File Description
crates/oxc_linter/src/rules/eslint/constructor_super.rs Added note that TypeScript compiler enforces this check
crates/oxc_linter/src/rules/eslint/no_class_assign.rs Added note that TypeScript compiler enforces this check
crates/oxc_linter/src/rules/eslint/no_dupe_class_members.rs Added note that TypeScript compiler enforces this check; added period to "What it does"
crates/oxc_linter/src/rules/eslint/no_dupe_keys.rs Moved TypeScript note to "What it does" section from "Why is this bad"; added period to "What it does"
crates/oxc_linter/src/rules/eslint/no_func_assign.rs Added note that TypeScript compiler enforces this check; added period to "What it does"
crates/oxc_linter/src/rules/eslint/no_import_assign.rs Capitalized diagnostic messages; updated to note TypeScript generally enforces this with caveats; added period to "What it does"
crates/oxc_linter/src/rules/eslint/no_new_native_nonconstructor.rs Added note that TypeScript compiler enforces this check; added period to "What it does"
crates/oxc_linter/src/rules/eslint/no_obj_calls.rs Standardized TypeScript note wording; maintained period in "What it does"
crates/oxc_linter/src/rules/eslint/no_setter_return.rs Added note that TypeScript compiler enforces this check
crates/oxc_linter/src/rules/eslint/no_this_before_super.rs Added note that TypeScript compiler enforces this check; added backticks around ReferenceError
crates/oxc_linter/src/rules/eslint/no_undef.rs Added note that TypeScript compiler enforces this check; line-wrapped "Why is this bad"
crates/oxc_linter/src/rules/eslint/no_unreachable.rs Added conditional note about TypeScript compiler enforcement with config requirement; added period to "What it does"
crates/oxc_linter/src/rules/eslint/no_unsafe_negation.rs Added note that TypeScript compiler enforces this check
crates/oxc_linter/src/snapshots/eslint_no_import_assign.snap Capitalized all diagnostic warning and help messages to use sentence case

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

@codspeed-hq
Copy link
Copy Markdown

codspeed-hq bot commented Dec 14, 2025

CodSpeed Performance Report

Merging #16819 will not alter performance

Comparing ts-enforces-docs (a47e6d4) with main (bbafba5)

Summary

✅ 4 untouched
⏩ 41 skipped1

Footnotes

  1. 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 14, 2025
@camc314 camc314 added the 0-merge Merge with Graphite Merge Queue label Dec 14, 2025
Copy link
Copy Markdown
Contributor

camc314 commented Dec 14, 2025

Merge activity

…for TS code. (#16819)

This is generally based on the `handled_by_typescript` flag in the original ESLint rule definitions. All of these are flagged in the original rules as being "handled by TypeScript", and so I deferred to that when determining which rules to note this on.
@graphite-app graphite-app bot merged commit ba8fe68 into main Dec 14, 2025
20 checks passed
@graphite-app graphite-app bot deleted the ts-enforces-docs branch December 14, 2025 13:42
@graphite-app graphite-app bot removed the 0-merge Merge with Graphite Merge Queue label Dec 14, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-linter Area - Linter C-docs Category - Documentation. Related to user-facing or internal documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants