8000 chore(schema): enable linting (#22546) · nuxt/nuxt@5244555 · GitHub
[go: up one dir, main page]

Skip to content

Commit 5244555

Browse files
chore(schema): enable linting (#22546)
1 parent 5d86580 commit 5244555

22 files changed

+236
-177
lines changed

.eslintignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
dist
22
node_modules
3-
schema
3+
packages/schema/schema
44
**/*.tmpl.*
55
sw.js

.eslintrc

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,21 @@
100100
"definedTags": ["__NO_SIDE_EFFECTS__"]
101101
}]
102102
},
103+
"overrides": [
104+
{
105+
"files": ["packages/schema/**"],
106+
"rules": {
107+
"jsdoc/no-undefined-types": "off",
108+
"jsdoc/valid-types": "off",
109+
"jsdoc/check-tag-names": [
110+
"error",
111+
{
112+
"definedTags": ["experimental"]
113+
}
114+
]
115+
}
116+
}
117+
],
103118
"settings": {
104119
"jsdoc": {
105120
"ignoreInternal": true,

packages/schema/src/config/adhoc.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ export default defineUntypedSchema({
3434
/**
3535
* An array of custom directories that will be auto-imported.
3636
* Note that this option will not override the default directories (~/composables, ~/utils).
37+
*
3738
* @example
3839
* ```js
3940
* imports: {
@@ -57,9 +58,8 @@ export default defineUntypedSchema({
5758
* Manually disable nuxt telemetry.
5859
*
5960
* @see [Nuxt Telemetry](https://github.com/nuxt/telemetry) for more information.
60-
*
6161
* @type {boolean | Record<string, any>}
62-
*/
62+
*/
6363
telemetry: undefined,
6464

6565
/**

packages/schema/src/config/app.ts

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ export default defineUntypedSchema({
1010
vue: {
1111
/**
1212
* Options for the Vue compiler that will be passed at build time.
13+
*
1314
* @see [documentation](https://vuejs.org/api/application.html#app-config-compileroptions)
1415
* @type {typeof import('@vue/compiler-core').CompilerOptions}
1516
*/
@@ -19,18 +20,20 @@ export default defineUntypedSchema({
1920
* Include Vue compiler in runtime bundle.
2021
*/
2122
runtimeCompiler: {
22-
$resolve: async (val, get) => val ?? await get('experimental.runtimeVueCompiler') ?? false,
23+
$resolve: async (val, get) => val ?? await get('experimental.runtimeVueCompiler') ?? false
2324
},
2425

2526
/**
2627
* Vue Experimental: Enable reactive destructure for `defineProps`
28+
*
2729
* @see [Vue RFC#502](https://github.com/vuejs/rfcs/discussions/502)
2830
* @type {boolean}
2931
*/
3032
propsDestructure: false,
3133

3234
/**
3335
* Vue Experimental: Enable macro `defineModel`
36+
*
3437
* @see [Vue RFC#503](https://github.com/vuejs/rfcs/discussions/503)
3538
* @type {boolean}
3639
*/
@@ -45,24 +48,26 @@ export default defineUntypedSchema({
4548
* The base path of your Nuxt application.
4649
*
4750
* This can be set at runtime by setting the NUXT_APP_BASE_URL environment variable.
51+
*
4852
* @example
4953
* ```bash
5054
* NUXT_APP_BASE_URL=/prefix/ node .output/server/index.mjs
5155
* ```
5256
*/
5357
baseURL: {
54-
$resolve: async (val) => val || process.env.NUXT_APP_BASE_URL || '/',
58+
$resolve: val => val || process.env.NUXT_APP_BASE_URL || '/'
5559
},
5660

5761
/** The folder name for the built site assets, relative to `baseURL` (or `cdnURL` if set). This is set at build time and should not be customized at runtime. */
5862
buildAssetsDir: {
59-
$resolve: async (val) => val || process.env.NUXT_APP_BUILD_ASSETS_DIR || '/_nuxt/',
63+
$resolve: val => val || process.env.NUXT_APP_BUILD_ASSETS_DIR || '/_nuxt/'
6064
},
6165

6266
/**
6367
* An absolute URL to serve the public folder from (production-only).
6468
*
6569
* This can be set to a different value at runtime by setting the `NUXT_APP_CDN_URL` environment variable.
70+
*
6671
* @example
6772
* ```bash
6873
* NUXT_APP_CDN_URL=https://mycdn.org/ node .output/server/index.mjs
@@ -175,10 +180,11 @@ export default defineUntypedSchema({
175180
* Customize Nuxt root element tag.
176181
*
177182
*/
178-
rootTag: 'div',
183+
rootTag: 'div'
179184
},
180185

181-
/** A path to an HTML file, the contents of which will be inserted into any HTML page
186+
/**
187+
* A path to an HTML file, the contents of which will be inserted into any HTML page
182188
* rendered with `ssr: false`.
183189
*
184190
* By default Nuxt will look in `~/app/spa-loading-template.html` for this file.
@@ -230,7 +236,6 @@ export default defineUntypedSchema({
230236
* }
231237
* </style>
232238
* ```
233-
*
234239
* @type {string | false}
235240
*/
236241
spaLoadingTemplate: {
@@ -249,9 +254,7 @@ export default defineUntypedSchema({
249254
* @note Plugins are also auto-registered from the `~/plugins` directory
250255
* and these plugins do not need to be listed in `nuxt.config` unless you
251256
* need to customize their order. All plugins are deduplicated by their src path.
252-
*
253257
* @see https://nuxt.com/docs/guide/directory-structure/plugins
254-
*
255258
* @example
256259
* ```js
257260
* plugins: [

packages/schema/src/config/build.ts

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ export default defineUntypedSchema({
1616
}
1717
const map: Record<string, string> = {
1818
vite: '@nuxt/vite-builder',
19-
webpack: '@nuxt/webpack-builder',
19+
webpack: '@nuxt/webpack-builder'
2020
}
2121
return map[val] || val || (await get('vite') === false ? map.webpack : map.vite)
2222
}
@@ -36,7 +36,7 @@ export default defineUntypedSchema({
3636
server: true,
3737
client: await get('dev')
3838
})
39-
},
39+
}
4040
},
4141

4242
/**
@@ -96,7 +96,6 @@ export default defineUntypedSchema({
9696
* }
9797
* ]
9898
* ```
99-
*
10099
* @type {typeof import('../src/types/nuxt').NuxtTemplate<any>[]}
101100
*/
102101
templates: [],
@@ -113,7 +112,6 @@ export default defineUntypedSchema({
113112
* }
114113
* ```
115114
* @type {boolean | typeof import('webpack-bundle-analyzer').BundleAnalyzerPlugin.Options | typeof import('rollup-plugin-visualizer').PluginVisualizerOptions}
116-
*
117115
*/
118116
analyze: {
119117
$resolve: async (val, get) => {
@@ -128,7 +126,7 @@ export default defineUntypedSchema({
128126
filename: join(analyzeDir, '{name}.html')
129127
}
130128
}
131-
},
129+
}
132130
},
133131

134132
/**
@@ -147,13 +145,13 @@ export default defineUntypedSchema({
147145
* @type {Array<{ name: string, source?: string | RegExp, argumentLength: number }>}
148146
*/
149147
keyedComposables: {
150-
$resolve: (val) => [
148+
$resolve: val => [
151149
{ name: 'defineNuxtComponent', argumentLength: 2 },
152150
{ name: 'useState', argumentLength: 2 },
153151
{ name: 'useFetch', argumentLength: 3 },
154152
{ name: 'useAsyncData', argumentLength: 3 },
155153
{ name: 'useLazyAsyncData', argumentLength: 3 },
156-
{ name: 'useLazyFetch', argumentLength: 3 },
154+
{ name: 'useLazyFetch', argumentLength: 3 }
157155
].concat(val).filter(Boolean)
158156
},
159157

@@ -172,18 +170,22 @@ export default defineUntypedSchema({
172170
composables: {
173171
server: {
174172
$resolve: async (val, get) => defu(val || {},
175-
await get('dev') ? {} : {
176-
vue: ['onBeforeMount', 'onMounted', 'onBeforeUpdate', 'onRenderTracked', 'onRenderTriggered', 'onActivated', 'onDeactivated', 'onBeforeUnmount'],
177-
'#app': ['definePayloadReviver', 'definePageMeta']
178-
}
173+
await get('dev')
174+
? {}
175+
: {
176+
vue: ['onBeforeMount', 'onMounted', 'onBeforeUpdate', 'onRenderTracked', 'onRenderTriggered', 'onActivated', 'onDeactivated', 'onBeforeUnmount'],
177+
'#app': ['definePayloadReviver', 'definePageMeta']
178+
}
179179
)
180180
},
181181
client: {
182182
$resolve: async (val, get) => defu(val || {},
183-
await get('dev') ? {} : {
184-
vue: ['onServerPrefetch', 'onRenderTracked', 'onRenderTriggered'],
185-
'#app': ['definePayloadReducer', 'definePageMeta']
186-
}
183+
await get('dev')
184+
? {}
185+
: {
186+
vue: ['onServerPrefetch', 'onRenderTracked', 'onRenderTriggered'],
187+
'#app': ['definePayloadReducer', 'definePageMeta']
188+
}
187189
)
188190
}
189191
}

packages/schema/src/config/common.ts

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ export default defineUntypedSchema({
1414
* You can use `github:`, `gitlab:`, `bitbucket:` or `https://` to extend from a remote git repository.
1515
*
1616
* @type {string|string[]}
17-
*
1817
*/
1918
extends: null,
2019

@@ -26,7 +25,6 @@ export default defineUntypedSchema({
2625
* You can use `github:`, `gitlab:`, `bitbucket:` or `https://` to extend from a remote git repository.
2726
*
2827
* @type {string}
29-
*
3028
*/
3129
theme: null,
3230

@@ -170,15 +168,15 @@ export default defineUntypedSchema({
170168
*
171169
*/
172170
debug: {
173-
$resolve: async (val, get) => val ?? isDebug
171+
$resolve: val => val ?? isDebug
174172
},
175173

176174
/**
177175
* Whether to enable rendering of HTML - either dynamically (in server mode) or at generate time.
178176
* If set to `false` generated pages will have no content.
179177
*/
180178
ssr: {
181-
$resolve: (val) => val ?? true,
179+
$resolve: val => val ?? true
182180
},
183181

184182
/**
@@ -191,7 +189,6 @@ export default defineUntypedSchema({
191189
* (in `node_modules`) and then will be resolved from project `srcDir` if `~` alias is used.
192190
*
193191
* @note Modules are executed sequentially so the order is important.
194-
*
195192
* @example
196193
* ```js
197194
* modules: [
@@ -252,12 +249,12 @@ export default defineUntypedSchema({
252249
* and copied across into your `dist` folder when your app is generated.
253250
*/
254251
public: {
255-
$resolve: async (val, get) => val || await get('dir.static') || 'public',
252+
$resolve: async (val, get) => val || await get('dir.static') || 'public'
256253
},
257254

258255
static: {
259256
$schema: { deprecated: 'use `dir.public` option instead' },
260-
$resolve: async (val, get) => val || await get('dir.public') || 'public',
257+
$resolve: async (val, get) => val || await get('dir.public') || 'public'
261258
}
262259
},
263260

@@ -274,11 +271,9 @@ export default defineUntypedSchema({
274271
*
275272
* @note Within a webpack context (image sources, CSS - but not JavaScript) you _must_ access
276273
* your alias by prefixing it with `~`.
277-
*
278274
* @note These aliases will be automatically added to the generated `.nuxt/tsconfig.json` so you can get full
279275
* type support and path auto-complete. In case you need to extend options provided by `./.nuxt/tsconfig.json`
280276
* further, make sure to add them here or within the `typescript.tsConfig` property in `nuxt.config`.
281-
*
282277
* @example
283278
* ```js
284279
* export default {
@@ -309,7 +304,6 @@ export default defineUntypedSchema({
309304
* }
310305
* </style>
311306
* ```
312-
*
313307
* @type {Record<string, string>}
314308
*/
315309
alias: {
@@ -328,7 +322,6 @@ export default defineUntypedSchema({
328322
* Pass options directly to `node-ignore` (which is used by Nuxt to ignore files).
329323
*
330324
* @see [node-ignore](https://github.com/kaelzhang/node-ignore)
331-
*
332325
* @example
333326
* ```js
334327
* ignoreOptions: {
@@ -343,7 +336,7 @@ export default defineUntypedSchema({
343336
* building if its filename starts with the prefix specified by `ignorePrefix`.
344337
*/
345338
ignorePrefix: {
346-
$resolve: (val) => val ?? '-',
339+
$resolve: val => val ?? '-'
347340
},
348341

349342
/**
@@ -372,7 +365,7 @@ export default defineUntypedSchema({
372365
* @type {Array<string | RegExp>}
373366
*/
374367
watch: {
375-
$resolve: val => [].concat(val).filter((b: unknown) => typeof b === 'string' || b instanceof RegExp),
368+
$resolve: val => [].concat(val).filter((b: unknown) => typeof b === 'string' || b instanceof RegExp)
376369
},
377370

378371
/**
@@ -385,7 +378,7 @@ export default defineUntypedSchema({
385378
* `watchOptions` to pass directly to webpack.
386379
*
387380
* @see [webpack@4 watch options](https://v4.webpack.js.org/configuration/watch/#watchoptions).
388-
* */
381+
*/
389382
webpack: {
390383
aggregateTimeout: 1000
391384
},
@@ -464,7 +457,7 @@ export default defineUntypedSchema({
464457
app: {
465458
baseURL: (await get('app')).baseURL,
466459
buildAssetsDir: (await get('app')).buildAssetsDir,
467-
cdnURL: (await get('app')).cdnURL,
460+
cdnURL: (await get('app')).cdnURL
468461
}
469462
})
470463
}

packages/schema/src/config/dev.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,7 @@ export default defineUntypedSchema({
1717
* }
1818
* })
1919
* ```
20-
*
21-
*
2220
* @type {boolean | { key: string; cert: string }}
23-
*
2421
*/
2522
https: false,
2623

@@ -43,6 +40,6 @@ export default defineUntypedSchema({
4340
*
4441
* @type {(data: { loading?: string }) => string}
4542
*/
46-
loadingTemplate: loadingTemplate
43+
loadingTemplate
4744
}
4845
})

0 commit comments

Comments
 (0)
0