eslint/id-denylist Style
What it does
Disallow specified identifiers
Why is this bad?
Generic names can lead to hard-to-decipher code. This rule allows you to specify a deny list of disallowed identifier names to avoid this practice.
Examples
Examples of incorrect code for this rule:
js
/*eslint id-denylist: ["error", "data", "callback"] */
const data = { ...values };
function callback() {
// ...
}
element.callback = function () {
// ...
};
const itemSet = {
data: [...values],
};
class Foo {
data = [];
}
class Bar {
#data = [];
}
class Baz {
callback() {}
}
class Qux {
#callback() {}
}Examples of correct code for this rule:
js
/*eslint id-denylist: ["error", "data", "callback"] */
const encodingOptions = { ...values };
function processFileResult() {
// ...
}
element.successHandler = function () {
// ...
};
const itemSet = {
entities: [...values],
};
callback(); // all function calls are ignored
foo.callback(); // all function calls are ignored
foo.data; // all property names that are not assignments are ignored
class Foo {
items = [];
}
class Bar {
#items = [];
}
class Baz {
method() {}
}
class Qux {
#method() {}
}Configuration
type: array
default: []
How to use
To enable this rule using the config file or in the CLI, you can use:
json
{
"rules": {
"id-denylist": "error"
}
}ts
import { defineConfig } from "oxlint";
export default defineConfig({
rules: {
"id-denylist": "error",
},
});bash
oxlint --deny id-denylistVersion
This rule was added in vnext.
