Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

📎 noUndeclaredVariables: set checkTypes to false by default #5401

Open
Conaclos opened this issue Mar 20, 2025 · 0 comments
Open

📎 noUndeclaredVariables: set checkTypes to false by default #5401

Conaclos opened this issue Mar 20, 2025 · 0 comments
Assignees
Labels
A-Linter Area: linter L-JavaScript Language: JavaScript and super languages
Milestone

Comments

@Conaclos
Copy link
Member

Description

As cited by our last changelog:

  • noUndeclaredVariables now provides the checkTypes option (#3998).

    noUndeclaredVariables is inspired by the no-undef ESLint rule. It reports all references that are not bound to any declarations within a module.
    Node.js, JavaScript and TypeScript globals are ignored.
    Biome provides the javascript.globals option to list additional globals that should be ignored by the rule.

    In TypeScript projects, developers often use global declaration files to declare global types.
    Biome is currently unable to detect these global types.
    This creates many false positives for noUndeclaredVariables.

    TypeScript is better suited to perform this kind of check.
    As proof of this, TypeScript ESLint doesn't provide any rule that extends the no-undef ESLint rule.

    This is why we introduce today a new option checkTypes which, when it is set to false, ignores undeclared type references.
    Given the following configuration...

    {
        "linter": {
            "rules": {
                "correctness": {
                    "noUndeclaredVariables": {
                        "level": "error",
                        "options": { "checkTypes": false }
                    }
                }
            }
        }
    }

    ... UndeclaredType is not reported by the rule.

    export default function(): UndeclaredType {}

    We plan to turn off the option by default in Biome 2.0
    Also, this will bring the Biome rule closer to the no-undef ESLint rule.

@Conaclos Conaclos added A-Linter Area: linter L-JavaScript Language: JavaScript and super languages labels Mar 20, 2025
@Conaclos Conaclos added this to the Biome 2.0 milestone Mar 20, 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

No branches or pull requests

1 participant