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

📎 noRestrictedGlobals: add an option for a custom message #4722

Open
dyc3 opened this issue Dec 11, 2024 · 3 comments
Open

📎 noRestrictedGlobals: add an option for a custom message #4722

dyc3 opened this issue Dec 11, 2024 · 3 comments
Labels
A-Linter Area: linter L-JavaScript Language: JavaScript and super languages S-Needs discussion Status: needs a discussion to understand criteria

Comments

@dyc3
Copy link
Contributor

dyc3 commented Dec 11, 2024

Description

From #4721.

Currently, the noRestrictedGlobals rule in Biome does not provide the ability to include a custom message explaining why a global variable is restricted. Users should be able to optionally specify a custom message for violations of this rule. Something like:

// biome.jsonc
{
    "options": {
        "deniedGlobals": [
            {
                "ident": "$",
                "message": "jQuery is not allowed. Use native DOM manipulation instead."
            },
            {
                "ident": "someGlobal",
                "message": "someGlobal shouldn't be used because..."
            }
        ]
    }
}

Once we decide on the config ergonomics, this could easily earn a good first issue label.

@dyc3 dyc3 added A-Linter Area: linter L-JavaScript Language: JavaScript and super languages labels Dec 11, 2024
@ematipico ematipico added the S-Needs discussion Status: needs a discussion to understand criteria label Dec 11, 2024
@ematipico
Copy link
Member

I have two other suggestions:

@Conaclos
Copy link
Member

use the proposed suggestion, but change ident to variable/variableName/globalName. ident is a non-beginner term

I could opt for globalName or just name because this also covers type names.

Anyway, if we align top the other we don't even need a name because it is already called deniedGlobals :)

// biome.jsonc
{
    "options": {
        "deniedGlobals": {
            "$": "jQuery is not allowed. Use native DOM manipulation instead.",
            "someGlobal": "someGlobal shouldn't be used because..."
        }
    }
}

Question: should we deprecate arrays for deniedGlobals?

@ematipico
Copy link
Member

Question: should we deprecate arrays for deniedGlobals?

Since we are working towards v2, we could just break it and provide a migration.

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 S-Needs discussion Status: needs a discussion to understand criteria
Projects
None yet
Development

No branches or pull requests

3 participants