@cooperco/nuxt-layer-base 1.1.0 → 1.1.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/README.md +64 -35
- package/eslint.config.mjs +11 -1
- package/nuxt.config.ts +4 -0
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -174,16 +174,45 @@ import withNuxt from './.nuxt/eslint.config.mjs'
|
|
|
174
174
|
|
|
175
175
|
export default withNuxt({
|
|
176
176
|
rules: {
|
|
177
|
-
|
|
178
|
-
'@stylistic/comma-dangle': [
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
177
|
+
/* Stylistic */
|
|
178
|
+
'@stylistic/comma-dangle': [
|
|
179
|
+
'error',
|
|
180
|
+
'only-multiline'
|
|
181
|
+
],
|
|
182
|
+
'@stylistic/no-tabs': [
|
|
183
|
+
'error',
|
|
184
|
+
{ allowIndentationTabs: true }
|
|
185
|
+
],
|
|
186
|
+
|
|
187
|
+
/* TS */
|
|
188
|
+
'@typescript-eslint/no-unused-vars': [
|
|
189
|
+
'error',
|
|
190
|
+
{ caughtErrorsIgnorePattern: '^_' }
|
|
191
|
+
],
|
|
192
|
+
|
|
193
|
+
/* Vue */
|
|
194
|
+
'vue/html-closing-bracket-newline': [
|
|
195
|
+
'error',
|
|
196
|
+
{ multiline: 'never', selfClosingTag: { multiline: 'never' } }
|
|
197
|
+
],
|
|
198
|
+
'vue/html-closing-bracket-spacing': [
|
|
199
|
+
'error',
|
|
200
|
+
{ selfClosingTag: 'never' }
|
|
201
|
+
],
|
|
202
|
+
'vue/html-indent': [
|
|
203
|
+
'error', 'tab',
|
|
204
|
+
{ baseIndent: 0 }
|
|
205
|
+
],
|
|
206
|
+
'vue/multi-word-component-names': ['error', {
|
|
207
|
+
ignores: []
|
|
208
|
+
}],
|
|
209
|
+
'vue/component-name-in-template-casing': [
|
|
210
|
+
'error',
|
|
211
|
+
'kebab-case',
|
|
212
|
+
{ registeredComponentsOnly: false, ignores: [] }
|
|
213
|
+
],
|
|
214
|
+
'vue/component-options-name-casing': ['error', 'kebab-case'],
|
|
215
|
+
'vue/component-definition-name-casing': ['error', 'kebab-case']
|
|
187
216
|
}
|
|
188
217
|
})
|
|
189
218
|
```
|
|
@@ -202,62 +231,62 @@ export default withNuxt({
|
|
|
202
231
|
Notes
|
|
203
232
|
- The base layer enables stylistic mode via Nuxt (`eslint.config.stylistic: true`).
|
|
204
233
|
- Do not use Prettier alongside stylistic rules; remove Prettier configs/plugins from your app to avoid conflicts.
|
|
234
|
+
- Tabs are allowed for indentation (including in Vue templates). The `no-tabs` rule is enabled but permits indentation tabs.
|
|
205
235
|
|
|
206
236
|
What this ESLint config enforces (in plain English)
|
|
207
237
|
|
|
208
238
|
- Base: It starts from Nuxt’s generated, project‑aware flat config (via `@nuxt/eslint`), then turns on stylistic mode for consistent formatting in JS/TS/Vue files.
|
|
209
239
|
- This layer adds a few focused rules to keep things consistent and practical:
|
|
210
|
-
- `@stylistic/comma-dangle: '
|
|
211
|
-
-
|
|
212
|
-
```js
|
|
213
|
-
const user = {
|
|
214
|
-
id: 1,
|
|
215
|
-
name: 'Ada',
|
|
216
|
-
}
|
|
217
|
-
```
|
|
218
|
-
- Good:
|
|
240
|
+
- `@stylistic/comma-dangle: 'only-multiline'` — Allow trailing commas only when the list spans multiple lines; disallow them on single‑line lists.
|
|
241
|
+
- Good (multiline, trailing comma ok):
|
|
219
242
|
```js
|
|
220
243
|
const user = {
|
|
221
|
-
|
|
222
|
-
|
|
244
|
+
id: 1,
|
|
245
|
+
name: 'Ada',
|
|
223
246
|
}
|
|
224
247
|
```
|
|
248
|
+
- Good (single‑line, no trailing comma): `const arr = [1, 2, 3]`
|
|
249
|
+
- `@stylistic/no-tabs` with `{ allowIndentationTabs: true }` — Tabs are allowed for indentation but tabs elsewhere are flagged.
|
|
225
250
|
- `@typescript-eslint/no-unused-vars` with `{ caughtErrorsIgnorePattern: '^_' }` — Flag unused variables, but allow a try/catch parameter that starts with `_` when you don’t use it.
|
|
226
251
|
- Good (explicitly ignored):
|
|
227
252
|
```ts
|
|
228
253
|
try {
|
|
229
|
-
|
|
254
|
+
risky()
|
|
230
255
|
}
|
|
231
256
|
catch (_err) {
|
|
232
|
-
|
|
257
|
+
// intentionally ignored
|
|
233
258
|
}
|
|
234
259
|
```
|
|
235
260
|
- `vue/html-closing-bracket-newline: { multiline: 'never', selfClosingTag: { multiline: 'never' } }` — Don’t put a newline before a closing bracket, even for multi‑line attribute lists.
|
|
236
261
|
- Bad:
|
|
237
262
|
```vue
|
|
238
|
-
<
|
|
239
|
-
|
|
240
|
-
|
|
263
|
+
<my-comp
|
|
264
|
+
a="1"
|
|
265
|
+
b="2"
|
|
241
266
|
/>
|
|
242
267
|
```
|
|
243
268
|
- Good:
|
|
244
269
|
```vue
|
|
245
|
-
<
|
|
246
|
-
|
|
247
|
-
|
|
270
|
+
<my-comp
|
|
271
|
+
a="1"
|
|
272
|
+
b="2" />
|
|
248
273
|
```
|
|
249
274
|
- `vue/html-closing-bracket-spacing: { selfClosingTag: 'never' }` — No space before a self‑closing `/>`.
|
|
250
|
-
- Bad: `<
|
|
251
|
-
- Good: `<
|
|
252
|
-
- `vue/html-indent: [
|
|
275
|
+
- Bad: `<my-comp />`
|
|
276
|
+
- Good: `<my-comp/>`
|
|
277
|
+
- `vue/html-indent: ['tab', { baseIndent: 0 }]` — Use tabs for indentation in Vue templates.
|
|
253
278
|
- Example:
|
|
254
279
|
```vue
|
|
255
280
|
<template>
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
281
|
+
<div>
|
|
282
|
+
<span>Text</span>
|
|
283
|
+
</div>
|
|
259
284
|
</template>
|
|
260
285
|
```
|
|
286
|
+
- `vue/multi-word-component-names` — Enforce multi‑word component names (no single generic names like `Header` conflicts). Configure ignores if needed.
|
|
287
|
+
- `vue/component-name-in-template-casing: 'kebab-case'` — In templates, component tags must be kebab‑case (e.g., `<my-widget/>`, not `<MyWidget/>`).
|
|
288
|
+
- `vue/component-options-name-casing: 'kebab-case'` — In SFC component options, the `name` should be kebab‑case.
|
|
289
|
+
- `vue/component-definition-name-casing: 'kebab-case'` — For component definitions in script, enforce kebab‑case names.
|
|
261
290
|
|
|
262
291
|
### TypeScript in consumer apps
|
|
263
292
|
|
package/eslint.config.mjs
CHANGED
|
@@ -32,7 +32,17 @@ export default withNuxt({
|
|
|
32
32
|
'vue/html-indent': [
|
|
33
33
|
'error', 'tab',
|
|
34
34
|
{ baseIndent: 0 }
|
|
35
|
-
]
|
|
35
|
+
],
|
|
36
|
+
'vue/multi-word-component-names': ['error', {
|
|
37
|
+
ignores: []
|
|
38
|
+
}],
|
|
39
|
+
'vue/component-name-in-template-casing': [
|
|
40
|
+
'error',
|
|
41
|
+
'kebab-case',
|
|
42
|
+
{ registeredComponentsOnly: false, ignores: [] }
|
|
43
|
+
],
|
|
44
|
+
'vue/component-options-name-casing': ['error', 'kebab-case'],
|
|
45
|
+
'vue/component-definition-name-casing': ['error', 'kebab-case']
|
|
36
46
|
}
|
|
37
47
|
})
|
|
38
48
|
|
package/nuxt.config.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cooperco/nuxt-layer-base",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./nuxt.config.ts",
|
|
6
6
|
"scripts": {
|
|
@@ -22,13 +22,13 @@
|
|
|
22
22
|
"author": "cooperco",
|
|
23
23
|
"license": "MIT",
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"@nuxt/eslint": "^1.10.0",
|
|
26
25
|
"@nuxtjs/i18n": "^10.2.1",
|
|
27
|
-
"nuxt": "^4.2.
|
|
26
|
+
"nuxt": "^4.2.2"
|
|
28
27
|
},
|
|
29
28
|
"devDependencies": {
|
|
29
|
+
"@nuxt/eslint": "^1.10.0",
|
|
30
30
|
"@nuxt/test-utils": "^3.20.1",
|
|
31
|
-
"eslint": "^9.39.
|
|
31
|
+
"eslint": "^9.39.2",
|
|
32
32
|
"vue-tsc": "^3.1.4"
|
|
33
33
|
}
|
|
34
34
|
}
|