@rnzeus/eslint-plugin 0.1.4 → 0.1.5

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
@@ -3,6 +3,7 @@
3
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
7
  - unused styles left in `*.styles.ts` files
7
8
  - inconsistent style naming
8
9
  - unsafe dynamic style usage
@@ -16,9 +17,11 @@ The plugin is **static**, **runtime-free**, and optimized for **ESLint Flat Conf
16
17
  ## Features
17
18
 
18
19
  ### ✅ `rnzeus/styles-usage`
20
+
19
21
  Ensures that all styles declared in `*.styles.ts(x)` files are actually used in the corresponding component file.
20
22
 
21
23
  **What it checks:**
24
+
22
25
  - detects unused style keys
23
26
  - forbids passing the whole `styles` object (`styles={styles}`)
24
27
  - supports arrays: `style={[styles.foo, condition && styles.bar]}`
@@ -27,6 +30,7 @@ Ensures that all styles declared in `*.styles.ts(x)` files are actually used in
27
30
  - supports additional “style-like” props (configurable): e.g. `contentContainerStyle`
28
31
 
29
32
  **File convention (required):**
33
+
30
34
  ```
31
35
  Component.tsx
32
36
  Component.styles.ts
@@ -35,21 +39,27 @@ Component.styles.ts
35
39
  ---
36
40
 
37
41
  ### ✅ `rnzeus/styles-naming`
42
+
38
43
  Enforces **snake_case** naming for style keys.
39
44
 
40
45
  **Example:**
46
+
41
47
  ```ts
42
48
  // ❌ bad
43
- itemName: {}
49
+ itemName: {
50
+ }
44
51
 
45
52
  // ✅ good
46
- item_name: {}
53
+ item_name: {
54
+ }
47
55
  ```
48
56
 
49
57
  ---
50
58
 
51
59
  ### ✅ `rnzeus/slice-imports`
60
+
52
61
  Enforces **FSD import boundaries** for alias imports:
62
+
53
63
  - **layer order**: lower layers cannot import higher layers
54
64
  - **same-slice imports** must be **relative**
55
65
  - **cross-slice** imports inside the same layer are allowed only via `@x/<currentSlice>`
@@ -57,10 +67,12 @@ Enforces **FSD import boundaries** for alias imports:
57
67
  This rule validates only alias imports starting with `@` (relative imports are ignored).
58
68
 
59
69
  **Assumed structure (defaults):**
70
+
60
71
  - `srcRoot`: `"src"`
61
72
  - `layers`: `shared -> entities -> features -> widgets -> pages -> app`
62
73
 
63
74
  **Examples (same slice must be relative):**
75
+
64
76
  ```ts
65
77
  // file: src/features/auth/ui/Login.tsx
66
78
 
@@ -72,6 +84,7 @@ import { submit } from "../model/submit";
72
84
  ```
73
85
 
74
86
  **Examples (cross-slice via @x):**
87
+
75
88
  ```ts
76
89
  // file: src/entities/product/ui/ProductCard.tsx
77
90
 
@@ -111,24 +124,18 @@ const imports = require("@rnzeus/eslint-plugin/configs/imports");
111
124
  ### Minimal setup
112
125
 
113
126
  ```js
114
- module.exports = [
115
- ...styles,
116
- ...imports,
117
- ];
127
+ module.exports = [...styles, ...imports];
118
128
  ```
119
129
 
120
130
  ### With other presets
121
131
 
122
132
  ```js
123
- const rnfsd = require('@rnzeus/themis/eslint/rnfsd');
133
+ const rnfsd = require("@rnzeus/themis/eslint/rnfsd");
134
+ const base = require("@rnzeus/eslint-plugin/configs/base");
124
135
  const styles = require("@rnzeus/eslint-plugin/configs/styles");
125
136
  const imports = require("@rnzeus/eslint-plugin/configs/imports");
126
137
 
127
- module.exports = [
128
- ...rnfsd,
129
- ...styles,
130
- ...imports,
131
- ];
138
+ module.exports = [...rnfsd, ...styles, ...imports];
132
139
  ```
133
140
 
134
141
  ---
@@ -145,6 +152,7 @@ You can extend or override this list via rule options.
145
152
  ### Merge (default)
146
153
 
147
154
  `type: "merge"` is the default behavior:
155
+
148
156
  - takes plugin defaults
149
157
  - adds your `styleProps`
150
158
  - de-duplicates
@@ -207,12 +215,14 @@ You **must** explicitly document allowed keys using a directive comment:
207
215
  ```
208
216
 
209
217
  Supported comment forms:
218
+
210
219
  ```ts
211
220
  // rnzeus-styles-used: a | b
212
221
  /* rnzeus-styles-used: a | b */
213
222
  ```
214
223
 
215
224
  This makes dynamic styles:
225
+
216
226
  - explicit
217
227
  - reviewable
218
228
  - safe during refactors
@@ -222,10 +232,12 @@ This makes dynamic styles:
222
232
  ## Configure `slice-imports`
223
233
 
224
234
  `rnzeus/slice-imports` supports these options:
235
+
225
236
  - `srcRoot` (default: `"src"`): marker folder used to detect layer/slice from absolute filename
226
237
  - `layers` (default: `["shared","entities","features","widgets","pages","app"]`): allowed layers in dependency order
227
238
 
228
239
  Example (custom `srcRoot` and layers):
240
+
229
241
  ```js
230
242
  const imports = require("@rnzeus/eslint-plugin/configs/imports");
231
243
 
@@ -251,46 +263,48 @@ module.exports = [
251
263
 
252
264
  ### `rnzeus/styles-usage`
253
265
 
254
- | Check | Status |
255
- |-----|------|
256
- Unused styles | ✅ |
257
- Whole styles object (`styles={styles}`) | ❌ |
258
- Array styles | ✅ |
259
- Conditional styles | ✅ |
260
- Dynamic styles | ⚠️ (directive required) |
261
- Extra style props | ✅ (configurable) |
266
+ | Check | Status |
267
+ | --------------------------------------- | ----------------------- |
268
+ | Unused styles | ✅ |
269
+ | Whole styles object (`styles={styles}`) | ❌ |
270
+ | Array styles | ✅ |
271
+ | Conditional styles | ✅ |
272
+ | Dynamic styles | ⚠️ (directive required) |
273
+ | Extra style props | ✅ (configurable) |
262
274
 
263
275
  ---
264
276
 
265
277
  ### `rnzeus/styles-naming`
266
278
 
267
- | Rule | Status |
268
- |----|----|
269
- snake_case only | ✅ |
270
- camelCase | ❌ |
271
- PascalCase | ❌ |
279
+ | Rule | Status |
280
+ | --------------- | ------ |
281
+ | snake_case only | ✅ |
282
+ | camelCase | ❌ |
283
+ | PascalCase | ❌ |
272
284
 
273
285
  Regex used:
286
+
274
287
  ```ts
275
- /^[a-z][a-z0-9_]*$/
288
+ /^[a-z][a-z0-9_]*$/;
276
289
  ```
277
290
 
278
291
  ---
279
292
 
280
293
  ### `rnzeus/slice-imports`
281
294
 
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 |
295
+ | Check | Status |
296
+ | ---------------------------------------- | ------- |
297
+ | Layer order (lower cannot import higher) | ✅ |
298
+ | Same slice must be relative | ✅ |
299
+ | Cross-slice via `@x/<currentSlice>` | ✅ |
300
+ | Relative imports | Ignored |
288
301
 
289
302
  ---
290
303
 
291
304
  ## Philosophy
292
305
 
293
306
  This plugin intentionally:
307
+
294
308
  - avoids runtime helpers
295
309
  - avoids TypeScript compiler APIs
296
310
  - avoids project-wide analysis