1 # disallow specified identifiers (id-denylist)
3 > "There are only two hard things in Computer Science: cache invalidation and naming things." — Phil Karlton
5 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.
9 This rule disallows specified identifiers in assignments and `function` definitions.
11 This rule will catch disallowed identifiers that are:
13 - variable declarations
14 - function declarations
15 - object properties assigned to during object creation
17 It will not catch disallowed identifiers that are:
19 - function calls (so you can still use functions you do not have control over)
20 - object properties (so you can still use objects you do not have control over)
24 The rule takes one or more strings as options: the names of restricted identifiers.
26 For example, to restrict the use of common generic identifiers:
30 "id-denylist": ["error", "data", "err", "e", "cb", "callback"]
34 Examples of **incorrect** code for this rule with sample `"data", "callback"` restricted identifiers:
37 /*eslint id-denylist: ["error", "data", "callback"] */
45 element.callback = function() {
54 Examples of **correct** code for this rule with sample `"data", "callback"` restricted identifiers:
57 /*eslint id-denylist: ["error", "data", "callback"] */
59 var encodingOptions = {...};
61 function processFileResult() {
65 element.successHandler = function() {
73 callback(); // all function calls are ignored
75 foo.callback(); // all function calls are ignored
77 foo.data; // all property names that are not assignments are ignored
82 You can turn this rule off if you do not want to restrict the use of certain identifiers.