@rnzeus/eslint-plugin 0.1.3 → 0.1.4

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
@@ -1,12 +1,13 @@
1
- # @rnzeus/eslint-plugin-style
1
+ # @rnzeus/eslint-plugin
2
2
 
3
- ESLint plugin for React / React Native projects focused on **style discipline**.
3
+ ESLint plugin for React / React Native projects focused on **style discipline** and **FSD import boundaries**.
4
4
 
5
5
  This plugin is designed to solve real-world problems that appear during refactoring:
6
6
  - unused styles left in `*.styles.ts` files
7
7
  - inconsistent style naming
8
8
  - unsafe dynamic style usage
9
9
  - passing whole `styles` objects to components
10
+ - architectural erosion via unconstrained cross-slice imports (FSD)
10
11
 
11
12
  The plugin is **static**, **runtime-free**, and optimized for **ESLint Flat Config (ESLint v9+)**.
12
13
 
@@ -47,12 +48,48 @@ item_name: {}
47
48
 
48
49
  ---
49
50
 
51
+ ### ✅ `rnzeus/slice-imports`
52
+ Enforces **FSD import boundaries** for alias imports:
53
+ - **layer order**: lower layers cannot import higher layers
54
+ - **same-slice imports** must be **relative**
55
+ - **cross-slice** imports inside the same layer are allowed only via `@x/<currentSlice>`
56
+
57
+ This rule validates only alias imports starting with `@` (relative imports are ignored).
58
+
59
+ **Assumed structure (defaults):**
60
+ - `srcRoot`: `"src"`
61
+ - `layers`: `shared -> entities -> features -> widgets -> pages -> app`
62
+
63
+ **Examples (same slice must be relative):**
64
+ ```ts
65
+ // file: src/features/auth/ui/Login.tsx
66
+
67
+ // ❌ bad (same slice via alias)
68
+ import { submit } from "@features/auth/model/submit";
69
+
70
+ // ✅ good
71
+ import { submit } from "../model/submit";
72
+ ```
73
+
74
+ **Examples (cross-slice via @x):**
75
+ ```ts
76
+ // file: src/entities/product/ui/ProductCard.tsx
77
+
78
+ // ❌ bad (direct cross-slice import inside same layer)
79
+ import { getCartTotal } from "@entities/cart/model/getCartTotal";
80
+
81
+ // ✅ good (cart exposes cross-slice API specifically for product slice)
82
+ import { getCartTotal } from "@entities/cart/@x/product";
83
+ ```
84
+
85
+ ---
86
+
50
87
  ## Installation
51
88
 
52
89
  ```bash
53
- npm install -D @rnzeus/eslint-plugin-style
90
+ npm install -D @rnzeus/eslint-plugin
54
91
  # or
55
- yarn add -D @rnzeus/eslint-plugin-style
92
+ yarn add -D @rnzeus/eslint-plugin
56
93
  ```
57
94
 
58
95
  > Peer dependency: `eslint >= 9`
@@ -64,10 +101,11 @@ yarn add -D @rnzeus/eslint-plugin-style
64
101
  This plugin exports **ready-to-use flat config presets**.
65
102
  No `.default` access and no manual plugin wiring is required.
66
103
 
67
- ### Import preset
104
+ ### Import presets
68
105
 
69
106
  ```js
70
- const styles = require('@rnzeus/eslint-plugin-style/configs/styles');
107
+ const styles = require("@rnzeus/eslint-plugin/configs/styles");
108
+ const imports = require("@rnzeus/eslint-plugin/configs/imports");
71
109
  ```
72
110
 
73
111
  ### Minimal setup
@@ -75,6 +113,7 @@ const styles = require('@rnzeus/eslint-plugin-style/configs/styles');
75
113
  ```js
76
114
  module.exports = [
77
115
  ...styles,
116
+ ...imports,
78
117
  ];
79
118
  ```
80
119
 
@@ -82,11 +121,13 @@ module.exports = [
82
121
 
83
122
  ```js
84
123
  const rnfsd = require('@rnzeus/themis/eslint/rnfsd');
85
- const styles = require('@rnzeus/eslint-plugin-style/configs/styles');
124
+ const styles = require("@rnzeus/eslint-plugin/configs/styles");
125
+ const imports = require("@rnzeus/eslint-plugin/configs/imports");
86
126
 
87
127
  module.exports = [
88
128
  ...rnfsd,
89
129
  ...styles,
130
+ ...imports,
90
131
  ];
91
132
  ```
92
133
 
@@ -178,6 +219,34 @@ This makes dynamic styles:
178
219
 
179
220
  ---
180
221
 
222
+ ## Configure `slice-imports`
223
+
224
+ `rnzeus/slice-imports` supports these options:
225
+ - `srcRoot` (default: `"src"`): marker folder used to detect layer/slice from absolute filename
226
+ - `layers` (default: `["shared","entities","features","widgets","pages","app"]`): allowed layers in dependency order
227
+
228
+ Example (custom `srcRoot` and layers):
229
+ ```js
230
+ const imports = require("@rnzeus/eslint-plugin/configs/imports");
231
+
232
+ module.exports = [
233
+ ...imports,
234
+ {
235
+ rules: {
236
+ "rnzeus/slice-imports": [
237
+ "error",
238
+ {
239
+ srcRoot: "src",
240
+ layers: ["shared", "entities", "features", "widgets", "pages", "app"],
241
+ },
242
+ ],
243
+ },
244
+ },
245
+ ];
246
+ ```
247
+
248
+ ---
249
+
181
250
  ## Rules
182
251
 
183
252
  ### `rnzeus/styles-usage`
@@ -208,6 +277,17 @@ Regex used:
208
277
 
209
278
  ---
210
279
 
280
+ ### `rnzeus/slice-imports`
281
+
282
+ | Check | Status |
283
+ |-----|------|
284
+ Layer order (lower cannot import higher) | ✅ |
285
+ Same slice must be relative | ✅ |
286
+ Cross-slice via `@x/<currentSlice>` | ✅ |
287
+ Relative imports | Ignored |
288
+
289
+ ---
290
+
211
291
  ## Philosophy
212
292
 
213
293
  This plugin intentionally: