Skip to content

Commit

Permalink
chore(lint): improve no-unused-vars rule (nuxt#1977)
Browse files Browse the repository at this point in the history
  • Loading branch information
clarkdo authored Nov 17, 2021
1 parent 232fdd8 commit c90bc50
Show file tree
Hide file tree
Showing 10 changed files with 12 additions and 20 deletions.
15 changes: 6 additions & 9 deletions .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,11 @@
"message": "nitro should not directly import other packages."
}
]
}],
"@typescript-eslint/no-unused-vars": ["error", {
"argsIgnorePattern": "^_",
"varsIgnorePattern": "^_",
"ignoreRestSiblings": true
}]
},
"settings": {
Expand All @@ -44,13 +49,5 @@
"note": "note"
}
}
},
"overrides": [
{
"files": ["*.vue"],
"rules": {
"@typescript-eslint/no-unused-vars": "off"
}
}
]
}
}
2 changes: 1 addition & 1 deletion docs/components/atoms/Gem.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion packages/bridge/src/runtime/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ export interface NuxtAppCompat {
}

export interface Context {
// eslint-disable-next-line
$_nuxtApp: NuxtAppCompat
}

Expand Down
3 changes: 1 addition & 2 deletions packages/nitro/src/rollup/plugins/externals.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,7 @@ export function externals (opts: NodeExternalsOptions): Plugin {
// // Find all unique package names
const pkgs = new Set<string>()
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'))
}

Expand Down
3 changes: 1 addition & 2 deletions packages/nitro/src/runtime/server/static.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
2 changes: 1 addition & 1 deletion packages/nuxt3/src/meta/runtime/components.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { useMeta } from './composables'
type Props = Readonly<Record<string, any>>

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<string, any>, renderChild?: boolean) => (props: Props, ctx: SetupContext) => {
useMeta(() => metaFactory({ ...removeUndefinedProps(props), ...ctx.attrs }, ctx))
Expand Down
2 changes: 1 addition & 1 deletion packages/nuxt3/src/pages/runtime/page.vue
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
</template>

<script>
import { getCurrentInstance, ref } from 'vue'
import { ref } from 'vue'
import NuxtLayout from './layout'
import { useNuxtApp } from '#app'
Expand Down
1 change: 0 additions & 1 deletion packages/vite/src/plugins/analyze.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ export function analyzePlugin (ctx: ViteBuildContext): Plugin[] {
{
name: 'nuxt-analyze-minify',
async generateBundle (_opts, outputBundle) {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
for (const [_bundleId, bundle] of Object.entries(outputBundle)) {
if (bundle.type !== 'chunk') { continue }
const originalEntries = Object.entries(bundle.modules)
Expand Down
2 changes: 1 addition & 1 deletion packages/webpack/src/utils/babel-preset.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ module.exports = (api, options = {}) => {
(corejs.version === 2 && isCorejs3Hoisted)
) {
// eslint-disable-next-line no-console
(console.fatal || console.error)(`babel corejs option is ${corejs.version}, please directlly install core-js@${corejs.version}.`)
(console.fatal || console.error)(`babel corejs option is ${corejs.version}, please directly install core-js@${corejs.version}.`)
}

const defaultTargets = {
Expand Down
1 change: 0 additions & 1 deletion packages/webpack/src/webpack.ts
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,6 @@ class WebpackBundler {

const { name } = compiler.options
const buildOptions = this.nuxt.options.build
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const { client, ...hotMiddlewareOptions } = buildOptions.hotMiddleware || {}

// Create webpack dev middleware
Expand Down

0 comments on commit c90bc50

Please sign in to comment.