id-denylist
Disallow the identifier names you list
Names like data, tmp or cb don't say much about what they hold. This rule reports the names you list when they name a variable, parameter, function, class, import, object key or class member, or a property you assign to.
Without a list, the rule reports nothing.
Configure#
Off by default. To turn it on:
[lint.rules]
"id-denylist" = "error" # or "warn"Examples#
[lint.rules]
id-denylist = ["error", "data", "callback"]"data", "callback"4 problemsconst dataIdentifier data is restricted. = loadUser(id);
function save(user, callbackIdentifier callback is restricted.) {}
const response = { dataIdentifier data is restricted.: 1 };
response.dataIdentifier data is restricted. = 2;"data", "callback"No problemsconst user = loadUser(id);
function save(user, onSaved) {}A variable is reported where it's declared and again where it's used, except where it's called or passed as an argument. This example gets two reports, on lines 1 and 3:
"data"2 problemsfunction render(dataIdentifier data is restricted.) {
log(data);
return dataIdentifier data is restricted..title;
}Reading a property is allowed, because the object may come from code you don't control. So is an import or a destructured property that you rename:
"data", "callback"No problemsimport { data as users } from "./api";
const { data: orders } = await fetchOrders();
console.log(response.data, users, orders);Private names are compared without the #:
"data"1 problemclass Store {
#dataIdentifier #data is restricted. = new Map();
}Options#
Each option is a name to disallow. Names are compared exactly, so "data" doesn't match userData.