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 +12 -0
- package/TESTING.md +3 -3
- package/{testExample.js → assets/testExample.js} +2 -2
- package/eslint.config.js +225 -227
- package/package.json +19 -23
- package/rules/noPathJoin.js +12 -17
- package/test/noPathJoin.test.js +22 -2
- package/dist/bundle.cjs +0 -66
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 =
|
|
10
|
+
const filePath1 = `${directory}/${filename}`;
|
|
11
11
|
|
|
12
12
|
// Ce code sera détecté et corrigé par notre règle
|
|
13
|
-
const filePath2 =
|
|
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:
|
|
57
|
-
sourceType:
|
|
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
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
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
|
-
|
|
144
|
-
}
|
|
141
|
+
case: 'camelCase',
|
|
142
|
+
},
|
|
145
143
|
],
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
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
|
-
|
|
158
|
+
'n/shebang': 0,
|
|
161
159
|
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
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
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
}
|
|
167
|
+
functions: false,
|
|
168
|
+
classes: false,
|
|
169
|
+
variables: true,
|
|
170
|
+
allowNamedExports: false,
|
|
171
|
+
},
|
|
174
172
|
],
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
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
|
-
|
|
253
|
-
}
|
|
250
|
+
exceptions: ['Object'],
|
|
251
|
+
},
|
|
254
252
|
],
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
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
|
+
"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.
|
|
28
|
-
"
|
|
29
|
-
"eslint": "^
|
|
30
|
-
"eslint-plugin-
|
|
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": "^
|
|
37
|
-
"eslint
|
|
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.
|
|
40
|
-
"globals": "^
|
|
41
|
-
"html-validate": "^
|
|
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": "^
|
|
44
|
-
"lint-staged": "^
|
|
45
|
-
"markdownlint": "^0.
|
|
46
|
-
"mocha": "^11.
|
|
47
|
-
"prettier": "^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"
|
package/rules/noPathJoin.js
CHANGED
|
@@ -2,7 +2,7 @@ export default {
|
|
|
2
2
|
meta: {
|
|
3
3
|
type: 'suggestion',
|
|
4
4
|
docs: {
|
|
5
|
-
description: 'Disallow path.join(
|
|
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
|
-
|
|
21
|
-
node.arguments.length === 2
|
|
19
|
+
node.arguments.length >= 2
|
|
22
20
|
) {
|
|
23
|
-
const sourceCode = context.getSourceCode();
|
|
24
|
-
|
|
25
|
-
const
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
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,
|
package/test/noPathJoin.test.js
CHANGED
|
@@ -23,9 +23,9 @@ ruleTester.run('no-path-join', noPathJoin, {
|
|
|
23
23
|
`,
|
|
24
24
|
},
|
|
25
25
|
{
|
|
26
|
-
// Cas avec
|
|
26
|
+
// Cas avec un seul argument (non concerné)
|
|
27
27
|
code: `
|
|
28
|
-
const filePath = path.join(
|
|
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
|
-
};
|