From c90bc508174b1f6604ffa438582b6a4b5c80a627 Mon Sep 17 00:00:00 2001 From: "Xin Du (Clark)" Date: Wed, 17 Nov 2021 11:21:38 +0000 Subject: [PATCH] chore(lint): improve no-unused-vars rule (#1977) --- .eslintrc | 15 ++++++--------- docs/components/atoms/Gem.vue | 2 +- packages/bridge/src/runtime/app.ts | 1 - packages/nitro/src/rollup/plugins/externals.ts | 3 +-- packages/nitro/src/runtime/server/static.ts | 3 +-- packages/nuxt3/src/meta/runtime/components.ts | 2 +- packages/nuxt3/src/pages/runtime/page.vue | 2 +- packages/vite/src/plugins/analyze.ts | 1 - packages/webpack/src/utils/babel-preset.cjs | 2 +- packages/webpack/src/webpack.ts | 1 - 10 files changed, 12 insertions(+), 20 deletions(-) diff --git a/.eslintrc b/.eslintrc index d1e1d84994..402223851a 100644 --- a/.eslintrc +++ b/.eslintrc @@ -35,6 +35,11 @@ "message": "nitro should not directly import other packages." } ] + }], + "@typescript-eslint/no-unused-vars": ["error", { + "argsIgnorePattern": "^_", + "varsIgnorePattern": "^_", + "ignoreRestSiblings": true }] }, "settings": { @@ -44,13 +49,5 @@ "note": "note" } } - }, - "overrides": [ - { - "files": ["*.vue"], - "rules": { - "@typescript-eslint/no-unused-vars": "off" - } - } - ] + } } diff --git a/docs/components/atoms/Gem.vue b/docs/components/atoms/Gem.vue index 2cdcbf8b89..1728e53a97 100644 --- a/docs/components/atoms/Gem.vue +++ b/docs/components/atoms/Gem.vue @@ -101,7 +101,7 @@ export default { const tick = () => { const elapsedTime = clock.getElapsedTime() - const deltaTime = elapsedTime - previousTime + const _deltaTime = elapsedTime - previousTime previousTime = elapsedTime if (gem) { gem.rotation.y = 1.1 * elapsedTime diff --git a/packages/bridge/src/runtime/app.ts b/packages/bridge/src/runtime/app.ts index d3352c4146..5df4cc0b62 100644 --- a/packages/bridge/src/runtime/app.ts +++ b/packages/bridge/src/runtime/app.ts @@ -49,7 +49,6 @@ export interface NuxtAppCompat { } export interface Context { - // eslint-disable-next-line $_nuxtApp: NuxtAppCompat } diff --git a/packages/nitro/src/rollup/plugins/externals.ts b/packages/nitro/src/rollup/plugins/externals.ts index 49b03def1b..7d668059b3 100644 --- a/packages/nitro/src/rollup/plugins/externals.ts +++ b/packages/nitro/src/rollup/plugins/externals.ts @@ -74,8 +74,7 @@ export function externals (opts: NodeExternalsOptions): Plugin { // // Find all unique package names const pkgs = new Set() for (const file of tracedFiles) { - // eslint-disable-next-line @typescript-eslint/no-unused-vars - const [_, baseDir, pkgName, _importPath] = /^(.+\/node_modules\/)([^@/]+|@[^/]+\/[^/]+)(\/?.*?)?$/.exec(file) + const [, baseDir, pkgName, _importPath] = /^(.+\/node_modules\/)([^@/]+|@[^/]+\/[^/]+)(\/?.*?)?$/.exec(file) pkgs.add(resolve(baseDir, pkgName, 'package.json')) } diff --git a/packages/nitro/src/runtime/server/static.ts b/packages/nitro/src/runtime/server/static.ts index b1b2a3e19f..ea084d484f 100644 --- a/packages/nitro/src/runtime/server/static.ts +++ b/packages/nitro/src/runtime/server/static.ts @@ -8,8 +8,7 @@ const PUBLIC_PATH = process.env.PUBLIC_PATH // Default: /_nuxt/ const TWO_DAYS = 2 * 60 * 60 * 24 const STATIC_ASSETS_BASE = process.env.NUXT_STATIC_BASE + '/' + process.env.NUXT_STATIC_VERSION -// eslint-disable-next-line -export default async function serveStatic(req, res) { +export default async function serveStatic (req, res) { if (!METHODS.includes(req.method)) { return } diff --git a/packages/nuxt3/src/meta/runtime/components.ts b/packages/nuxt3/src/meta/runtime/components.ts index cb0ca692fe..9abe521da3 100644 --- a/packages/nuxt3/src/meta/runtime/components.ts +++ b/packages/nuxt3/src/meta/runtime/components.ts @@ -5,7 +5,7 @@ import { useMeta } from './composables' type Props = Readonly> const removeUndefinedProps = (props: Props) => - Object.fromEntries(Object.entries(props).filter(([_key, value]) => value !== undefined)) + Object.fromEntries(Object.entries(props).filter(([, value]) => value !== undefined)) const setupForUseMeta = (metaFactory: (props: Props, ctx: SetupContext) => Record, renderChild?: boolean) => (props: Props, ctx: SetupContext) => { useMeta(() => metaFactory({ ...removeUndefinedProps(props), ...ctx.attrs }, ctx)) diff --git a/packages/nuxt3/src/pages/runtime/page.vue b/packages/nuxt3/src/pages/runtime/page.vue index c971872d98..f3deb5c0fe 100644 --- a/packages/nuxt3/src/pages/runtime/page.vue +++ b/packages/nuxt3/src/pages/runtime/page.vue @@ -14,7 +14,7 @@