2 * @fileoverview Disallow string concatenation when using __dirname and __filename
3 * @author Nicholas C. Zakas
7 //------------------------------------------------------------------------------
9 //------------------------------------------------------------------------------
11 module.exports = function(context) {
13 var MATCHER = /^__(?:dir|file)name$/;
15 //--------------------------------------------------------------------------
17 //--------------------------------------------------------------------------
21 "BinaryExpression": function(node) {
26 if (node.operator === "+" &&
27 ((left.type === "Identifier" && MATCHER.test(left.name)) ||
28 (right.type === "Identifier" && MATCHER.test(right.name)))
31 context.report(node, "Use path.join() or path.resolve() instead of + to create paths.");