disallowDanglingUnderscores

Disallows identifiers that start or end in _.

Types: Boolean or Object

Values:

  • true
  • Object:
    • allExcept: array of quoted identifiers

JSHint: nomen

Some popular identifiers are automatically listed as exceptions:

  • __proto__ (javascript)
  • _ (underscore.js)
  • __filename (node.js global)
  • __dirname (node.js global)
  • super_ (node.js, used by util.inherits)

Example

"disallowDanglingUnderscores": { "allExcept": ["_exception"] }
Valid
var x = 1;
var o = obj.__proto__;
var y = _.extend;
var z = __dirname;
var w = __filename;
var x_y = 1;
var v = _exception;
Invalid
var _x = 1;
var x_ = 1;
var x_y_ = 1;
Rule source
Test source