๐ `noRestrictedGlobals`: add an option for a custom message
Opened this issue ยท 3 comments
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.
I have two other suggestions:
- align the option to this option https://biomejs.dev/linter/rules/no-restricted-imports/#_top (which is unfortunate because the current opinion is an array...)
- use the proposed suggestion, but change
ident
tovariable
/variableName
/globalName
.ident
is a non-beginner term
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
?
Question: should we deprecate arrays for deniedGlobals?
Since we are working towards v2, we could just break it and provide a migration.