2 * @fileoverview Disallow string concatenation when using __dirname and __filename
3 * @author Nicholas C. Zakas
7 //------------------------------------------------------------------------------
9 //------------------------------------------------------------------------------
20 description: "disallow string concatenation with `__dirname` and `__filename`",
21 category: "Node.js and CommonJS",
23 url: "https://eslint.org/docs/rules/no-path-concat"
29 usePathFunctions: "Use path.join() or path.resolve() instead of + to create paths."
35 const MATCHER = /^__(?:dir|file)name$/u;
37 //--------------------------------------------------------------------------
39 //--------------------------------------------------------------------------
43 BinaryExpression(node) {
45 const left = node.left,
48 if (node.operator === "+" &&
49 ((left.type === "Identifier" && MATCHER.test(left.name)) ||
50 (right.type === "Identifier" && MATCHER.test(right.name)))
55 messageId: "usePathFunctions"