eslint-plugin-raflint 1.3.0 → 1.3.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/bundle.cjs +48 -0
  2. package/package.json +2 -2
package/dist/bundle.cjs CHANGED
@@ -14,5 +14,53 @@ module.exports = {
14
14
  };
15
15
  },
16
16
  },
17
+ 'no-path-join': {
18
+ meta: {
19
+ type: 'suggestion',
20
+ docs: {
21
+ description: 'Disallow path.join(a, b) in favor of template strings',
22
+ category: 'Stylistic Issues',
23
+ recommended: true,
24
+ },
25
+ fixable: 'code',
26
+ schema: [],
27
+ },
28
+ create(context) {
29
+ return {
30
+ CallExpression(node) {
31
+ // Vérifier si c'est un appel à path.join
32
+ if (
33
+ node.callee.type === 'MemberExpression' &&
34
+ node.callee.object.name === 'path' &&
35
+ node.callee.property.name === 'join' &&
36
+ // Uniquement pour les cas avec exactement 2 arguments
37
+ node.arguments.length === 2
38
+ ) {
39
+ const sourceCode = context.getSourceCode();
40
+ const arg1 = sourceCode.getText(node.arguments[0]);
41
+ const arg2 = sourceCode.getText(node.arguments[1]);
42
+
43
+ // Vérifier si le second argument est une chaîne littérale
44
+ let replacement;
45
+ if (node.arguments[1].type === 'Literal' && typeof node.arguments[1].value === 'string') {
46
+ // Si c'est une chaîne littérale, l'inclure directement sans ${}
47
+ replacement = `\`\${${arg1}}/${node.arguments[1].value}\``;
48
+ } else {
49
+ // Sinon, utiliser le format standard avec ${}
50
+ replacement = `\`\${${arg1}}/\${${arg2}}\``;
51
+ }
52
+
53
+ context.report({
54
+ node,
55
+ message: 'Utilisez des template strings au lieu de path.join() pour la concaténation de chemins simples',
56
+ fix(fixer) {
57
+ return fixer.replaceText(node, replacement);
58
+ },
59
+ });
60
+ }
61
+ },
62
+ };
63
+ },
64
+ },
17
65
  },
18
66
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "eslint-plugin-raflint",
3
- "version": "1.3.0",
3
+ "version": "1.3.2",
4
4
  "private": false,
5
5
  "description": "",
6
6
  "keywords": [],
@@ -36,7 +36,7 @@
36
36
  "c8": "^10.1.3",
37
37
  "eslint-plugin-import": "^2.31.0",
38
38
  "eslint-plugin-promise": "^7.2.1",
39
- "eslint-plugin-raflint": "^1.2.11",
39
+ "eslint-plugin-raflint": "^1.3.0",
40
40
  "globals": "^16.0.0",
41
41
  "html-validate": "^9.5.3",
42
42
  "husky": "^9.1.7",