Skip to content
NewBun 1.4.5 is out. Release notes
AphrodyBun

Linter · Rules

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"]

Reported:

const data = loadUser(id);

function save(user, callback) {}

const response = { data: 1 };
response.data = 2;

Not reported:

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:

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:

import { data as users } from "./api";

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

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

Private names are compared without the #:

class Store {
  #data = new Map();
}

Options

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