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:

bunfig.toml
[lint.rules]
"id-denylist" = "error" # or "warn"

Examples#

bunfig.toml
[lint.rules]
id-denylist = ["error", "data", "callback"]
example.jswith "data", "callback"4 problems
const data = loadUser(id);

function save(user, callback) {}

const response = { data: 1 };
response.data = 2;
example.jswith "data", "callback"No problems
const 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:

example.jswith "data"2 problems
function render(data) {
  log(data);
  return data.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:

example.jswith "data", "callback"No problems
import { data as users } from "./api";

const { data: orders } = await fetchOrders();

console.log(response.data, users, orders);

Private names are compared without the #:

example.jswith "data"1 problem
class Store {
  #data = new Map();
}

Options#

Each option is a name to disallow. Names are compared exactly, so "data" doesn't match userData.