eslint-plugin-raflint 1.4.0 → 1.4.1

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/eslint.config.js CHANGED
@@ -3,7 +3,7 @@ import unicorn from 'eslint-plugin-unicorn';
3
3
  import promise from 'eslint-plugin-promise';
4
4
  import n from 'eslint-plugin-n';
5
5
  import raflint from 'eslint-plugin-raflint';
6
- import pluginimport from 'eslint-plugin-import';
6
+ import pluginimport from 'eslint-plugin-import-x';
7
7
  import babelParser from '@babel/eslint-parser';
8
8
  import js from '@eslint/js';
9
9
  import globals from 'globals';
@@ -28,7 +28,7 @@ export default [
28
28
  pluginimport.flatConfigs.recommended,
29
29
 
30
30
  {
31
- ignores: ['node_modules/', 'web/', 'public/', 'coverage/', 'data/', 'vendor/', 'cypress/', 'react/', 'js/', 'assets/', '**/old/'],
31
+ ignores: ['legacy/', 'dist/', 'node_modules/', 'web/', 'public/', 'coverage/', 'data/', 'vendor/', 'react/', 'js/', 'assets/', '**/old/'],
32
32
  },
33
33
  {
34
34
  languageOptions: {
@@ -56,8 +56,8 @@ export default [
56
56
  'sonarjs/publicly-writable-directories': 0,
57
57
  'sonarjs/file-permissions': 0,
58
58
  'sonarjs/no-empty-test-file': 0,
59
- 'import/no-named-as-default-member': 0,
60
- 'import/no-unresolved': [
59
+ 'import-x/no-named-as-default-member': 0,
60
+ 'import-x/no-unresolved': [
61
61
  'error',
62
62
  {
63
63
  ignore: [
@@ -66,7 +66,11 @@ export default [
66
66
  '^@vitejs/plugin-react$',
67
67
  '^public-ip$',
68
68
  '^@modelcontextprotocol/sdk/',
69
- '^@maizzle/framework$'
69
+ '^@maizzle/framework$',
70
+ '^file-type$',
71
+ '^vite$',
72
+ '^windows-1252$',
73
+ '^csv-parse/sync$'
70
74
  ],
71
75
  },
72
76
  ],
@@ -129,18 +133,16 @@ export default [
129
133
  'unicorn/prefer-ternary': 0,
130
134
  'unicorn/prefer-top-level-await': 0,
131
135
  'unicorn/prevent-abbreviations': 0,
136
+ 'unicorn/consistent-compound-words': 0,
137
+ // ne pas retirer `undefined` passe en argument (souvent requis par la signature -> casse tsc)
138
+ 'unicorn/no-useless-undefined': ['error', { checkArguments: false }],
132
139
  'unicorn/relative-url-style': 0,
133
140
  'unicorn/switch-case-braces': 0,
134
141
  'unicorn/template-indent': 0,
135
142
  'unicorn/text-encoding-identifier-case': 0,
136
143
  'unicorn/prefer-regexp-test': 0,
137
144
  'unicorn/prefer-optional-catch-binding': 0,
138
- 'unicorn/filename-case': [
139
- 'error',
140
- {
141
- case: 'camelCase',
142
- },
143
- ],
145
+ 'unicorn/filename-case': 0,
144
146
  'sonarjs/cognitive-complexity': 0,
145
147
  'sonarjs/no-nested-template-literals': 0,
146
148
  'sonarjs/no-collapsible-if': 0,
@@ -151,6 +153,7 @@ export default [
151
153
  'sonarjs/prefer-single-boolean-return': 0,
152
154
  'n/no-unpublished-import': 0,
153
155
  'n/no-unsupported-features/es-syntax': 0,
156
+ 'n/no-unsupported-features/node-builtins': 0,
154
157
  'n/no-missing-import': 0,
155
158
  'n/no-process-exit': 0,
156
159
 
@@ -216,6 +219,7 @@ export default [
216
219
  radix: ['error', 'as-needed'],
217
220
  'prefer-regex-literals': 'error',
218
221
  'prefer-promise-reject-errors': 'error',
222
+ 'promise/catch-or-return': ['error', { terminationMethod: ['catch', 'finally'] }],
219
223
  'no-warning-comments': 'error',
220
224
  'no-void': 'error',
221
225
  'no-useless-return': 'error',
package/index.js CHANGED
@@ -7,47 +7,3 @@ export default {
7
7
  'no-path-join': noPathJoin,
8
8
  },
9
9
  };
10
-
11
- /*
12
- import path from 'node:path';
13
- import { fileURLToPath } from 'node:url';
14
- const __dirname = path.dirname(fileURLToPath(import.meta.url));
15
- import fs from 'node:fs';
16
- const { name, version } = JSON.parse(await fs.promises.readFile(`${__dirname}/package.json`));
17
-
18
- import noConditionalObjectSpread from './rules/noConditionalObjectSpread.js';
19
- import noPathJoin from './rules/noPathJoin.js';
20
-
21
- const rules = {
22
- 'no-conditional-object-spread': noConditionalObjectSpread,
23
- 'no-path-join': noPathJoin,
24
- };
25
-
26
- export default {
27
- meta: {
28
- name,
29
- version,
30
- },
31
- rules,
32
- configs: {
33
- 'flat/recommended': {
34
- plugins: {
35
- raflint: {
36
- meta: {
37
- name,
38
- version,
39
- },
40
- rules: {
41
- 'raflint/no-conditional-object-spread': "error",
42
- 'raflint/no-path-join': "error"
43
- },
44
- }
45
- },
46
- rules: {
47
- 'raflint/no-conditional-object-spread': "error",
48
- 'raflint/no-path-join': "error"
49
- },
50
- },
51
- }
52
- };
53
- */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "eslint-plugin-raflint",
3
- "version": "1.4.0",
3
+ "version": "1.4.1",
4
4
  "private": false,
5
5
  "description": "",
6
6
  "keywords": [],
@@ -14,35 +14,35 @@
14
14
  "exports": "./index.js",
15
15
  "scripts": {
16
16
  "cov": "c8 npm run test",
17
- "jest": "SILENT=1 node --no-warnings --experimental-vm-modules ./node_modules/.bin/jest",
18
17
  "prepare": "husky",
19
- "test": "SILENT=1 mocha --timeout 15000 {lib,test}/**/*.test.js"
18
+ "test": "SILENT=1 mocha --timeout 15000 {,lib/**/,test/**/}*.test.js"
20
19
  },
21
20
  "dependencies": {
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"
21
+ "@babel/eslint-parser": "^8.0.0",
22
+ "eslint-plugin-n": "^18.1.0",
23
+ "eslint-plugin-sonarjs": "^4.0.3",
24
+ "eslint-plugin-unicorn": "^67.0.0"
26
25
  },
27
26
  "devDependencies": {
28
- "@eslint/js": "^9.39.4",
29
- "@stoplight/spectral-cli": "^6.15.0",
27
+ "@eslint/js": "^10.0.1",
28
+ "@stoplight/spectral-cli": "^6.16.0",
30
29
  "c8": "^11.0.0",
31
- "eslint": "^9.39.4",
32
- "eslint-plugin-import": "^2.32.0",
33
- "eslint-plugin-promise": "^7.2.1",
34
- "eslint-plugin-raflint": "^1.3.4",
35
- "globals": "^17.4.0",
36
- "html-validate": "^10.11.2",
30
+ "eslint": "^10.5.0",
31
+ "eslint-plugin-import-x": "^4.16.2",
32
+ "eslint-plugin-promise": "^7.3.0",
33
+ "eslint-plugin-raflint": "^1.4.0",
34
+ "globals": "^17.6.0",
37
35
  "husky": "^9.1.7",
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",
36
+ "lint-staged": "^17.0.7",
37
+ "markdownlint": "^0.41.0",
38
+ "mocha": "^11.7.6",
39
+ "prettier": "^3.8.4",
43
40
  "ts-api-utils": "^2.5.0"
44
41
  },
45
42
  "engines": {
46
43
  "node": ">=21.0.0"
44
+ },
45
+ "allowScripts": {
46
+ "unrs-resolver": true
47
47
  }
48
48
  }
package/todo.txt ADDED
@@ -0,0 +1,96 @@
1
+ REVIEW DE CODE — 2026-04-26
2
+ ============================================
3
+
4
+ Plugin ESLint custom maison. Expose 2 regles :
5
+ - `no-conditional-object-spread` : interdit `{...(cond ? {x:1} : {})}`
6
+ et `{...(cond && {x:1})}`
7
+ - `no-path-join` : interdit `path.join(a, b)` au profit de
8
+ `\`${a}/${b}\`` (avec autofix).
9
+
10
+ 13+43 lignes de code metier dans rules/, 124 lignes de tests, 53
11
+ lignes (dont 42 commentees) dans index.js.
12
+
13
+ BUGS / FRAGILITE
14
+ ----------------
15
+ [ ] index.js : 42 lignes commentees (CRITIQUE de lisibilite)
16
+ index.js:11-53 : tout un bloc commente avec une version
17
+ "améliorée" du plugin (avec `meta.name`, `meta.version`,
18
+ `configs.flat/recommended`). C'est probablement la version
19
+ "qui marche" sur ESLint 9 flat config, mais elle est commentee.
20
+ L'export actuel (lignes 1-9) est minimal et ne suit pas la
21
+ convention ESLint `meta` (manque name/version). Si ESLint
22
+ detecte le plugin sans meta, certains checks (cache, dedup)
23
+ sont degrades.
24
+ A clarifier : soit reactiver le bloc commente (et garder une
25
+ seule version), soit delete le bloc inutile.
26
+
27
+ [ ] noPathJoin : autofix n'introduit pas de slash safe
28
+ rules/noPathJoin.js:25-27 : `parts.join('/')`. Si l'argument
29
+ est `path.join(__dirname, '..', 'file.js')`, le fix produit
30
+ `\`${__dirname}/../file.js\``. OK.
31
+ Mais si l'argument contient un slash final/début, doublon :
32
+ `path.join('a/', 'b')` => `\`a//b\`` (autofix incorrect).
33
+ Path.join normalise les slashs, le fix non. Edge case rare
34
+ mais reel.
35
+
36
+ [ ] noPathJoin : detection MemberExpression chain
37
+ rules/noPathJoin.js:13 : `node.callee.object.name === 'path'`.
38
+ Si import `import { join } from 'node:path'` et utilise
39
+ `join(a, b)`, pas detecte (pas de `path.join`). Fragmentation
40
+ incomplete.
41
+
42
+ [ ] noPathJoin : detection seulement "path.join(>=2 args)"
43
+ rules/noPathJoin.js:14 : `node.arguments.length >= 2`. Si
44
+ `path.join(a)` (1 seul arg), pas declenche. Mais `path.join
45
+ (a)` est en pratique inutile (path.join('foo') === 'foo'),
46
+ une regle pourrait suggerer de retirer l'appel.
47
+
48
+ [ ] noPathJoin : pas de skip pour les cas corrects
49
+ Si l'utilisateur a deliberement choisi `path.join` pour la
50
+ portabilité Windows (`\\` vs `/`), le fix le casse.
51
+ Convention de la stack : tout est sur Linux donc OK, mais
52
+ a documenter (cf README).
53
+
54
+ [ ] noConditionalObjectSpread : detection trop large
55
+ rules/noConditionalObjectSpread.js:5 : `node.argument.type
56
+ === 'ConditionalExpression' || 'LogicalExpression'`.
57
+ Detecte aussi :
58
+ const obj = { ...(a || b) };
59
+ qui est un usage VALIDE (a est preferable, sinon b). Faux
60
+ positif. A affiner : check si une des branches est `{}` ou
61
+ null/undefined.
62
+
63
+ [ ] noConditionalObjectSpread : pas d'autofix
64
+ Pas `fixable: 'code'`. Le user doit refactor a la main. Bon
65
+ point puisque le refactor change la semantique (variable de
66
+ sortie modifiee), mais le message d'erreur ne propose pas
67
+ d'alternative claire.
68
+
69
+ [ ] noConditionalObjectSpread : pas de meta
70
+ rules/noConditionalObjectSpread.js : pas de `meta` block.
71
+ Manque `meta.docs.description`, `meta.type`, etc. ESLint
72
+ plant pas, mais best practice.
73
+
74
+ CODE MORT / POLLUTION
75
+ ---------------------
76
+ [ ] assets/testExample.js
77
+ Fichier de test manuel. OK pour la documentation.
78
+
79
+ [ ] TESTING.md
80
+ Documentation manuelle separee. A consolider dans README.md.
81
+
82
+ CONVENTIONS
83
+ -----------
84
+ [ ] Mauvaise pratique : meta block manquant sur noConditionalObjectSpread
85
+ Cf bugs.
86
+
87
+ [ ] Pas de versioning des rules
88
+ 1.4.0 mais pas de breaking change tracking. Si on rend la
89
+ detection plus stricte, casse les CI des consommateurs.
90
+
91
+ DECISION SUGGEREE
92
+ -----------------
93
+ [ ] Trancher index.js : la version commentee semble plus complete.
94
+ Migrer vers la version commentee (avec meta + configs/flat/
95
+ recommended), tester sur 2-3 projets consommateurs, release
96
+ 1.5.0.
package/jest.config.js DELETED
@@ -1,4 +0,0 @@
1
- export default {
2
- transform: {},
3
- testTimeout: 60_000,
4
- };