eslint-plugin-raflint 1.5.0 → 1.5.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.
@@ -1,3 +1,6 @@
1
+ // Le backslash doit etre echappe en premier, sinon il redouble ceux ajoutes ensuite.
2
+ const escapeTemplateLiteral = (value) => value.replaceAll('\\', '\\\\').replaceAll('`', '\\`').replaceAll('${', '\\${');
3
+ const MESSAGE = 'Utilisez des template strings au lieu de path.join() pour la concaténation de chemins simples';
1
4
  const rule = {
2
5
  meta: {
3
6
  type: 'suggestion',
@@ -11,20 +14,28 @@ const rule = {
11
14
  create(context) {
12
15
  return {
13
16
  CallExpression(node) {
14
- if (!(node.callee.type === 'MemberExpression' && node.callee.object.name === 'path' && node.callee.property.name === 'join' && node.arguments.length >= 2)) {
17
+ if (!(node.callee.type === 'MemberExpression' &&
18
+ node.callee.object.name === 'path' &&
19
+ node.callee.property.name === 'join' &&
20
+ node.arguments.length >= 2)) {
21
+ return;
22
+ }
23
+ // Un spread ne peut pas être interpolé (`${...parts}` est une erreur de syntaxe) : on signale sans corriger.
24
+ if (node.arguments.some((argument) => argument.type === 'SpreadElement')) {
25
+ context.report({ node, message: MESSAGE });
15
26
  return;
16
27
  }
17
28
  const sourceCode = context.sourceCode ?? context.getSourceCode();
18
29
  const parts = node.arguments.map((argument) => {
19
30
  if (argument.type === 'Literal' && typeof argument.value === 'string') {
20
- return argument.value;
31
+ return escapeTemplateLiteral(argument.value);
21
32
  }
22
33
  return `\${${sourceCode.getText(argument)}}`;
23
34
  });
24
35
  const replacement = `\`${parts.join('/')}\``;
25
36
  context.report({
26
37
  node,
27
- message: 'Utilisez des template strings au lieu de path.join() pour la concaténation de chemins simples',
38
+ message: MESSAGE,
28
39
  fix: (fixer) => fixer.replaceText(node, replacement),
29
40
  });
30
41
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "eslint-plugin-raflint",
3
- "version": "1.5.0",
3
+ "version": "1.5.2",
4
4
  "private": false,
5
5
  "description": "",
6
6
  "keywords": [],
@@ -11,8 +11,8 @@
11
11
  "license": "ISC",
12
12
  "author": "Raphael Piccolo",
13
13
  "type": "module",
14
- "main": "./dist/index.js",
15
14
  "exports": "./dist/index.js",
15
+ "main": "./dist/index.js",
16
16
  "types": "./dist/index.d.ts",
17
17
  "files": [
18
18
  "dist"
@@ -22,37 +22,41 @@
22
22
  "cov": "c8 npm run test",
23
23
  "prepare": "husky",
24
24
  "prepublishOnly": "npm run build",
25
- "test": "SILENT=1 mocha --timeout 60000 {,lib/**/,test/**/}*.test.ts"
25
+ "test": "SILENT=1 mocha --timeout 60000 {,lib/**/,src/lib/**/,test/**/}*.test.ts"
26
26
  },
27
27
  "dependencies": {
28
28
  "@babel/eslint-parser": "^8.0.1",
29
- "eslint-plugin-n": "^18.2.1",
30
- "eslint-plugin-sonarjs": "^4.1.0",
31
- "eslint-plugin-unicorn": "^69.0.0"
29
+ "eslint-plugin-n": "^18.2.2",
30
+ "eslint-plugin-sonarjs": "^4.2.0",
31
+ "eslint-plugin-unicorn": "^72.0.0"
32
32
  },
33
33
  "devDependencies": {
34
34
  "@eslint/js": "^10.0.1",
35
- "@stoplight/spectral-cli": "^6.16.0",
36
- "c8": "^11.0.0",
35
+ "@stoplight/spectral-cli": "^6.16.2",
36
+ "c8": "^12.0.0",
37
37
  "eslint": "^10.5.0",
38
+ "eslint-import-resolver-typescript": "^4.4.5",
38
39
  "eslint-plugin-import-x": "^4.17.1",
39
40
  "eslint-plugin-promise": "^7.3.0",
40
- "eslint-plugin-raflint": "^1.4.1",
41
- "globals": "^17.7.0",
41
+ "eslint-plugin-raflint": "^1.5.1",
42
+ "eslint-plugin-react-hooks": "^7.1.1",
43
+ "globals": "^17.8.0",
42
44
  "husky": "^9.1.7",
43
- "lint-staged": "^17.0.8",
44
- "markdownlint": "^0.41.0",
45
+ "lint-staged": "^17.2.0",
46
+ "markdownlint": "^0.41.1",
45
47
  "mocha": "^11.7.6",
46
- "prettier": "^3.9.1",
48
+ "prettier": "^3.9.6",
47
49
  "ts-api-utils": "^2.5.0",
48
- "tsx": "^4.22.4",
49
- "typescript": "^6.0.3"
50
+ "tsx": "^4.23.1",
51
+ "typescript": "^6.0.3",
52
+ "typescript-eslint": "^8.65.0"
50
53
  },
51
54
  "engines": {
52
55
  "node": ">=21.0.0"
53
56
  },
54
57
  "allowScripts": {
55
58
  "unrs-resolver": true,
56
- "esbuild": true
59
+ "esbuild": true,
60
+ "@scarf/scarf": false
57
61
  }
58
62
  }