@gem-sdk/eslint-plugin 0.0.1 → 0.0.2
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 +0 -239
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -57,242 +57,3 @@ Choose the config that matches your tech stack:
|
|
|
57
57
|
}
|
|
58
58
|
}
|
|
59
59
|
```
|
|
60
|
-
|
|
61
|
-
---
|
|
62
|
-
|
|
63
|
-
## Rules
|
|
64
|
-
|
|
65
|
-
### Architecture (React + Vue)
|
|
66
|
-
|
|
67
|
-
These rules apply to both `.tsx` and `.vue` files and enforce the v2 module structure used across all GemPages repos.
|
|
68
|
-
|
|
69
|
-
Module detection handles both project layouts:
|
|
70
|
-
- `v2/modules/<name>/` — business modules (code lives under `app/` subdir)
|
|
71
|
-
- `v2/core/<name>/` — core modules (code lives at the module root)
|
|
72
|
-
|
|
73
|
-
---
|
|
74
|
-
|
|
75
|
-
#### `module-structure`
|
|
76
|
-
|
|
77
|
-
Enforces the allowed file/folder layout inside v2 modules.
|
|
78
|
-
|
|
79
|
-
**Allowed paths (business modules):**
|
|
80
|
-
|
|
81
|
-
```
|
|
82
|
-
app/contexts/*.(ts|tsx)
|
|
83
|
-
app/constants/*.ts
|
|
84
|
-
app/hooks/*.ts
|
|
85
|
-
app/stores/*.ts
|
|
86
|
-
app/types/*.ts
|
|
87
|
-
app/utils/*.ts
|
|
88
|
-
app/graphql/{fragments,queries,mutations}/*.(gql|ts)
|
|
89
|
-
app/ui/{atoms,molecules,organisms,templates}/*.(vue|tsx)
|
|
90
|
-
app/ui/assets/fonts/*.(woff|woff2|ttf|eot)
|
|
91
|
-
app/ui/assets/icons/*.(vue|tsx)
|
|
92
|
-
app/ui/assets/images/*.(png|jpg|jpeg|gif|svg|webp|ico|bmp|tiff)
|
|
93
|
-
app/ui/assets/styles/*.(css|scss)
|
|
94
|
-
app/ui/assets/videos/*.(mp4|mp3)
|
|
95
|
-
*.test.[tj]sx? (anywhere in the module)
|
|
96
|
-
external.ts (module root only)
|
|
97
|
-
index.ts (module root only)
|
|
98
|
-
```
|
|
99
|
-
|
|
100
|
-
Core modules use the same layout without the `app/` prefix.
|
|
101
|
-
|
|
102
|
-
---
|
|
103
|
-
|
|
104
|
-
#### `no-module-barrel`
|
|
105
|
-
|
|
106
|
-
Bans `index.ts` barrel files inside module subdirectories. Only the module-root `index.ts` is allowed.
|
|
107
|
-
|
|
108
|
-
```ts
|
|
109
|
-
// ❌ Error — app/hooks/index.ts
|
|
110
|
-
export { useFoo } from './useFoo';
|
|
111
|
-
|
|
112
|
-
// ✅ OK — module-root index.ts
|
|
113
|
-
export { useFoo } from './app/hooks/useFoo';
|
|
114
|
-
```
|
|
115
|
-
|
|
116
|
-
---
|
|
117
|
-
|
|
118
|
-
#### `module-import-boundary`
|
|
119
|
-
|
|
120
|
-
Prevents files inside a module from importing across the module boundary. Cross-module dependencies must go through `external.ts`.
|
|
121
|
-
|
|
122
|
-
Banned imports:
|
|
123
|
-
- Alias imports (`~/...`, `@/...`) — always escape the module
|
|
124
|
-
- Relative imports (`../`) resolving outside the module root
|
|
125
|
-
|
|
126
|
-
Scoped npm packages (e.g. `@shopify/react-form`) are unaffected — the alias check only matches the literal `@/` prefix.
|
|
127
|
-
|
|
128
|
-
```ts
|
|
129
|
-
// ❌ Error
|
|
130
|
-
import { useShop } from '~/modules/shop-info/app/hooks/useShop';
|
|
131
|
-
|
|
132
|
-
// ✅ OK — through the public API
|
|
133
|
-
import { useShop } from '~/modules/shop-info';
|
|
134
|
-
```
|
|
135
|
-
|
|
136
|
-
---
|
|
137
|
-
|
|
138
|
-
#### `pure-ui-layer`
|
|
139
|
-
|
|
140
|
-
Bans hook imports and `use*` calls inside `ui/atoms/` and `ui/molecules/`. These layers must be stateless.
|
|
141
|
-
|
|
142
|
-
Exempt hooks: anything matching `use.*i18n`, `use.*translat`, or `use.*const` (case-insensitive) — e.g. `useI18n`, `useTranslation`, `useConstants`.
|
|
143
|
-
|
|
144
|
-
Files under `v2/modules/<name>/core/` are fully exempt from this rule.
|
|
145
|
-
|
|
146
|
-
```tsx
|
|
147
|
-
// ❌ Error — atoms/ProductCard.tsx
|
|
148
|
-
import { useProduct } from '../../hooks/useProduct';
|
|
149
|
-
|
|
150
|
-
// ✅ OK
|
|
151
|
-
import { useTranslation } from '../../hooks/useTranslation';
|
|
152
|
-
```
|
|
153
|
-
|
|
154
|
-
---
|
|
155
|
-
|
|
156
|
-
#### `module-index-required`
|
|
157
|
-
|
|
158
|
-
Verifies that every v2 module has an `index.ts` at its root. Fires on every file linted inside the module.
|
|
159
|
-
|
|
160
|
-
---
|
|
161
|
-
|
|
162
|
-
### i18n (React + Vue)
|
|
163
|
-
|
|
164
|
-
#### `no-t-for-variable`
|
|
165
|
-
|
|
166
|
-
Only plain string literals are allowed as the first argument to `t()`. Template literals with interpolations are banned.
|
|
167
|
-
|
|
168
|
-
```ts
|
|
169
|
-
// ✅ OK
|
|
170
|
-
t("Save")
|
|
171
|
-
t(`Hello`)
|
|
172
|
-
|
|
173
|
-
// ❌ Error
|
|
174
|
-
t(key)
|
|
175
|
-
t(`Hello ${name}`)
|
|
176
|
-
t(props.label)
|
|
177
|
-
```
|
|
178
|
-
|
|
179
|
-
---
|
|
180
|
-
|
|
181
|
-
### Vue-specific
|
|
182
|
-
|
|
183
|
-
#### `not-use-store-to-refs`
|
|
184
|
-
|
|
185
|
-
Bans Pinia's `storeToRefs()`. Use `computed()` instead for explicit reactivity.
|
|
186
|
-
|
|
187
|
-
```ts
|
|
188
|
-
// ❌ Error
|
|
189
|
-
const { count } = storeToRefs(useCounterStore())
|
|
190
|
-
|
|
191
|
-
// ✅ OK
|
|
192
|
-
const count = computed(() => useCounterStore().count)
|
|
193
|
-
```
|
|
194
|
-
|
|
195
|
-
#### `not-use-custom-color-class`
|
|
196
|
-
|
|
197
|
-
Warns when raw color values (hex, `rgb()`, `hsl()`) are used in Vue template class bindings. Use design-system tokens instead.
|
|
198
|
-
|
|
199
|
-
```html
|
|
200
|
-
<!-- ❌ Warning -->
|
|
201
|
-
<div :class="['[#ff0000]']" />
|
|
202
|
-
|
|
203
|
-
<!-- ✅ OK -->
|
|
204
|
-
<div class="text-primary" />
|
|
205
|
-
```
|
|
206
|
-
|
|
207
|
-
Requires `vue-eslint-parser` as the parser.
|
|
208
|
-
|
|
209
|
-
---
|
|
210
|
-
|
|
211
|
-
### React / TypeScript-specific
|
|
212
|
-
|
|
213
|
-
#### `no-export-type-from-tsx`
|
|
214
|
-
|
|
215
|
-
Disallows type/interface exports from `.tsx` files. Move types to a dedicated `.ts` file.
|
|
216
|
-
|
|
217
|
-
```ts
|
|
218
|
-
// ❌ Error — MyComponent.tsx
|
|
219
|
-
export type MyProps = { name: string };
|
|
220
|
-
|
|
221
|
-
// ✅ OK — MyComponent.ts
|
|
222
|
-
export type MyProps = { name: string };
|
|
223
|
-
```
|
|
224
|
-
|
|
225
|
-
#### `no-import-from-package-path`
|
|
226
|
-
|
|
227
|
-
Prevents value imports from `@gem-sdk` packages using deep path syntax. Type-only imports are allowed.
|
|
228
|
-
|
|
229
|
-
```ts
|
|
230
|
-
// ❌ Error
|
|
231
|
-
import { fn } from '@gem-sdk/core/internal/utils';
|
|
232
|
-
|
|
233
|
-
// ✅ OK
|
|
234
|
-
import { fn } from '@gem-sdk/core';
|
|
235
|
-
import type { T } from '@gem-sdk/core/internal/utils';
|
|
236
|
-
```
|
|
237
|
-
|
|
238
|
-
---
|
|
239
|
-
|
|
240
|
-
## Development
|
|
241
|
-
|
|
242
|
-
### Setup
|
|
243
|
-
|
|
244
|
-
```bash
|
|
245
|
-
yarn install
|
|
246
|
-
```
|
|
247
|
-
|
|
248
|
-
### Tests
|
|
249
|
-
|
|
250
|
-
Each rule has a co-located `.test.ts` file. Run all tests with:
|
|
251
|
-
|
|
252
|
-
```bash
|
|
253
|
-
yarn test
|
|
254
|
-
```
|
|
255
|
-
|
|
256
|
-
### Build
|
|
257
|
-
|
|
258
|
-
```bash
|
|
259
|
-
yarn build # outputs to dist/
|
|
260
|
-
```
|
|
261
|
-
|
|
262
|
-
### Adding a new rule
|
|
263
|
-
|
|
264
|
-
1. Create `src/rules/myNewRule.ts` (camelCase filename)
|
|
265
|
-
2. Export the rule as `default`
|
|
266
|
-
3. Add a co-located `src/rules/myNewRule.test.ts`
|
|
267
|
-
4. Register in `src/index.ts`:
|
|
268
|
-
|
|
269
|
-
```ts
|
|
270
|
-
import myNewRule from './rules/myNewRule';
|
|
271
|
-
|
|
272
|
-
export const rules = {
|
|
273
|
-
// ...existing
|
|
274
|
-
'my-new-rule': myNewRule,
|
|
275
|
-
};
|
|
276
|
-
```
|
|
277
|
-
|
|
278
|
-
---
|
|
279
|
-
|
|
280
|
-
## Release
|
|
281
|
-
|
|
282
|
-
This package uses [Changesets](https://github.com/changesets/changesets) with the same branching strategy as `web-builder-elements`:
|
|
283
|
-
|
|
284
|
-
| Branch | NPM tag |
|
|
285
|
-
|--------|---------|
|
|
286
|
-
| `production` | `latest` |
|
|
287
|
-
| `staging` | `staging` |
|
|
288
|
-
| `dev` | `dev` |
|
|
289
|
-
| `dev-sun` / `dev-moon` / `dev-earth` / `dev-new-feature` | `sun` / `moon` / `earth` / `new-feature` |
|
|
290
|
-
|
|
291
|
-
To release a new version:
|
|
292
|
-
|
|
293
|
-
```bash
|
|
294
|
-
# 1. Create a changeset describing your changes
|
|
295
|
-
yarn changeset
|
|
296
|
-
|
|
297
|
-
# 2. The CI release workflow handles publishing automatically on merge
|
|
298
|
-
```
|