Skip to content

Commit d828da4

Browse files
authored
chore(lint): adopt shared eslint base config (#675)
* chore(lint): adopt shared eslint base config Bump eslint-plugin-harlanzw to 0.18.1 and route the copy-pasted override blocks through harlanzw({ base }). Drops the hand-rolled test relaxation and examples/package.json catalog exemptions. * chore(lint): keep the playground linted, bump to 0.19.0 `base({ ignores: false })` hands the ignore set back to this repo, which lints its playground on purpose. A global ignore cannot be undone by a later config, so the shared set had dropped 320 files from the run. File count is back to 702, matching main. * chore: bump eslint-plugin-harlanzw to 0.19.2 * refactor: take the prefer-satisfies suggestions that typecheck Eight object literals annotated `Record<string, V>` that are only ever read by a static key. `satisfies` keeps their keys, so `keyof typeof` and autocomplete work. Two are left alone, because narrowing them breaks the build: `emoji-names-minimal.ts` is indexed from another file, and `styleDirectives.ts` spreads its map into `BREAKPOINTS`, which is then indexed. The rule cannot see either without type information. pnpm typecheck clean, 933 unit tests pass.
1 parent 71b56f9 commit d828da4

12 files changed

Lines changed: 42 additions & 48 deletions

eslint.config.js

Lines changed: 18 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,22 @@
11
import antfu from '@antfu/eslint-config'
22
import harlanzw from 'eslint-plugin-harlanzw'
33

4-
export default antfu({
5-
ignores: ['.claude'],
6-
rules: {
7-
'node/prefer-global/process': 'off',
8-
'node/prefer-global/buffer': 'off',
9-
'no-use-before-define': 'off',
4+
export default antfu(
5+
// og-image lints its playground on purpose, so the shared ignore set is off and
6+
// this repo keeps its own list. A global ignore cannot be undone downstream.
7+
{ ignores: ['.claude'] },
8+
...harlanzw({
9+
base: { type: 'app', ignores: false },
10+
link: true,
11+
nuxt: true,
12+
vue: true,
13+
content: true,
14+
}),
15+
{
16+
rules: {
17+
'harlanzw/link-no-underscores': 'off',
18+
'harlanzw/link-trailing-slash': 'off',
19+
'harlanzw/link-lowercase': 'off',
20+
},
1021
},
11-
}, ...harlanzw({ link: true, nuxt: true, vue: true, content: true }), {
12-
files: ['test/**/*.ts', 'test/**/*.mjs'],
13-
rules: {
14-
'e18e/prefer-static-regex': 'off',
15-
},
16-
}, {
17-
rules: {
18-
'harlanzw/link-no-underscores': 'off',
19-
'harlanzw/link-trailing-slash': 'off',
20-
'harlanzw/link-lowercase': 'off',
21-
},
22-
}, {
23-
files: ['examples/**/package.json'],
24-
rules: {
25-
'pnpm/json-enforce-catalog': 'off',
26-
'pnpm/json-valid-catalog': 'off',
27-
'pnpm/json-prefer-workspace-settings': 'off',
28-
},
29-
})
22+
)

pnpm-lock.yaml

Lines changed: 6 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pnpm-workspace.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ minimumReleaseAgeExclude:
6262
- '@unhead/vue@3.2.1'
6363
- unhead@3.2.1
6464
- satori@0.28.2
65+
- eslint-plugin-harlanzw@0.19.2
6566
shellEmulator: true
6667

6768
trustPolicy: no-downgrade
@@ -135,7 +136,7 @@ catalog:
135136
defu: ^6.1.7
136137
devalue: ^5.9.0
137138
eslint: ^10.8.1
138-
eslint-plugin-harlanzw: ^0.17.1
139+
eslint-plugin-harlanzw: ^0.19.2
139140
exsolve: ^1.1.1
140141
fnv1a-64: ^0.1.2
141142
fontless: ^0.2.1

src/build/css/providers/tw4.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -485,7 +485,7 @@ function buildThemeVars(
485485
buildNuxtUiVars(vars, nuxtUiColors, theme)
486486

487487
if (extracted) {
488-
const themeRootAttrs: Record<string, string> = { 'data-theme': theme }
488+
const themeRootAttrs = { 'data-theme': theme } satisfies Record<string, string>
489489
const themeVars = resolveExtractedVars(extracted, themeRootAttrs)
490490
for (const [n, v] of themeVars)
491491
vars.set(n, v)

src/cli.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -445,7 +445,7 @@ async function removeDeprecatedConfigKeys(rootDir: string, keys: Array<{ key: st
445445
}
446446

447447
// Deprecated ogImage config keys and their replacements
448-
const DEPRECATED_CONFIG_KEYS: Record<string, string> = {
448+
const DEPRECATED_CONFIG_KEYS = {
449449
fonts: '@nuxt/fonts module (migrated automatically)',
450450
strictNuxtContentPaths: 'Removed (no effect in Content v3)',
451451
playground: 'Removed (use Nuxt DevTools)',
@@ -459,7 +459,7 @@ const DEPRECATED_CONFIG_KEYS: Record<string, string> = {
459459
cacheKey: 'Removed',
460460
static: 'zeroRuntime',
461461
componentOptions: 'Removed (use defineOgImage())',
462-
}
462+
} satisfies Record<string, string>
463463

464464
// Check if nuxt config has deprecated options
465465
async function checkNuxtConfig(rootDir: string): Promise<{

src/onboarding.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import {
2121
validateProviderSetup,
2222
} from './utils/dependencies'
2323

24-
const DEPRECATED_CONFIG: Record<string, string> = {
24+
const DEPRECATED_CONFIG = {
2525
playground: 'Removed - use Nuxt DevTools',
2626
host: 'Use site.url or NUXT_SITE_URL',
2727
siteUrl: 'Use site.url or NUXT_SITE_URL',
@@ -33,7 +33,7 @@ const DEPRECATED_CONFIG: Record<string, string> = {
3333
cacheKey: 'Removed',
3434
static: 'Removed - use zeroRuntime',
3535
fonts: 'Use @nuxt/fonts module instead',
36-
}
36+
} satisfies Record<string, string>
3737

3838
const DEPRECATED_COMPOSABLES = [
3939
'defineOgImageStatic',

test/e2e-not-nuxt/zeroRuntimeBuild.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ describe('zeroRuntime', () => {
2828
await exec('nuxt', ['build'], { nodeOptions: { cwd: fixtureDir } })
2929
const serverOutputPath = resolve('../fixtures/zero-runtime/.output/server')
3030
const { stdout } = await exec('du', ['-sh', serverOutputPath])
31-
// eslint-disable-next-line no-console,style/no-tabs
31+
// eslint-disable-next-line style/no-tabs
3232
console.log(`Size: ${stdout.split(' ')[0]}`)
3333
const imagePath = resolve('../fixtures/zero-runtime/.output/public/_og')
3434
const images = await globby('**/*.png', { cwd: imagePath }).then((r: string[]) => r.sort())

test/e2e/multi-font-families.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ describe('multi-font-families', () => {
2929
'/font-black-takumi',
3030
)
3131

32-
const snapshotIds: Record<string, string> = {
32+
const snapshotIds = {
3333
'/': 'multi-font-lobster',
3434
'/playfair': 'multi-font-playfair',
3535
'/roboto': 'multi-font-jetbrains',
@@ -43,7 +43,7 @@ describe('multi-font-families', () => {
4343
'/biz-udp-bold': 'multi-font-biz-udp-bold-takumi',
4444
'/font-black': 'multi-font-font-black',
4545
'/font-black-takumi': 'multi-font-font-black-takumi',
46-
}
46+
} satisfies Record<string, string>
4747

4848
for (const [path, id] of Object.entries(snapshotIds)) {
4949
// Use tighter threshold for biz-udp-bold: the font-weight regression

test/unit/font-requirements.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ describe('font-requirements', () => {
99
})
1010

1111
describe('font weight class mapping', () => {
12-
const FONT_WEIGHT_CLASSES: Record<string, number> = {
12+
const FONT_WEIGHT_CLASSES = {
1313
'font-thin': 100,
1414
'font-extralight': 200,
1515
'font-light': 300,
@@ -19,7 +19,7 @@ describe('font-requirements', () => {
1919
'font-bold': 700,
2020
'font-extrabold': 800,
2121
'font-black': 900,
22-
}
22+
} satisfies Record<string, number>
2323

2424
it('should have correct weight mappings', () => {
2525
expect(FONT_WEIGHT_CLASSES['font-thin']).toBe(100)

test/unit/fonts.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,11 +82,11 @@ describe('extractCustomFontFamilies', () => {
8282
})
8383

8484
describe('resolveFontFamilies', () => {
85-
const fontVars: Record<string, string> = {
85+
const fontVars = {
8686
'font-sans': 'Inter, sans-serif',
8787
'font-serif': '\'Playfair Display\', Georgia, serif',
8888
'font-mono': '\'JetBrains Mono\', monospace',
89-
}
89+
} satisfies Record<string, string>
9090

9191
it('returns empty when no classes or names', () => {
9292
expect(resolveFontFamilies([], [], fontVars)).toEqual([])

0 commit comments

Comments
 (0)