source: imaps-frontend/node_modules/eslint/lib/rules/no-path-concat.js

main
Last change on this file was d565449, checked in by stefan toskovski <stefantoska84@…>, 4 weeks ago

Update repo after prototype presentation

  • Property mode set to 100644
File size: 1.7 KB
Line 
1/**
2 * @fileoverview Disallow string concatenation when using __dirname and __filename
3 * @author Nicholas C. Zakas
4 * @deprecated in ESLint v7.0.0
5 */
6"use strict";
7
8//------------------------------------------------------------------------------
9// Rule Definition
10//------------------------------------------------------------------------------
11
12/** @type {import('../shared/types').Rule} */
13module.exports = {
14 meta: {
15 deprecated: true,
16
17 replacedBy: [],
18
19 type: "suggestion",
20
21 docs: {
22 description: "Disallow string concatenation with `__dirname` and `__filename`",
23 recommended: false,
24 url: "https://eslint.org/docs/latest/rules/no-path-concat"
25 },
26
27 schema: [],
28
29 messages: {
30 usePathFunctions: "Use path.join() or path.resolve() instead of + to create paths."
31 }
32 },
33
34 create(context) {
35
36 const MATCHER = /^__(?:dir|file)name$/u;
37
38 //--------------------------------------------------------------------------
39 // Public
40 //--------------------------------------------------------------------------
41
42 return {
43
44 BinaryExpression(node) {
45
46 const left = node.left,
47 right = node.right;
48
49 if (node.operator === "+" &&
50 ((left.type === "Identifier" && MATCHER.test(left.name)) ||
51 (right.type === "Identifier" && MATCHER.test(right.name)))
52 ) {
53
54 context.report({
55 node,
56 messageId: "usePathFunctions"
57 });
58 }
59 }
60
61 };
62
63 }
64};
Note: See TracBrowser for help on using the repository browser.