eslint-plugin-raflint 1.3.2 → 1.4.0

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.
package/README.md CHANGED
@@ -29,3 +29,15 @@ Les utilisations de `path.join()` avec deux arguments qui peuvent être remplac
29
29
  qui devrait être écrites comme ça:
30
30
 
31
31
  const filePath = `${directory}/${filename}`;
32
+
33
+ # tester le plugin sur un projet
34
+
35
+ on peut se mettre dans le dossier ou on veut utiliser le plugin pui lancer :
36
+
37
+ npm link ../pathDuPlugin
38
+ on peut ensuite le voir comme ça
39
+
40
+ npm ls --link
41
+ puis enlever le link
42
+
43
+ npm unlink xxx
package/TESTING.md CHANGED
@@ -1,12 +1,12 @@
1
1
  # Comment tester la règle no-path-join
2
2
  ## Test manuel avec le fichier d'exemple
3
3
 
4
- Un fichier d'exemple `testExample.js` a été créé pour démontrer le fonctionnement de la règle. Pour tester manuellement:
4
+ Un fichier d'exemple `assets/testExample.js` a été créé pour démontrer le fonctionnement de la règle. Pour tester manuellement:
5
5
 
6
6
  1. Vérifier que la règle détecte les problèmes:
7
7
 
8
8
  ```bash
9
- npx eslint -c eslinttest.config.js testExample.js
9
+ npx eslint -c eslinttest.config.js assets/testExample.js
10
10
  ```
11
11
 
12
12
  Vous devriez voir des erreurs pour les lignes contenant `path.join(directory, filename)` et `path.join(process.cwd(), 'file.txt')`.
@@ -14,5 +14,5 @@ Vous devriez voir des erreurs pour les lignes contenant `path.join(directory, fi
14
14
  2. Vérifier que la règle corrige automatiquement le code:
15
15
 
16
16
  ```bash
17
- npx eslint -c eslinttest.config.js testExample.js --fix
17
+ npx eslint -c eslinttest.config.js assets/testExample.js --fix
18
18
  ```
@@ -7,10 +7,10 @@ const filename = 'file.txt';
7
7
  const root = '/';
8
8
 
9
9
  // Ce code sera détecté et corrigé par notre règle
10
- const filePath1 = path.join(directory, filename);
10
+ const filePath1 = `${directory}/${filename}`;
11
11
 
12
12
  // Ce code sera détecté et corrigé par notre règle
13
- const filePath2 = path.join(process.cwd(), 'file.txt');
13
+ const filePath2 = `${process.cwd()}/file.txt`;
14
14
 
15
15
  // Ce code ne sera pas détecté car il a plus de 2 arguments
16
16
  const filePath3 = path.join(root, directory, filename);
package/eslint.config.js CHANGED
@@ -8,8 +8,6 @@ import babelParser from '@babel/eslint-parser';
8
8
  import js from '@eslint/js';
9
9
  import globals from 'globals';
10
10
 
11
-
12
-
13
11
  export default [
14
12
  // eslint:recommended,
15
13
  js.configs.recommended,
@@ -30,19 +28,7 @@ export default [
30
28
  pluginimport.flatConfigs.recommended,
31
29
 
32
30
  {
33
- ignores: [
34
- "node_modules/",
35
- "web/",
36
- "public/",
37
- "coverage/",
38
- "data/",
39
- "vendor/",
40
- "cypress/",
41
- "react/",
42
- "js/",
43
- "assets/",
44
- "**/old/",
45
- ],
31
+ ignores: ['node_modules/', 'web/', 'public/', 'coverage/', 'data/', 'vendor/', 'cypress/', 'react/', 'js/', 'assets/', '**/old/'],
46
32
  },
47
33
  {
48
34
  languageOptions: {
@@ -53,8 +39,8 @@ export default [
53
39
  },
54
40
  parser: babelParser,
55
41
  parserOptions: {
56
- ecmaVersion: "latest",
57
- sourceType: "module",
42
+ ecmaVersion: 'latest',
43
+ sourceType: 'module',
58
44
  requireConfigFile: false,
59
45
  },
60
46
  },
@@ -62,223 +48,235 @@ export default [
62
48
  raflint,
63
49
  },
64
50
  rules: {
65
- "sonarjs/no-empty-function": 0,
66
- "sonarjs/no-unused-expressions": 0,
67
- "sonarjs/no-unsafe-unzip": 0,
68
- "sonarjs/os-command": 0,
69
- "sonarjs/cors": 0,
70
- "sonarjs/publicly-writable-directories": 0,
71
- "sonarjs/file-permissions": 0,
72
- "sonarjs/no-empty-test-file": 0,
73
- "import/no-named-as-default-member": 0,
74
- "sonarjs/regex-complexity": 0,
75
- "sonarjs/no-clear-text-protocols": 0,
76
- "sonarjs/no-infinite-loop": 0,
77
- "sonarjs/no-hardcoded-ip": 0,
78
- "sonarjs/pluginRules-of-hooks": 0,
79
- "sonarjs/sonar-no-fallthrough": 0,
80
- "sonarjs/no-ignored-exceptions": 0,
81
- "sonarjs/slow-regex": 0,
82
- "sonarjs/concise-regex": 0,
83
- "sonarjs/hashing": 0,
84
- "sonarjs/no-dead-store": 0,
85
- "sonarjs/no-unused-vars": 0,
86
- "sonarjs/no-hardcoded-passwords": 0,
87
- "sonarjs/no-hardcoded-secrets": 0,
88
- "sonarjs/unnecessary-character-escapes": 0,
89
- "sonarjs/pseudo-random": 0,
90
- "sonarjs/no-os-command-from-path": 0,
91
- "sonarjs/anchor-precedence": 0,
92
- "sonarjs/no-nested-functions": 0,
93
- "sonarjs/new-cap": 0,
94
- "sonarjs/sql-queries": 0,
95
- "sonarjs/content-length": 0,
96
- "sonarjs/no-commented-code": 0,
97
- "raflint/no-conditional-object-spread": ["error"],
98
- "raflint/no-path-join": ["error"],
99
- // "import/no-named-as-default-member": 0,
100
- "unicorn/prefer-event-target": 0,
101
- "unicorn/prefer-structured-clone": 0,
102
- "unicorn/prefer-string-raw": 0,
103
- "unicorn/no-anonymous-default-export": 0,
104
- "unicorn/better-regex": 0,
105
- "unicorn/catch-error-name": 0,
106
- "unicorn/consistent-function-scoping": 0,
107
- "unicorn/expiring-todo-comments": 0,
108
- "unicorn/explicit-length-check": 0,
109
- "unicorn/import-style": 0,
110
- "unicorn/no-array-for-each": 0,
111
- "unicorn/prefer-single-call": 0,
112
- "unicorn/no-array-reduce": 0,
113
- "unicorn/no-lonely-if": 0,
114
- "unicorn/no-negated-condition": 0,
115
- "unicorn/no-null": 0,
116
- "unicorn/no-process-exit": 0,
117
- "unicorn/no-this-assignment": 0,
118
- "unicorn/no-unnecessary-await": 0,
119
- "unicorn/no-unused-properties": 0,
120
- "unicorn/prefer-code-point": 0,
121
- "unicorn/prefer-default-parameters": 0,
122
- "unicorn/prefer-export-from": 0,
123
- "unicorn/prefer-native-coercion-functions": 0,
124
- "unicorn/prefer-number-properties": 0,
125
- "unicorn/prefer-set-has": 0,
126
- "unicorn/prefer-set-size": 0,
127
- "unicorn/prefer-spread": 0,
128
- "unicorn/prefer-string-replace-all": 0,
129
- "unicorn/prefer-string-slice": 0,
130
- "unicorn/prefer-switch": 0,
131
- "unicorn/prefer-ternary": 0,
132
- "unicorn/prefer-top-level-await": 0,
133
- "unicorn/prevent-abbreviations": 0,
134
- "unicorn/relative-url-style": 0,
135
- "unicorn/switch-case-braces": 0,
136
- "unicorn/template-indent": 0,
137
- "unicorn/text-encoding-identifier-case": 0,
138
- "unicorn/prefer-regexp-test": 0,
139
- "unicorn/prefer-optional-catch-binding": 0,
140
- "unicorn/filename-case": [
141
- "error",
51
+ 'sonarjs/no-empty-function': 0,
52
+ 'sonarjs/no-unused-expressions': 0,
53
+ 'sonarjs/no-unsafe-unzip': 0,
54
+ 'sonarjs/os-command': 0,
55
+ 'sonarjs/cors': 0,
56
+ 'sonarjs/publicly-writable-directories': 0,
57
+ 'sonarjs/file-permissions': 0,
58
+ 'sonarjs/no-empty-test-file': 0,
59
+ 'import/no-named-as-default-member': 0,
60
+ 'import/no-unresolved': [
61
+ 'error',
62
+ {
63
+ ignore: [
64
+ '^yargs/helpers$',
65
+ '^p-queue$',
66
+ '^@vitejs/plugin-react$',
67
+ '^public-ip$',
68
+ '^@modelcontextprotocol/sdk/',
69
+ '^@maizzle/framework$'
70
+ ],
71
+ },
72
+ ],
73
+ 'sonarjs/regex-complexity': 0,
74
+ 'sonarjs/no-clear-text-protocols': 0,
75
+ 'sonarjs/no-infinite-loop': 0,
76
+ 'sonarjs/no-hardcoded-ip': 0,
77
+ 'sonarjs/pluginRules-of-hooks': 0,
78
+ 'sonarjs/sonar-no-fallthrough': 0,
79
+ 'sonarjs/no-ignored-exceptions': 0,
80
+ 'sonarjs/slow-regex': 0,
81
+ 'sonarjs/concise-regex': 0,
82
+ 'sonarjs/hashing': 0,
83
+ 'sonarjs/no-dead-store': 0,
84
+ 'sonarjs/no-unused-vars': 0,
85
+ 'sonarjs/no-hardcoded-passwords': 0,
86
+ 'sonarjs/no-hardcoded-secrets': 0,
87
+ 'sonarjs/unnecessary-character-escapes': 0,
88
+ 'sonarjs/pseudo-random': 0,
89
+ 'sonarjs/no-os-command-from-path': 0,
90
+ 'sonarjs/anchor-precedence': 0,
91
+ 'sonarjs/no-nested-functions': 0,
92
+ 'sonarjs/new-cap': 0,
93
+ 'sonarjs/sql-queries': 0,
94
+ 'sonarjs/content-length': 0,
95
+ 'sonarjs/no-commented-code': 0,
96
+ 'raflint/no-conditional-object-spread': ['error'],
97
+ 'raflint/no-path-join': ['error'],
98
+ 'unicorn/prefer-event-target': 0,
99
+ 'unicorn/prefer-structured-clone': 0,
100
+ 'unicorn/prefer-string-raw': 0,
101
+ 'unicorn/no-anonymous-default-export': 0,
102
+ 'unicorn/better-regex': 0,
103
+ 'unicorn/catch-error-name': 0,
104
+ 'unicorn/consistent-function-scoping': 0,
105
+ 'unicorn/expiring-todo-comments': 0,
106
+ 'unicorn/explicit-length-check': 0,
107
+ 'unicorn/import-style': 0,
108
+ 'unicorn/no-array-for-each': 0,
109
+ 'unicorn/prefer-single-call': 0,
110
+ 'unicorn/no-array-reduce': 0,
111
+ 'unicorn/no-lonely-if': 0,
112
+ 'unicorn/no-negated-condition': 0,
113
+ 'unicorn/no-null': 0,
114
+ 'unicorn/no-process-exit': 0,
115
+ 'unicorn/no-this-assignment': 0,
116
+ 'unicorn/no-unnecessary-await': 0,
117
+ 'unicorn/no-unused-properties': 0,
118
+ 'unicorn/prefer-code-point': 0,
119
+ 'unicorn/prefer-default-parameters': 0,
120
+ 'unicorn/prefer-export-from': 0,
121
+ 'unicorn/prefer-native-coercion-functions': 0,
122
+ 'unicorn/prefer-number-properties': 0,
123
+ 'unicorn/prefer-set-has': 0,
124
+ 'unicorn/prefer-set-size': 0,
125
+ 'unicorn/prefer-spread': 0,
126
+ 'unicorn/prefer-string-replace-all': 0,
127
+ 'unicorn/prefer-string-slice': 0,
128
+ 'unicorn/prefer-switch': 0,
129
+ 'unicorn/prefer-ternary': 0,
130
+ 'unicorn/prefer-top-level-await': 0,
131
+ 'unicorn/prevent-abbreviations': 0,
132
+ 'unicorn/relative-url-style': 0,
133
+ 'unicorn/switch-case-braces': 0,
134
+ 'unicorn/template-indent': 0,
135
+ 'unicorn/text-encoding-identifier-case': 0,
136
+ 'unicorn/prefer-regexp-test': 0,
137
+ 'unicorn/prefer-optional-catch-binding': 0,
138
+ 'unicorn/filename-case': [
139
+ 'error',
142
140
  {
143
- "case": "camelCase"
144
- }
141
+ case: 'camelCase',
142
+ },
145
143
  ],
146
- "sonarjs/cognitive-complexity": 0,
147
- "sonarjs/no-nested-template-literals": 0,
148
- "sonarjs/no-collapsible-if": 0,
149
- "sonarjs/no-duplicate-string": 0,
150
- "sonarjs/prefer-immediate-return": 0,
151
- "sonarjs/no-identical-functions": 0,
152
- "sonarjs/prefer-object-literal": 0,
153
- "sonarjs/prefer-single-boolean-return": 0,
154
- "n/no-unpublished-import": 0,
155
- "n/no-unsupported-features/es-syntax": 0,
156
- "n/no-missing-import": 0,
157
- "n/no-process-exit": 0,
158
-
144
+ 'sonarjs/cognitive-complexity': 0,
145
+ 'sonarjs/no-nested-template-literals': 0,
146
+ 'sonarjs/no-collapsible-if': 0,
147
+ 'sonarjs/no-duplicate-string': 0,
148
+ 'sonarjs/prefer-immediate-return': 0,
149
+ 'sonarjs/no-identical-functions': 0,
150
+ 'sonarjs/prefer-object-literal': 0,
151
+ 'sonarjs/prefer-single-boolean-return': 0,
152
+ 'n/no-unpublished-import': 0,
153
+ 'n/no-unsupported-features/es-syntax': 0,
154
+ 'n/no-missing-import': 0,
155
+ 'n/no-process-exit': 0,
156
+
159
157
  // si on l'active ça pose pb dans check / automerge
160
- "n/shebang": 0,
158
+ 'n/shebang': 0,
161
159
 
162
- "one-var-declaration-per-line": ["error", "always"],
163
- "one-var": ["error", "never"],
164
- "no-unused-expressions": "error",
165
- "no-nested-ternary": "error",
166
- "no-use-before-define": [
167
- "error",
160
+ 'one-var-declaration-per-line': ['error', 'always'],
161
+ 'one-var': ['error', 'never'],
162
+ 'no-unused-expressions': 'error',
163
+ 'no-nested-ternary': 'error',
164
+ 'no-use-before-define': [
165
+ 'error',
168
166
  {
169
- "functions": false,
170
- "classes": false,
171
- "variables": true,
172
- "allowNamedExports": false
173
- }
167
+ functions: false,
168
+ classes: false,
169
+ variables: true,
170
+ allowNamedExports: false,
171
+ },
174
172
  ],
175
- "no-new-native-nonconstructor": "error",
176
- "no-empty-static-block": "error",
177
- "symbol-description": "error",
178
- "require-yield": "error",
179
- "prefer-spread": "error",
180
- "prefer-rest-params": "error",
181
- "prefer-object-spread": "error",
182
- "prefer-object-has-own": "error",
183
- "prefer-numeric-literals": "error",
184
- "prefer-exponentiation-operator": "error",
185
- "operator-assignment": "error",
186
- "no-useless-rename": "error",
187
- "no-useless-constructor": "error",
188
- "no-useless-computed-key": "error",
189
- "no-unused-labels": "error",
190
- "no-script-url": "error",
191
- "no-new-object": "error",
192
- "no-multi-assign": "error",
193
- "no-loop-func": "error",
194
- "no-inline-comments": "error",
195
- "no-implicit-coercion": "error",
196
- "no-extra-boolean-cast": "error",
197
- "no-confusing-arrow": "error",
198
- "no-case-declarations": "error",
199
- "no-bitwise": "error",
200
- "no-array-constructor": "error",
201
- "no-alert": "error",
202
- "logical-assignment-operators": "error",
203
- "grouped-accessor-pairs": "error",
204
- "func-name-matching": "error",
205
- "dot-notation": "error",
206
- "consistent-this": ["error", "self"],
207
- "accessor-pairs": "error",
208
- "no-unused-private-class-members": "error",
209
- "no-promise-executor-return": "error",
210
- "no-duplicate-imports": "error",
211
- "no-constant-binary-expression": "error",
212
- "no-undef-init": "error",
213
- "no-label-var": "error",
214
- "init-declarations": ["error", "always"],
215
- "wrap-iife": ["error", "inside"],
216
- "yoda": "error",
217
- "vars-on-top": "error",
218
- "radix": ["error", "as-needed"],
219
- "prefer-regex-literals": "error",
220
- "prefer-promise-reject-errors": "error",
221
- "no-warning-comments": "error",
222
- "no-void": "error",
223
- "no-useless-return": "error",
224
- "no-useless-concat": "error",
225
- "no-useless-call": "error",
226
- "no-throw-literal": "error",
227
- "no-sequences": "error",
228
- "no-self-compare": "error",
229
- "no-return-assign": "error",
230
- "no-proto": "error",
231
- "no-octal-escape": "error",
232
- "no-nonoctal-decimal-escape": "error",
233
- "no-new-wrappers": "error",
234
- "no-new-func": "error",
235
- "no-new": "error",
236
- "no-multi-str": "error",
237
- "no-multi-spaces": "error",
238
- "no-lone-blocks": "error",
239
- "no-labels": "error",
240
- "no-iterator": "error",
241
- "no-empty-function": "error",
242
- "block-scoped-var": "error",
243
- "prefer-arrow-callback": "error",
244
- "no-implied-eval": "error",
245
- "no-implicit-globals": "error",
246
- "no-floating-decimal": "error",
247
- "no-extra-label": "error",
248
- "no-extra-bind": "error",
249
- "no-extend-native": [
250
- "error",
173
+ 'no-new-native-nonconstructor': 'error',
174
+ 'no-empty-static-block': 'error',
175
+ 'symbol-description': 'error',
176
+ 'require-yield': 'error',
177
+ 'prefer-spread': 'error',
178
+ 'prefer-rest-params': 'error',
179
+ 'prefer-object-spread': 'error',
180
+ 'prefer-object-has-own': 'error',
181
+ 'prefer-numeric-literals': 'error',
182
+ 'prefer-exponentiation-operator': 'error',
183
+ 'operator-assignment': 'error',
184
+ 'no-useless-rename': 'error',
185
+ 'no-useless-constructor': 'error',
186
+ 'no-useless-computed-key': 'error',
187
+ 'no-unused-labels': 'error',
188
+ 'no-script-url': 'error',
189
+ 'no-new-object': 'error',
190
+ 'no-multi-assign': 'error',
191
+ 'no-loop-func': 'error',
192
+ 'no-inline-comments': 'error',
193
+ 'no-implicit-coercion': 'error',
194
+ 'no-extra-boolean-cast': 'error',
195
+ 'no-confusing-arrow': 'error',
196
+ 'no-case-declarations': 'error',
197
+ 'no-bitwise': 'error',
198
+ 'no-array-constructor': 'error',
199
+ 'no-alert': 'error',
200
+ 'logical-assignment-operators': 'error',
201
+ 'grouped-accessor-pairs': 'error',
202
+ 'func-name-matching': 'error',
203
+ 'dot-notation': 'error',
204
+ 'consistent-this': ['error', 'self'],
205
+ 'accessor-pairs': 'error',
206
+ 'no-unused-private-class-members': 'error',
207
+ 'no-promise-executor-return': 'error',
208
+ 'no-duplicate-imports': 'error',
209
+ 'no-constant-binary-expression': 'error',
210
+ 'no-undef-init': 'error',
211
+ 'no-label-var': 'error',
212
+ 'init-declarations': ['error', 'always'],
213
+ 'wrap-iife': ['error', 'inside'],
214
+ yoda: 'error',
215
+ 'vars-on-top': 'error',
216
+ radix: ['error', 'as-needed'],
217
+ 'prefer-regex-literals': 'error',
218
+ 'prefer-promise-reject-errors': 'error',
219
+ 'no-warning-comments': 'error',
220
+ 'no-void': 'error',
221
+ 'no-useless-return': 'error',
222
+ 'no-useless-concat': 'error',
223
+ 'no-useless-call': 'error',
224
+ 'no-throw-literal': 'error',
225
+ 'no-sequences': 'error',
226
+ 'no-self-compare': 'error',
227
+ 'no-return-assign': 'error',
228
+ 'no-proto': 'error',
229
+ 'no-octal-escape': 'error',
230
+ 'no-nonoctal-decimal-escape': 'error',
231
+ 'no-new-wrappers': 'error',
232
+ 'no-new-func': 'error',
233
+ 'no-new': 'error',
234
+ 'no-multi-str': 'error',
235
+ 'no-multi-spaces': 'error',
236
+ 'no-lone-blocks': 'error',
237
+ 'no-labels': 'error',
238
+ 'no-iterator': 'error',
239
+ 'no-empty-function': 'error',
240
+ 'block-scoped-var': 'error',
241
+ 'prefer-arrow-callback': 'error',
242
+ 'no-implied-eval': 'error',
243
+ 'no-implicit-globals': 'error',
244
+ 'no-floating-decimal': 'error',
245
+ 'no-extra-label': 'error',
246
+ 'no-extra-bind': 'error',
247
+ 'no-extend-native': [
248
+ 'error',
251
249
  {
252
- "exceptions": ["Object"]
253
- }
250
+ exceptions: ['Object'],
251
+ },
254
252
  ],
255
- "no-eval": "error",
256
- "no-constant-condition": ["error", { "checkLoops": false }],
257
- "no-eq-null": "error",
258
- "no-else-return": "error",
259
- "no-unused-vars": 0,
260
- "no-console": 0,
261
- "no-empty": 0,
262
- "no-redeclare": 0,
263
- "no-useless-escape": 0,
264
- "no-var": "error",
265
- "object-shorthand": ["error", "properties"],
266
- "prefer-template": "error",
267
- "no-div-regex": "error",
268
- "no-constructor-return": "error",
269
- "no-caller": "error",
270
- "max-classes-per-file": "error",
271
- "default-param-last": "error",
272
- "default-case-last": "error",
273
- "default-case": "error",
274
- "array-callback-return": "error",
275
- "no-unsafe-optional-chaining": "error",
276
- "no-unreachable-loop": "error",
277
- "no-template-curly-in-string": "error",
278
- "no-loss-of-precision": "error",
279
- "no-inner-declarations": 0,
280
- "no-process-exit": 0,
281
- "prefer-const": ["error", { "destructuring": "all" }]
253
+ 'no-eval': 'error',
254
+ 'no-constant-condition': ['error', { checkLoops: false }],
255
+ 'no-eq-null': 'error',
256
+ 'no-else-return': 'error',
257
+ 'no-unused-vars': 0,
258
+ 'no-console': 0,
259
+ 'no-empty': 0,
260
+ 'no-redeclare': 0,
261
+ 'no-useless-escape': 0,
262
+ 'no-var': 'error',
263
+ 'object-shorthand': ['error', 'properties'],
264
+ 'prefer-template': 'error',
265
+ 'no-div-regex': 'error',
266
+ 'no-constructor-return': 'error',
267
+ 'no-caller': 'error',
268
+ 'max-classes-per-file': 'error',
269
+ 'default-param-last': 'error',
270
+ 'default-case-last': 'error',
271
+ 'default-case': 'error',
272
+ 'array-callback-return': 'error',
273
+ 'no-unsafe-optional-chaining': 'error',
274
+ 'no-unreachable-loop': 'error',
275
+ 'no-template-curly-in-string': 'error',
276
+ 'no-loss-of-precision': 'error',
277
+ 'no-inner-declarations': 0,
278
+ 'no-process-exit': 0,
279
+ 'prefer-const': ['error', { destructuring: 'all' }],
282
280
  },
283
- }
281
+ },
284
282
  ];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "eslint-plugin-raflint",
3
- "version": "1.3.2",
3
+ "version": "1.4.0",
4
4
  "private": false,
5
5
  "description": "",
6
6
  "keywords": [],
@@ -11,12 +11,7 @@
11
11
  "license": "ISC",
12
12
  "author": "Raphael Piccolo",
13
13
  "type": "module",
14
- "exports": {
15
- ".": {
16
- "require": "./dist/bundle.cjs",
17
- "import": "./index.js"
18
- }
19
- },
14
+ "exports": "./index.js",
20
15
  "scripts": {
21
16
  "cov": "c8 npm run test",
22
17
  "jest": "SILENT=1 node --no-warnings --experimental-vm-modules ./node_modules/.bin/jest",
@@ -24,27 +19,28 @@
24
19
  "test": "SILENT=1 mocha --timeout 15000 {lib,test}/**/*.test.js"
25
20
  },
26
21
  "dependencies": {
27
- "@babel/eslint-parser": "^7.27.1",
28
- "@eslint/js": "^9.26.0",
29
- "eslint": "^9.26.0",
30
- "eslint-plugin-n": "^17.17.0",
31
- "eslint-plugin-sonarjs": "^3.0.2",
32
- "eslint-plugin-unicorn": "^59.0.0"
22
+ "@babel/eslint-parser": "^7.28.6",
23
+ "eslint-plugin-n": "^17.24.0",
24
+ "eslint-plugin-sonarjs": "^4.0.2",
25
+ "eslint-plugin-unicorn": "^64.0.0"
33
26
  },
34
27
  "devDependencies": {
28
+ "@eslint/js": "^9.39.4",
35
29
  "@stoplight/spectral-cli": "^6.15.0",
36
- "c8": "^10.1.3",
37
- "eslint-plugin-import": "^2.31.0",
30
+ "c8": "^11.0.0",
31
+ "eslint": "^9.39.4",
32
+ "eslint-plugin-import": "^2.32.0",
38
33
  "eslint-plugin-promise": "^7.2.1",
39
- "eslint-plugin-raflint": "^1.3.0",
40
- "globals": "^16.0.0",
41
- "html-validate": "^9.5.3",
34
+ "eslint-plugin-raflint": "^1.3.4",
35
+ "globals": "^17.4.0",
36
+ "html-validate": "^10.11.2",
42
37
  "husky": "^9.1.7",
43
- "jest": "^29.7.0",
44
- "lint-staged": "^15.5.1",
45
- "markdownlint": "^0.38.0",
46
- "mocha": "^11.2.2",
47
- "prettier": "^3.5.3"
38
+ "jest": "^30.3.0",
39
+ "lint-staged": "^16.4.0",
40
+ "markdownlint": "^0.40.0",
41
+ "mocha": "^11.7.5",
42
+ "prettier": "^3.8.1",
43
+ "ts-api-utils": "^2.5.0"
48
44
  },
49
45
  "engines": {
50
46
  "node": ">=21.0.0"
@@ -2,7 +2,7 @@ export default {
2
2
  meta: {
3
3
  type: 'suggestion',
4
4
  docs: {
5
- description: 'Disallow path.join(a, b) in favor of template strings',
5
+ description: 'Disallow path.join() in favor of template strings',
6
6
  category: 'Stylistic Issues',
7
7
  recommended: true,
8
8
  },
@@ -12,27 +12,22 @@ export default {
12
12
  create(context) {
13
13
  return {
14
14
  CallExpression(node) {
15
- // Vérifier si c'est un appel à path.join
16
15
  if (
17
16
  node.callee.type === 'MemberExpression' &&
18
17
  node.callee.object.name === 'path' &&
19
18
  node.callee.property.name === 'join' &&
20
- // Uniquement pour les cas avec exactement 2 arguments
21
- node.arguments.length === 2
19
+ node.arguments.length >= 2
22
20
  ) {
23
- const sourceCode = context.getSourceCode();
24
- const arg1 = sourceCode.getText(node.arguments[0]);
25
- const arg2 = sourceCode.getText(node.arguments[1]);
26
-
27
- // Vérifier si le second argument est une chaîne littérale
28
- let replacement;
29
- if (node.arguments[1].type === 'Literal' && typeof node.arguments[1].value === 'string') {
30
- // Si c'est une chaîne littérale, l'inclure directement sans ${}
31
- replacement = `\`\${${arg1}}/${node.arguments[1].value}\``;
32
- } else {
33
- // Sinon, utiliser le format standard avec ${}
34
- replacement = `\`\${${arg1}}/\${${arg2}}\``;
35
- }
21
+ const sourceCode = context.sourceCode ?? context.getSourceCode();
22
+
23
+ const parts = node.arguments.map((arg) => {
24
+ if (arg.type === 'Literal' && typeof arg.value === 'string') {
25
+ return arg.value;
26
+ }
27
+ return `\${${sourceCode.getText(arg)}}`;
28
+ });
29
+
30
+ const replacement = `\`${parts.join('/')}\``;
36
31
 
37
32
  context.report({
38
33
  node,
@@ -23,9 +23,9 @@ ruleTester.run('no-path-join', noPathJoin, {
23
23
  `,
24
24
  },
25
25
  {
26
- // Cas avec plus de 2 arguments (non concerné par la règle)
26
+ // Cas avec un seul argument (non concerné)
27
27
  code: `
28
- const filePath = path.join(root, directory, filename);
28
+ const filePath = path.join(directory);
29
29
  `,
30
30
  },
31
31
  {
@@ -54,5 +54,25 @@ ruleTester.run('no-path-join', noPathJoin, {
54
54
  const filePath = \`\${process.cwd()}/file.txt\`;
55
55
  `,
56
56
  },
57
+ {
58
+ // 3 arguments
59
+ code: `
60
+ const filePath = path.join(root, directory, filename);
61
+ `,
62
+ errors: [{ message: 'Utilisez des template strings au lieu de path.join() pour la concaténation de chemins simples' }],
63
+ output: `
64
+ const filePath = \`\${root}/\${directory}/\${filename}\`;
65
+ `,
66
+ },
67
+ {
68
+ // Mix variables et littéraux
69
+ code: `
70
+ const filePath = path.join(root, 'uploads', filename);
71
+ `,
72
+ errors: [{ message: 'Utilisez des template strings au lieu de path.join() pour la concaténation de chemins simples' }],
73
+ output: `
74
+ const filePath = \`\${root}/uploads/\${filename}\`;
75
+ `,
76
+ },
57
77
  ],
58
78
  });
package/dist/bundle.cjs DELETED
@@ -1,66 +0,0 @@
1
- module.exports = {
2
- rules: {
3
- 'no-conditional-object-spread': {
4
- create(context) {
5
- return {
6
- SpreadElement(node) {
7
- if (node.argument.type === 'ConditionalExpression' || node.argument.type === 'LogicalExpression') {
8
- context.report({
9
- node,
10
- message: 'Conditional object spread is not allowed.',
11
- });
12
- }
13
- },
14
- };
15
- },
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
- },
65
- },
66
- };