Skip to content

Commit

Permalink
fix: consistent config names
Browse files Browse the repository at this point in the history
  • Loading branch information
antfu committed Apr 3, 2024
1 parent d45b250 commit 80a050b
Show file tree
Hide file tree
Showing 17 changed files with 217 additions and 203 deletions.
4 changes: 3 additions & 1 deletion docs/content/1.packages/0.module.md
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ export default withNuxt(
// ...Prepend some flat configs in front
)
// Override some rules in a specific config, based on their name
.override('nuxt:typescript', {
.override('nuxt/typescript', {
rules: {
// ...Override rules, for example:
'@typescript-eslint/ban-types': 'off'
Expand All @@ -154,6 +154,8 @@ export default withNuxt(

You can learn more about the options available with the types can JSDocs of the instance.

For all the available configure names, please use the DevTools to inspect.

### Dev Server Checker

Usually you don't need this setting as most IDEs are capable of running ESLint directly to inform you of issues. It's also possible to set up a [pre-commit hook with `lint-staged`](https://github.com/lint-staged/lint-staged) to guard your codebase before committing.
Expand Down
2 changes: 1 addition & 1 deletion docs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,6 @@
"@vueuse/core": "^10.9.0",
"@vueuse/nuxt": "^10.9.0",
"nuxt": "^3.11.1",
"nuxt-og-image": "^3.0.0-rc.48"
"nuxt-og-image": "^3.0.0-rc.49"
}
}
38 changes: 8 additions & 30 deletions docs/pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"private": true,
"type": "module",
"packageManager": "pnpm@8.15.5",
"packageManager": "pnpm@8.15.6",
"version": "0.3.0-beta.8",
"scripts": {
"build": "pnpm run -r build",
Expand All @@ -21,7 +21,7 @@
"@nuxt/eslint-plugin": "workspace:*",
"@nuxt/test-utils": "^3.12.0",
"@types/eslint": "^8.56.7",
"@types/node": "^20.12.2",
"@types/node": "^20.12.3",
"bumpp": "^9.4.0",
"eslint": "^8.57.0",
"typescript": "^5.4.3",
Expand Down
4 changes: 2 additions & 2 deletions packages-legacy/nuxt2-eslint-config-typescript/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
],
"dependencies": {
"@nuxtjs/eslint-config": "^12.0.0",
"@typescript-eslint/eslint-plugin": "^7.4.0",
"@typescript-eslint/parser": "^7.4.0",
"@typescript-eslint/eslint-plugin": "^7.5.0",
"@typescript-eslint/parser": "^7.5.0",
"eslint-import-resolver-typescript": "^3.6.1",
"eslint-plugin-import": "^2.29.1",
"eslint-plugin-vue": "^9.24.0"
Expand Down
4 changes: 2 additions & 2 deletions packages/eslint-config/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@
"@nuxt/eslint-plugin": "workspace:*",
"@rushstack/eslint-patch": "^1.10.1",
"@stylistic/eslint-plugin": "^1.7.0",
"@typescript-eslint/eslint-plugin": "^7.4.0",
"@typescript-eslint/parser": "^7.4.0",
"@typescript-eslint/eslint-plugin": "^7.5.0",
"@typescript-eslint/parser": "^7.5.0",
"eslint-flat-config-utils": "^0.2.0",
"eslint-plugin-vue": "^9.24.0",
"globals": "^15.0.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/eslint-config/src/flat/configs/disables.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export default function disables(options: NuxtESLintConfigOptions): FlatConfigIt

if (fileRoutes.length) {
configs.push({
name: 'nuxt:vue:routes:disables',
name: 'nuxt/disables/routes',
files: fileRoutes,
rules: {
'vue/multi-word-component-names': 'off',
Expand Down
2 changes: 1 addition & 1 deletion packages/eslint-config/src/flat/configs/javascript.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import globals from 'globals'
export default function javascript(): FlatConfigItem[] {
return [
{
name: 'nuxt:javascript',
name: 'nuxt/javascript',
languageOptions: {
ecmaVersion: 2022,
parserOptions: {
Expand Down
24 changes: 12 additions & 12 deletions packages/eslint-config/src/flat/configs/nuxt.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,26 +14,26 @@ export default function nuxt(options: NuxtESLintConfigOptions): FlatConfigItem[]
...(dirs.pages?.map(pagesDir => join(pagesDir, `**/*.${GLOB_EXTS}`)) || []),
]

const configs: FlatConfigItem[] = [
{
name: 'nuxt:rules',
plugins: {
nuxt: nuxtPlugin,
},
rules: {
'nuxt/prefer-import-meta': 'error',
},
},
]
const configs: FlatConfigItem[] = []

if (fileSingleRoot.length)
configs.push({
name: 'nuxt:vue:single-root',
name: 'nuxt/vue/single-root',
files: fileSingleRoot,
rules: {
'vue/no-multiple-template-root': 'error',
},
})

configs.push({
name: 'nuxt/rules',
plugins: {
nuxt: nuxtPlugin,
},
rules: {
'nuxt/prefer-import-meta': 'error',
},
})

return configs
}
8 changes: 4 additions & 4 deletions packages/eslint-config/src/flat/configs/typescript.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import * as parserTs from '@typescript-eslint/parser'
import parserTs from '@typescript-eslint/parser'
import pluginTs from '@typescript-eslint/eslint-plugin'
import type { FlatConfigItem } from 'eslint-flat-config-utils'
import { resolveOptions } from '../utils'
Expand All @@ -15,14 +15,14 @@ export default function typescript(options: NuxtESLintConfigOptions): FlatConfig

return [
{
name: 'nuxt:typescript:setup',
name: 'nuxt/typescript/setup',
plugins: {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
'@typescript-eslint': pluginTs as any,
},
},
{
name: 'nuxt:typescript',
name: 'nuxt/typescript/rules',
files: ['**/*.ts', '**/*.tsx', '**/*.mts', '**/*.cts', '**/*.vue'],
languageOptions: {
parser: parserTs,
Expand All @@ -40,7 +40,7 @@ export default function typescript(options: NuxtESLintConfigOptions): FlatConfig
},
},
{
name: 'nuxt:typescript:disables',
name: 'nuxt/typescript/disables',
files: ['**/*.ts', '**/*.tsx', '**/*.mts', '**/*.cts', '**/*.vue'],
rules: {
// The core 'no-unused-vars' rules (in the eslint:recommended ruleset)
Expand Down
6 changes: 3 additions & 3 deletions packages/eslint-config/src/flat/configs/vue.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as parserVue from 'vue-eslint-parser'
import * as parserTs from '@typescript-eslint/parser'
import parserTs from '@typescript-eslint/parser'

// @ts-expect-error missing types
import pluginVue from 'eslint-plugin-vue'
Expand All @@ -13,7 +13,7 @@ export default function vue(options: NuxtESLintConfigOptions): FlatConfigItem[]

return [
{
name: 'nuxt:vue:setup',
name: 'nuxt/vue/setup',
plugins: {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
vue: pluginVue as any,
Expand Down Expand Up @@ -49,7 +49,7 @@ export default function vue(options: NuxtESLintConfigOptions): FlatConfigItem[]
},
},
{
name: 'nuxt:vue',
name: 'nuxt/vue/rules',
files: [
'**/*.vue',
],
Expand Down
4 changes: 2 additions & 2 deletions packages/eslint-plugin/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
"eslint": "^8.57.0"
},
"dependencies": {
"@typescript-eslint/types": "^7.4.0",
"@typescript-eslint/utils": "^7.4.0"
"@typescript-eslint/types": "^7.5.0",
"@typescript-eslint/utils": "^7.5.0"
}
}
4 changes: 2 additions & 2 deletions packages/module/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
}
},
"dependencies": {
"@eslint/config-inspector": "^0.2.1",
"@eslint/config-inspector": "^0.3.1",
"@nuxt/devtools-kit": "^1.1.5",
"@nuxt/eslint-config": "workspace:*",
"@nuxt/eslint-plugin": "workspace:*",
Expand All @@ -64,7 +64,7 @@
"devDependencies": {
"@nuxt/module-builder": "^0.5.5",
"@nuxt/schema": "^3.11.1",
"@typescript-eslint/scope-manager": "^7.4.0",
"@typescript-eslint/scope-manager": "^7.5.0",
"eslint-webpack-plugin": "^4.1.0",
"nuxt": "^3.11.1",
"vite-plugin-eslint2": "^4.4.0"
Expand Down
2 changes: 1 addition & 1 deletion packages/module/src/config-addons/globals.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export function createAddonGlobals(nuxt: Nuxt): ESLintConfigGenAddon {
configs: [
'// Set globals from imports registry\n'
+ JSON.stringify(<FlatConfigItem>{
name: 'nuxt:import-globals',
name: 'nuxt/import-globals',
languageOptions: {
globals: Object.fromEntries((await unimport.getImports()).map(i => [i.as || i.name, 'readonly'])),
},
Expand Down
5 changes: 2 additions & 3 deletions packages/module/src/modules/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ async function setupDevToolsIntegration(nuxt: Nuxt) {
tabs.push({
name: 'eslint-config',
title: 'ESLint Config',
icon: 'https://raw.githubusercontent.com/eslint/config-inspector/main/public/favicon.svg',
icon: 'https://raw.githubusercontent.com/eslint/config-inspector/main/app/public/favicon.svg',
view: viewerUrl
? {
type: 'iframe',
Expand Down Expand Up @@ -170,11 +170,10 @@ async function setupDevToolsIntegration(nuxt: Nuxt) {
viewerProcess = startSubprocess(
{
command: 'node',
args: [inspectorBinPath],
args: [inspectorBinPath, '--no-open'],
cwd: nuxt.options.rootDir,
env: {
PORT: viewerPort.toString(),
NO_OPEN: 'true',
},
},
{
Expand Down
2 changes: 1 addition & 1 deletion playground/eslint.config.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// @ts-check
import withNuxt from './.nuxt/eslint.config.mjs'

export default withNuxt({})
export default withNuxt()

0 comments on commit 80a050b

Please sign in to comment.