eslint-config-maedow-arch 0.1.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/LICENSE +21 -0
- package/README.md +63 -0
- package/index.js +112 -0
- package/package.json +43 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Jean-Marc
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
# eslint-config-maedow-arch
|
|
2
|
+
|
|
3
|
+
Règles ESLint officielles de [Maedow Arch](https://github.com/maedow-arch/maedow-arch-docs) : enforce les frontières entre `app`, `features`, `core`, `components` et `lib` via [`eslint-plugin-boundaries`](https://www.jsboundaries.dev/).
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install --save-dev eslint-config-maedow-arch eslint-plugin-boundaries eslint-import-resolver-typescript
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
> **`eslint-import-resolver-typescript` n'est pas optionnel.** Sans résolveur TypeScript, les imports `.ts`/`.tsx` sont classés « unknown » par le plugin et **aucune règle ne se déclenche** : le lint passe au vert sans rien vérifier. C'est le mode de défaillance le plus sournois de ce type de configuration.
|
|
12
|
+
|
|
13
|
+
## Usage
|
|
14
|
+
|
|
15
|
+
```js
|
|
16
|
+
// eslint.config.mjs
|
|
17
|
+
import maedowArchConfig from "eslint-config-maedow-arch";
|
|
18
|
+
|
|
19
|
+
export default [
|
|
20
|
+
...maedowArchConfig,
|
|
21
|
+
// tes règles additionnelles ici
|
|
22
|
+
];
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
La config n'impose pas de parser : apporte le tien (`typescript-eslint` dans un projet TypeScript).
|
|
26
|
+
|
|
27
|
+
## Ce que ça enforce
|
|
28
|
+
|
|
29
|
+
Le flux de dépendance est unidirectionnel — `app → features → core → lib` :
|
|
30
|
+
|
|
31
|
+
| Depuis | Peut importer |
|
|
32
|
+
| :--- | :--- |
|
|
33
|
+
| `app/` | tout |
|
|
34
|
+
| `features/<x>/` | `features/_shared/`, `core/`, `components/`, `lib/`, et **sa propre feature** |
|
|
35
|
+
| `features/_shared/` | `core/`, `components/`, `lib/` — jamais une feature |
|
|
36
|
+
| `core/` | `core/`, `lib/` — **zéro dépendance UI** |
|
|
37
|
+
| `components/` | `components/`, `lib/` |
|
|
38
|
+
| `lib/` | `lib/` uniquement |
|
|
39
|
+
|
|
40
|
+
Une violation produit un message explicite :
|
|
41
|
+
|
|
42
|
+
```
|
|
43
|
+
Maedow Arch : core ne peut pas importer components. Voir architecture.md §6.
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
## Dispositions supportées
|
|
47
|
+
|
|
48
|
+
Les patterns ne sont pas ancrés à la racine du projet : `core/` et `src/core/` fonctionnent tous les deux, sans configuration supplémentaire.
|
|
49
|
+
|
|
50
|
+
## Vérifier que les frontières sont bien actives
|
|
51
|
+
|
|
52
|
+
Une config de frontières qui ne matche rien passe au vert. Le seul test qui prouve quelque chose est le test **négatif** : ajoute temporairement un import interdit et vérifie qu'ESLint échoue.
|
|
53
|
+
|
|
54
|
+
```ts
|
|
55
|
+
// src/core/billing/service.ts
|
|
56
|
+
import { Button } from "../../components/ui/Button"; // doit lever une erreur
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
Ce package embarque ce test — voir `test/run.mjs`, lancé par `npm run test:boundaries` à la racine du dépôt.
|
|
60
|
+
|
|
61
|
+
## Licence
|
|
62
|
+
|
|
63
|
+
MIT
|
package/index.js
ADDED
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import boundaries from "eslint-plugin-boundaries";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Configuration ESLint officielle de Maedow Arch.
|
|
5
|
+
* Enforce le flux de dépendance unidirectionnel :
|
|
6
|
+
*
|
|
7
|
+
* app → features → core → lib
|
|
8
|
+
*
|
|
9
|
+
* Usage dans eslint.config.mjs :
|
|
10
|
+
* import maedowArchConfig from "eslint-config-maedow-arch";
|
|
11
|
+
* export default [...maedowArchConfig];
|
|
12
|
+
*
|
|
13
|
+
* ⚠️ Deux points qui font échouer silencieusement une config boundaries :
|
|
14
|
+
*
|
|
15
|
+
* 1. L'ORDRE des éléments compte — le premier pattern qui matche gagne.
|
|
16
|
+
* `shared-feature` doit précéder `feature`, sinon `features/_shared/`
|
|
17
|
+
* serait classé comme une feature ordinaire et sa règle serait morte.
|
|
18
|
+
*
|
|
19
|
+
* 2. La RÉSOLUTION des imports doit connaître TypeScript. Sans résolveur TS,
|
|
20
|
+
* les imports `.ts`/`.tsx` sont classés « unknown » et AUCUNE règle ne se
|
|
21
|
+
* déclenche — le lint passe au vert sans rien vérifier. D'où la
|
|
22
|
+
* peerDependency `eslint-import-resolver-typescript`.
|
|
23
|
+
*
|
|
24
|
+
* Les patterns ne sont pas ancrés à la racine : ils matchent le segment
|
|
25
|
+
* correspondant où qu'il soit. `core` couvre donc aussi bien `core/` que
|
|
26
|
+
* `src/core/`.
|
|
27
|
+
*/
|
|
28
|
+
export default [
|
|
29
|
+
{
|
|
30
|
+
files: ["**/*.{js,jsx,ts,tsx,mjs,cjs}"],
|
|
31
|
+
plugins: { boundaries },
|
|
32
|
+
settings: {
|
|
33
|
+
"import/resolver": {
|
|
34
|
+
typescript: { alwaysTryTypes: true },
|
|
35
|
+
node: { extensions: [".js", ".jsx", ".ts", ".tsx", ".mjs", ".cjs"] },
|
|
36
|
+
},
|
|
37
|
+
"boundaries/elements": [
|
|
38
|
+
{ type: "shared-feature", pattern: "features/_shared" },
|
|
39
|
+
{ type: "feature", pattern: "features/*", capture: ["feature"] },
|
|
40
|
+
{ type: "app", pattern: "app" },
|
|
41
|
+
{ type: "core", pattern: "core" },
|
|
42
|
+
{ type: "components", pattern: "components" },
|
|
43
|
+
{ type: "lib", pattern: "lib" },
|
|
44
|
+
],
|
|
45
|
+
},
|
|
46
|
+
rules: {
|
|
47
|
+
"boundaries/dependencies": [
|
|
48
|
+
"error",
|
|
49
|
+
{
|
|
50
|
+
default: "disallow",
|
|
51
|
+
message:
|
|
52
|
+
"Maedow Arch : {{from.type}} ne peut pas importer {{to.type}}. Voir architecture.md §6.",
|
|
53
|
+
policies: [
|
|
54
|
+
// app/ orchestre : il peut tout importer.
|
|
55
|
+
{
|
|
56
|
+
from: { element: { type: "app" } },
|
|
57
|
+
allow: {
|
|
58
|
+
to: {
|
|
59
|
+
element: {
|
|
60
|
+
types: {
|
|
61
|
+
anyOf: ["app", "feature", "shared-feature", "core", "components", "lib"],
|
|
62
|
+
},
|
|
63
|
+
},
|
|
64
|
+
},
|
|
65
|
+
},
|
|
66
|
+
},
|
|
67
|
+
// Une feature descend la pile, mais n'atteint jamais une autre feature.
|
|
68
|
+
{
|
|
69
|
+
from: { element: { type: "feature" } },
|
|
70
|
+
allow: {
|
|
71
|
+
to: {
|
|
72
|
+
element: { types: { anyOf: ["shared-feature", "core", "components", "lib"] } },
|
|
73
|
+
},
|
|
74
|
+
},
|
|
75
|
+
},
|
|
76
|
+
// ...sauf elle-même : les imports internes à la feature sont libres.
|
|
77
|
+
{
|
|
78
|
+
from: { element: { type: "feature" } },
|
|
79
|
+
allow: {
|
|
80
|
+
to: { element: { type: "feature", captured: { feature: "{{from.feature}}" } } },
|
|
81
|
+
},
|
|
82
|
+
},
|
|
83
|
+
// features/_shared/ est transverse : il ne connaît aucune feature.
|
|
84
|
+
{
|
|
85
|
+
from: { element: { type: "shared-feature" } },
|
|
86
|
+
allow: {
|
|
87
|
+
to: {
|
|
88
|
+
element: { types: { anyOf: ["shared-feature", "core", "components", "lib"] } },
|
|
89
|
+
},
|
|
90
|
+
},
|
|
91
|
+
},
|
|
92
|
+
// core/ est le domaine métier : zéro dépendance UI, zéro feature.
|
|
93
|
+
{
|
|
94
|
+
from: { element: { type: "core" } },
|
|
95
|
+
allow: { to: { element: { types: { anyOf: ["core", "lib"] } } } },
|
|
96
|
+
},
|
|
97
|
+
// components/ est présentationnel pur.
|
|
98
|
+
{
|
|
99
|
+
from: { element: { type: "components" } },
|
|
100
|
+
allow: { to: { element: { types: { anyOf: ["components", "lib"] } } } },
|
|
101
|
+
},
|
|
102
|
+
// lib/ est la feuille de l'arbre : il ne dépend que de lui-même.
|
|
103
|
+
{
|
|
104
|
+
from: { element: { type: "lib" } },
|
|
105
|
+
allow: { to: { element: { type: "lib" } } },
|
|
106
|
+
},
|
|
107
|
+
],
|
|
108
|
+
},
|
|
109
|
+
],
|
|
110
|
+
},
|
|
111
|
+
},
|
|
112
|
+
];
|
package/package.json
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "eslint-config-maedow-arch",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Règles ESLint de Maedow Arch — enforce les frontières app/features/core/components/lib via eslint-plugin-boundaries",
|
|
5
|
+
"main": "index.js",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"exports": {
|
|
8
|
+
".": "./index.js"
|
|
9
|
+
},
|
|
10
|
+
"keywords": [
|
|
11
|
+
"eslint",
|
|
12
|
+
"eslintconfig",
|
|
13
|
+
"maedow-arch",
|
|
14
|
+
"architecture",
|
|
15
|
+
"boundaries",
|
|
16
|
+
"clean-architecture",
|
|
17
|
+
"typescript"
|
|
18
|
+
],
|
|
19
|
+
"license": "MIT",
|
|
20
|
+
"author": "Jean-Marc",
|
|
21
|
+
"repository": {
|
|
22
|
+
"type": "git",
|
|
23
|
+
"url": "git+https://github.com/maedow-arch/maedow-arch-docs.git",
|
|
24
|
+
"directory": "packages/eslint-config-maedow-arch"
|
|
25
|
+
},
|
|
26
|
+
"homepage": "https://github.com/maedow-arch/maedow-arch-docs#readme",
|
|
27
|
+
"bugs": {
|
|
28
|
+
"url": "https://github.com/maedow-arch/maedow-arch-docs/issues"
|
|
29
|
+
},
|
|
30
|
+
"engines": {
|
|
31
|
+
"node": ">=18"
|
|
32
|
+
},
|
|
33
|
+
"peerDependencies": {
|
|
34
|
+
"eslint": ">=9",
|
|
35
|
+
"eslint-import-resolver-typescript": ">=4",
|
|
36
|
+
"eslint-plugin-boundaries": ">=7"
|
|
37
|
+
},
|
|
38
|
+
"files": [
|
|
39
|
+
"index.js",
|
|
40
|
+
"README.md",
|
|
41
|
+
"LICENSE"
|
|
42
|
+
]
|
|
43
|
+
}
|