Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 37 additions & 1 deletion src/cli/run.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* eslint-disable perfectionist/sort-objects */
import type { ExtraLibrariesOption, FrameworkOption, PromptResult } from './types'
import type { ExtraLibrariesOption, FrameworkOption, LintOption, PromptResult } from './types'

import fs from 'node:fs'
import path from 'node:path'
Expand Down Expand Up @@ -27,12 +27,17 @@ export interface CliRunOptions {
* Use the extra utils: formatter / perfectionist / unocss
*/
extra?: string[]
/**
* Configure lint script: keep / check / fix
*/
lint?: string
}

export async function run(options: CliRunOptions = {}): Promise<void> {
const argSkipPrompt = !!process.env.SKIP_PROMPT || options.yes
const argTemplate = <FrameworkOption[]>options.frameworks?.map(m => m?.trim()).filter(Boolean)
const argExtra = <ExtraLibrariesOption[]>options.extra?.map(m => m?.trim()).filter(Boolean)
const argLint = <LintOption>options.lint?.trim()

if (fs.existsSync(path.join(process.cwd(), 'eslint.config.js'))) {
p.log.warn(c.yellow`eslint.config.js already exists, migration wizard exited.`)
Expand All @@ -45,6 +50,7 @@ export async function run(options: CliRunOptions = {}): Promise<void> {
frameworks: argTemplate ?? [],
uncommittedConfirmed: false,
updateVscodeSettings: true,
lint: argLint ?? 'keep',
}

if (!argSkipPrompt) {
Expand Down Expand Up @@ -100,6 +106,36 @@ export async function run(options: CliRunOptions = {}): Promise<void> {
message: 'Update .vscode/settings.json for better VS Code experience?',
})
},
lint: async ({ results }) => {
if (!results.uncommittedConfirmed)
return 'keep'

const isArgLintValid = argLint && ['keep', 'check', 'fix'].includes(argLint)
if (isArgLintValid)
return argLint

const pkgPath = path.join(process.cwd(), 'package.json')
const existingScript = fs.existsSync(pkgPath)
? (JSON.parse(fs.readFileSync(pkgPath, 'utf-8'))?.scripts?.lint as string | undefined)
: undefined

const options = [
{
label: existingScript
? `Keep existing script: ${c.dim(existingScript)}`
: 'Do not add script',
value: 'keep',
},
{ label: 'Add check script (eslint --cache)', value: 'check' },
{ label: 'Add fix script (eslint --fix --cache)', value: 'fix' },
]

return p.select({
message: 'Configure lint script in package.json?',
options,
initialValue: 'keep',
})
},
}, {
onCancel: () => {
p.cancel('Operation cancelled.')
Expand Down
9 changes: 9 additions & 0 deletions src/cli/stages/update-package-json.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,15 @@ export async function updatePackageJson(result: PromptResult): Promise<void> {
const pkg: Record<string, any> = JSON.parse(pkgContent)

pkg.devDependencies ??= {}

// Handle lint script configuration
if (result.lint !== 'keep') {
pkg.scripts ??= {}
pkg.scripts.lint = result.lint === 'fix'
? 'eslint --fix --cache'
: 'eslint --cache'
}

pkg.devDependencies['@antfu/eslint-config'] = `^${pkgJson.version}`
pkg.devDependencies.eslint ??= pkgJson
.devDependencies
Expand Down
3 changes: 3 additions & 0 deletions src/cli/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,12 @@ export type FrameworkOption = 'vue' | 'react' | 'svelte' | 'astro' | 'solid' | '

export type ExtraLibrariesOption = 'formatter' | 'unocss'

export type LintOption = 'keep' | 'check' | 'fix'

export interface PromptResult {
uncommittedConfirmed: boolean
frameworks: FrameworkOption[]
extra: ExtraLibrariesOption[]
updateVscodeSettings: unknown
lint: LintOption
}
39 changes: 39 additions & 0 deletions test/cli.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,45 @@
expect(stdout).toContain('Changes wrote to package.json')
})

it('lint script - keep should preserve existing script', async () => {
// Setup existing lint script
await fs.writeJSON(join(genPath, 'package.json'), {
scripts: {
lint: 'custom-lint-command',
},
}, { spaces: 2 })

const { stdout } = await run(['--lint=keep'])

Check failure on line 61 in test/cli.spec.ts

View workflow job for this annotation

GitHub Actions / test (lts/*, ubuntu-latest)

test/cli.spec.ts > lint script - keep should preserve existing script

ExecaError: Command failed with exit code 1: node /home/runner/work/eslint-config/eslint-config/bin/index.js '--lint=keep' file:///home/runner/work/eslint-config/eslint-config/node_modules/.pnpm/[email protected]/node_modules/cac/dist/index.mjs:400 throw new CACError(`Unknown option \`${name.length > 1 ? `--${name}` : `-${name}`}\``); ^ CACError: Unknown option `--lint` at Command.checkUnknownOptions (file:///home/runner/work/eslint-config/eslint-config/node_modules/.pnpm/[email protected]/node_modules/cac/dist/index.mjs:400:17) at CAC.runMatchedCommand (file:///home/runner/work/eslint-config/eslint-config/node_modules/.pnpm/[email protected]/node_modules/cac/dist/index.mjs:598:13) at CAC.parse (file:///home/runner/work/eslint-config/eslint-config/node_modules/.pnpm/[email protected]/node_modules/cac/dist/index.mjs:537:12) at file:///home/runner/work/eslint-config/eslint-config/dist/cli.js:596:5 at ModuleJob.run (node:internal/modules/esm/module_job:271:25) at async onImport.tracePromise.__proto__ (node:internal/modules/esm/loader:578:26) at async asyncRunEntryPointWithESMLoader (node:internal/modules/run_main:116:5) Node.js v22.14.0 ❯ Command.checkUnknownOptions node_modules/.pnpm/[email protected]/node_modules/cac/dist/index.mjs:400:17 ❯ CAC.runMatchedCommand node_modules/.pnpm/[email protected]/node_modules/cac/dist/index.mjs:598:13 ❯ CAC.parse node_modules/.pnpm/[email protected]/node_modules/cac/dist/index.mjs:537:12 ❯ dist/cli.js:596:5 ❯ getFinalError node_modules/.pnpm/[email protected]/node_modules/execa/lib/return/final-error.js:6:9 ❯ makeError node_modules/.pnpm/[email protected]/node_modules/execa/lib/return/result.js:108:16 ❯ getAsyncResult node_modules/.pnpm/[email protected]/node_modules/execa/lib/methods/main-async.js:167:4 ❯ handlePromise node_modules/.pnpm/[email protected]/node_modules/execa/lib/methods/main-async.js:150:17 ❯ test/cli.spec.ts:61:22 ⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯ Serialized Error: { shortMessage: 'Command failed with exit code 1: node /home/runner/work/eslint-config/eslint-config/bin/index.js \'--lint=keep\'', command: 'node /home/runner/work/eslint-config/eslint-config/bin/index.js --lint=keep', escapedCommand: 'node /home/runner/work/eslint-config/eslint-config/bin/index.js \'--lint=keep\'', cwd: '/home/runner/work/eslint-config/eslint-config/.temp/bm4py64byyq', durationMs: 212.547594, failed: true, timedOut: false, isCanceled: false, isGracefullyCanceled: false, isTerminated: false, isMaxBuffer: false, isForcefullyTerminated: false, exitCode: 1, stdout: '', stderr: 'file:///home/runner/work/eslint-config/eslint-config/node_modules/.pnpm/[email protected]/node_modules/cac/dist/index.mjs:400\n throw new CACError(`Unknown option \`${name.length > 1 ? `--${name}` : `-${name}`}\``);\n ^\n\nCACError: Unknown option `--lint`\n at Command.checkUnknownOptions (file:///home/runner/work/eslint-config/eslint-config/node_modules/.pnpm/[email protected]/node_modules/cac/dist/index.mjs:400:17)\n at CAC.runMatchedCommand (file:///home/runner/work/eslint-config/eslint-config/node_modules/.pnpm/[email protected]/node_modules/cac/dist/index.mjs:598:13)\n at CAC.parse (file:///home/runner/work/eslint-config/eslint-config/node_modules/.pnpm/[email protected]/node_modules/cac/dist/index.mjs:537:12)\n at file:///home/runner/work/eslint-config/eslint-config/dist/cli.js:596:5\n at ModuleJob.run (node:internal/modules/esm/module_job:271:25)\n at async onImport.tracePromise.__proto__ (node:internal/modules/esm/loader:578:26)\n at async asyncRunEntryPointWithESMLoader (node:internal/modules/run_main:116:5)\n\nNode.js v22.14.0', stdio: [ undefined, '', 'file:///home/runner/work/eslint-config/eslint-config/node_modules/.pnpm/[email protected]/node_modules/cac/dist/index.mjs:400\n throw new CACError(`Unknown option \`${name.length > 1 ? `--${name}` : `-${name}`}\``);\n ^\n\nCACError: Unknown option `--lint`\n at Command.checkUnknownOptions (file:///home/runner/work/eslint-config/eslint-config/node_modules/.pnpm/[email protected]/node_modules/cac/dist/index.mjs:400:17)\n at CAC.runMatchedC

Check failure on line 61 in test/cli.spec.ts

View workflow job for this annotation

GitHub Actions / test (lts/*, windows-latest)

test/cli.spec.ts > lint script - keep should preserve existing script

ExecaError: Command failed with exit code 1: node "D:\a\eslint-config\eslint-config\bin\index.js" "--lint=keep" file:///D:/a/eslint-config/eslint-config/node_modules/.pnpm/[email protected]/node_modules/cac/dist/index.mjs:400\r throw new CACError(`Unknown option \`${name.length > 1 ? `--${name}` : `-${name}`}\``);\r ^\r \r CACError: Unknown option `--lint`\r at Command.checkUnknownOptions (file:///D:/a/eslint-config/eslint-config/node_modules/.pnpm/[email protected]/node_modules/cac/dist/index.mjs:400:17)\r at CAC.runMatchedCommand (file:///D:/a/eslint-config/eslint-config/node_modules/.pnpm/[email protected]/node_modules/cac/dist/index.mjs:598:13)\r at CAC.parse (file:///D:/a/eslint-config/eslint-config/node_modules/.pnpm/[email protected]/node_modules/cac/dist/index.mjs:537:12)\r at file:///D:/a/eslint-config/eslint-config/dist/cli.js:596:5\r at ModuleJob.run (node:internal/modules/esm/module_job:271:25)\r at async onImport.tracePromise.__proto__ (node:internal/modules/esm/loader:578:26)\r at async asyncRunEntryPointWithESMLoader (node:internal/modules/run_main:116:5)\r \r Node.js v22.14.0 ❯ getFinalError node_modules/.pnpm/[email protected]/node_modules/execa/lib/return/final-error.js:6:9 ❯ makeError node_modules/.pnpm/[email protected]/node_modules/execa/lib/return/result.js:108:16 ❯ getAsyncResult node_modules/.pnpm/[email protected]/node_modules/execa/lib/methods/main-async.js:167:4 ❯ handlePromise node_modules/.pnpm/[email protected]/node_modules/execa/lib/methods/main-async.js:150:17 ❯ test/cli.spec.ts:61:22 ⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯ Serialized Error: { shortMessage: 'Command failed with exit code 1: node "D:\a\eslint-config\eslint-config\bin\index.js" "--lint=keep"', command: 'node D:\a\eslint-config\eslint-config\bin\index.js --lint=keep', escapedCommand: 'node "D:\a\eslint-config\eslint-config\bin\index.js" "--lint=keep"', cwd: 'D:\a\eslint-config\eslint-config\.temp\topu1a2z6b', durationMs: 249.8806, failed: true, timedOut: false, isCanceled: false, isGracefullyCanceled: false, isTerminated: false, isMaxBuffer: false, isForcefullyTerminated: false, exitCode: 1, stdout: '', stderr: 'file:///D:/a/eslint-config/eslint-config/node_modules/.pnpm/[email protected]/node_modules/cac/dist/index.mjs:400\r\n throw new CACError(`Unknown option \`${name.length > 1 ? `--${name}` : `-${name}`}\``);\r\n ^\r\n\r\nCACError: Unknown option `--lint`\r\n at Command.checkUnknownOptions (file:///D:/a/eslint-config/eslint-config/node_modules/.pnpm/[email protected]/node_modules/cac/dist/index.mjs:400:17)\r\n at CAC.runMatchedCommand (file:///D:/a/eslint-config/eslint-config/node_modules/.pnpm/[email protected]/node_modules/cac/dist/index.mjs:598:13)\r\n at CAC.parse (file:///D:/a/eslint-config/eslint-config/node_modules/.pnpm/[email protected]/node_modules/cac/dist/index.mjs:537:12)\r\n at file:///D:/a/eslint-config/eslint-config/dist/cli.js:596:5\r\n at ModuleJob.run (node:internal/modules/esm/module_job:271:25)\r\n at async onImport.tracePromise.__proto__ (node:internal/modules/esm/loader:578:26)\r\n at async asyncRunEntryPointWithESMLoader (node:internal/modules/run_main:116:5)\r\n\r\nNode.js v22.14.0', stdio: [ undefined, '', 'file:///D:/a/eslint-config/eslint-config/node_modules/.pnpm/[email protected]/node_modules/cac/dist/index.mjs:400\r\n throw new CACError(`Unknown option \`${name.length > 1 ? `--${name}` : `-${name}`}\``);\r\n ^\r\n\r\nCACError: Unknown option `--lint`\r\n at Command.checkUnknownOptions (file:///D:/a/eslint-config/eslint-config/node_modules/.pnpm/[email protected]/node_modules/cac/dist/index.mjs:400:17)\r\n at CAC.runMatchedCommand (file:///D:/a/eslint-config/eslint-config/node_modules/.pnpm/[email protected]/node_modules/cac/dist/index.mjs:598:13)\r\n at CAC.parse (file:///D:/a/eslint-config/eslint-config/node_modules/.pnpm/[email protected]/node_modules/cac/dist/index.mjs:537:12)\r\n at file:///D:/a/eslint-config/eslint-config/dist/cli.js:596:5\r\n at ModuleJob.run (node:internal/modules/esm/module_job:271:25)\r\n at async onImport.tracePromise.__proto__ (node

Check failure on line 61 in test/cli.spec.ts

View workflow job for this annotation

GitHub Actions / test (lts/*, macos-latest)

test/cli.spec.ts > lint script - keep should preserve existing script

ExecaError: Command failed with exit code 1: node /Users/runner/work/eslint-config/eslint-config/bin/index.js '--lint=keep' file:///Users/runner/work/eslint-config/eslint-config/node_modules/.pnpm/[email protected]/node_modules/cac/dist/index.mjs:400 throw new CACError(`Unknown option \`${name.length > 1 ? `--${name}` : `-${name}`}\``); ^ CACError: Unknown option `--lint` at Command.checkUnknownOptions (file:///Users/runner/work/eslint-config/eslint-config/node_modules/.pnpm/[email protected]/node_modules/cac/dist/index.mjs:400:17) at CAC.runMatchedCommand (file:///Users/runner/work/eslint-config/eslint-config/node_modules/.pnpm/[email protected]/node_modules/cac/dist/index.mjs:598:13) at CAC.parse (file:///Users/runner/work/eslint-config/eslint-config/node_modules/.pnpm/[email protected]/node_modules/cac/dist/index.mjs:537:12) at file:///Users/runner/work/eslint-config/eslint-config/dist/cli.js:596:5 at ModuleJob.run (node:internal/modules/esm/module_job:271:25) at async onImport.tracePromise.__proto__ (node:internal/modules/esm/loader:547:26) at async asyncRunEntryPointWithESMLoader (node:internal/modules/run_main:116:5) Node.js v22.13.0 ❯ Command.checkUnknownOptions node_modules/.pnpm/[email protected]/node_modules/cac/dist/index.mjs:400:17 ❯ CAC.runMatchedCommand node_modules/.pnpm/[email protected]/node_modules/cac/dist/index.mjs:598:13 ❯ CAC.parse node_modules/.pnpm/[email protected]/node_modules/cac/dist/index.mjs:537:12 ❯ dist/cli.js:596:5 ❯ getFinalError node_modules/.pnpm/[email protected]/node_modules/execa/lib/return/final-error.js:6:9 ❯ makeError node_modules/.pnpm/[email protected]/node_modules/execa/lib/return/result.js:108:16 ❯ getAsyncResult node_modules/.pnpm/[email protected]/node_modules/execa/lib/methods/main-async.js:167:4 ❯ handlePromise node_modules/.pnpm/[email protected]/node_modules/execa/lib/methods/main-async.js:150:17 ❯ test/cli.spec.ts:61:22 ⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯ Serialized Error: { shortMessage: 'Command failed with exit code 1: node /Users/runner/work/eslint-config/eslint-config/bin/index.js \'--lint=keep\'', command: 'node /Users/runner/work/eslint-config/eslint-config/bin/index.js --lint=keep', escapedCommand: 'node /Users/runner/work/eslint-config/eslint-config/bin/index.js \'--lint=keep\'', cwd: '/Users/runner/work/eslint-config/eslint-config/.temp/bd3kcaau5yv', durationMs: 145.547167, failed: true, timedOut: false, isCanceled: false, isGracefullyCanceled: false, isTerminated: false, isMaxBuffer: false, isForcefullyTerminated: false, exitCode: 1, stdout: '', stderr: 'file:///Users/runner/work/eslint-config/eslint-config/node_modules/.pnpm/[email protected]/node_modules/cac/dist/index.mjs:400\n throw new CACError(`Unknown option \`${name.length > 1 ? `--${name}` : `-${name}`}\``);\n ^\n\nCACError: Unknown option `--lint`\n at Command.checkUnknownOptions (file:///Users/runner/work/eslint-config/eslint-config/node_modules/.pnpm/[email protected]/node_modules/cac/dist/index.mjs:400:17)\n at CAC.runMatchedCommand (file:///Users/runner/work/eslint-config/eslint-config/node_modules/.pnpm/[email protected]/node_modules/cac/dist/index.mjs:598:13)\n at CAC.parse (file:///Users/runner/work/eslint-config/eslint-config/node_modules/.pnpm/[email protected]/node_modules/cac/dist/index.mjs:537:12)\n at file:///Users/runner/work/eslint-config/eslint-config/dist/cli.js:596:5\n at ModuleJob.run (node:internal/modules/esm/module_job:271:25)\n at async onImport.tracePromise.__proto__ (node:internal/modules/esm/loader:547:26)\n at async asyncRunEntryPointWithESMLoader (node:internal/modules/run_main:116:5)\n\nNode.js v22.13.0', stdio: [ undefined, '', 'file:///Users/runner/work/eslint-config/eslint-config/node_modules/.pnpm/[email protected]/node_modules/cac/dist/index.mjs:400\n throw new CACError(`Unknown option \`${name.length > 1 ? `--${name}` : `-${name}`}\``);\n ^\n\nCACError: Unknown option `--lint`\n at Command.checkUnknownOptions (file:///Users/runner/work/eslint-config/eslint-config/node_modules/.pnpm/[email protected]/node_modules/cac/dist/index.mjs:400:17)\n a

const pkgContent: Record<string, any> = await fs.readJSON(join(genPath, 'package.json'))
expect(pkgContent.scripts?.lint).toBe('custom-lint-command')
expect(stdout).toContain('Changes wrote to package.json')
})

it('lint script - check should add check script', async () => {
const { stdout } = await run(['--lint=check'])

Check failure on line 69 in test/cli.spec.ts

View workflow job for this annotation

GitHub Actions / test (lts/*, ubuntu-latest)

test/cli.spec.ts > lint script - check should add check script

ExecaError: Command failed with exit code 1: node /home/runner/work/eslint-config/eslint-config/bin/index.js '--lint=check' file:///home/runner/work/eslint-config/eslint-config/node_modules/.pnpm/[email protected]/node_modules/cac/dist/index.mjs:400 throw new CACError(`Unknown option \`${name.length > 1 ? `--${name}` : `-${name}`}\``); ^ CACError: Unknown option `--lint` at Command.checkUnknownOptions (file:///home/runner/work/eslint-config/eslint-config/node_modules/.pnpm/[email protected]/node_modules/cac/dist/index.mjs:400:17) at CAC.runMatchedCommand (file:///home/runner/work/eslint-config/eslint-config/node_modules/.pnpm/[email protected]/node_modules/cac/dist/index.mjs:598:13) at CAC.parse (file:///home/runner/work/eslint-config/eslint-config/node_modules/.pnpm/[email protected]/node_modules/cac/dist/index.mjs:537:12) at file:///home/runner/work/eslint-config/eslint-config/dist/cli.js:596:5 at ModuleJob.run (node:internal/modules/esm/module_job:271:25) at async onImport.tracePromise.__proto__ (node:internal/modules/esm/loader:578:26) at async asyncRunEntryPointWithESMLoader (node:internal/modules/run_main:116:5) Node.js v22.14.0 ❯ Command.checkUnknownOptions node_modules/.pnpm/[email protected]/node_modules/cac/dist/index.mjs:400:17 ❯ CAC.runMatchedCommand node_modules/.pnpm/[email protected]/node_modules/cac/dist/index.mjs:598:13 ❯ CAC.parse node_modules/.pnpm/[email protected]/node_modules/cac/dist/index.mjs:537:12 ❯ dist/cli.js:596:5 ❯ getFinalError node_modules/.pnpm/[email protected]/node_modules/execa/lib/return/final-error.js:6:9 ❯ makeError node_modules/.pnpm/[email protected]/node_modules/execa/lib/return/result.js:108:16 ❯ getAsyncResult node_modules/.pnpm/[email protected]/node_modules/execa/lib/methods/main-async.js:167:4 ❯ handlePromise node_modules/.pnpm/[email protected]/node_modules/execa/lib/methods/main-async.js:150:17 ❯ test/cli.spec.ts:69:22 ⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯ Serialized Error: { shortMessage: 'Command failed with exit code 1: node /home/runner/work/eslint-config/eslint-config/bin/index.js \'--lint=check\'', command: 'node /home/runner/work/eslint-config/eslint-config/bin/index.js --lint=check', escapedCommand: 'node /home/runner/work/eslint-config/eslint-config/bin/index.js \'--lint=check\'', cwd: '/home/runner/work/eslint-config/eslint-config/.temp/bm4py64byyq', durationMs: 231.597512, failed: true, timedOut: false, isCanceled: false, isGracefullyCanceled: false, isTerminated: false, isMaxBuffer: false, isForcefullyTerminated: false, exitCode: 1, stdout: '', stderr: 'file:///home/runner/work/eslint-config/eslint-config/node_modules/.pnpm/[email protected]/node_modules/cac/dist/index.mjs:400\n throw new CACError(`Unknown option \`${name.length > 1 ? `--${name}` : `-${name}`}\``);\n ^\n\nCACError: Unknown option `--lint`\n at Command.checkUnknownOptions (file:///home/runner/work/eslint-config/eslint-config/node_modules/.pnpm/[email protected]/node_modules/cac/dist/index.mjs:400:17)\n at CAC.runMatchedCommand (file:///home/runner/work/eslint-config/eslint-config/node_modules/.pnpm/[email protected]/node_modules/cac/dist/index.mjs:598:13)\n at CAC.parse (file:///home/runner/work/eslint-config/eslint-config/node_modules/.pnpm/[email protected]/node_modules/cac/dist/index.mjs:537:12)\n at file:///home/runner/work/eslint-config/eslint-config/dist/cli.js:596:5\n at ModuleJob.run (node:internal/modules/esm/module_job:271:25)\n at async onImport.tracePromise.__proto__ (node:internal/modules/esm/loader:578:26)\n at async asyncRunEntryPointWithESMLoader (node:internal/modules/run_main:116:5)\n\nNode.js v22.14.0', stdio: [ undefined, '', 'file:///home/runner/work/eslint-config/eslint-config/node_modules/.pnpm/[email protected]/node_modules/cac/dist/index.mjs:400\n throw new CACError(`Unknown option \`${name.length > 1 ? `--${name}` : `-${name}`}\``);\n ^\n\nCACError: Unknown option `--lint`\n at Command.checkUnknownOptions (file:///home/runner/work/eslint-config/eslint-config/node_modules/.pnpm/[email protected]/node_modules/cac/dist/index.mjs:400:17)\n at CAC.runMatc

Check failure on line 69 in test/cli.spec.ts

View workflow job for this annotation

GitHub Actions / test (lts/*, windows-latest)

test/cli.spec.ts > lint script - check should add check script

ExecaError: Command failed with exit code 1: node "D:\a\eslint-config\eslint-config\bin\index.js" "--lint=check" file:///D:/a/eslint-config/eslint-config/node_modules/.pnpm/[email protected]/node_modules/cac/dist/index.mjs:400\r throw new CACError(`Unknown option \`${name.length > 1 ? `--${name}` : `-${name}`}\``);\r ^\r \r CACError: Unknown option `--lint`\r at Command.checkUnknownOptions (file:///D:/a/eslint-config/eslint-config/node_modules/.pnpm/[email protected]/node_modules/cac/dist/index.mjs:400:17)\r at CAC.runMatchedCommand (file:///D:/a/eslint-config/eslint-config/node_modules/.pnpm/[email protected]/node_modules/cac/dist/index.mjs:598:13)\r at CAC.parse (file:///D:/a/eslint-config/eslint-config/node_modules/.pnpm/[email protected]/node_modules/cac/dist/index.mjs:537:12)\r at file:///D:/a/eslint-config/eslint-config/dist/cli.js:596:5\r at ModuleJob.run (node:internal/modules/esm/module_job:271:25)\r at async onImport.tracePromise.__proto__ (node:internal/modules/esm/loader:578:26)\r at async asyncRunEntryPointWithESMLoader (node:internal/modules/run_main:116:5)\r \r Node.js v22.14.0 ❯ getFinalError node_modules/.pnpm/[email protected]/node_modules/execa/lib/return/final-error.js:6:9 ❯ makeError node_modules/.pnpm/[email protected]/node_modules/execa/lib/return/result.js:108:16 ❯ getAsyncResult node_modules/.pnpm/[email protected]/node_modules/execa/lib/methods/main-async.js:167:4 ❯ handlePromise node_modules/.pnpm/[email protected]/node_modules/execa/lib/methods/main-async.js:150:17 ❯ test/cli.spec.ts:69:22 ⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯ Serialized Error: { shortMessage: 'Command failed with exit code 1: node "D:\a\eslint-config\eslint-config\bin\index.js" "--lint=check"', command: 'node D:\a\eslint-config\eslint-config\bin\index.js --lint=check', escapedCommand: 'node "D:\a\eslint-config\eslint-config\bin\index.js" "--lint=check"', cwd: 'D:\a\eslint-config\eslint-config\.temp\topu1a2z6b', durationMs: 205.1341, failed: true, timedOut: false, isCanceled: false, isGracefullyCanceled: false, isTerminated: false, isMaxBuffer: false, isForcefullyTerminated: false, exitCode: 1, stdout: '', stderr: 'file:///D:/a/eslint-config/eslint-config/node_modules/.pnpm/[email protected]/node_modules/cac/dist/index.mjs:400\r\n throw new CACError(`Unknown option \`${name.length > 1 ? `--${name}` : `-${name}`}\``);\r\n ^\r\n\r\nCACError: Unknown option `--lint`\r\n at Command.checkUnknownOptions (file:///D:/a/eslint-config/eslint-config/node_modules/.pnpm/[email protected]/node_modules/cac/dist/index.mjs:400:17)\r\n at CAC.runMatchedCommand (file:///D:/a/eslint-config/eslint-config/node_modules/.pnpm/[email protected]/node_modules/cac/dist/index.mjs:598:13)\r\n at CAC.parse (file:///D:/a/eslint-config/eslint-config/node_modules/.pnpm/[email protected]/node_modules/cac/dist/index.mjs:537:12)\r\n at file:///D:/a/eslint-config/eslint-config/dist/cli.js:596:5\r\n at ModuleJob.run (node:internal/modules/esm/module_job:271:25)\r\n at async onImport.tracePromise.__proto__ (node:internal/modules/esm/loader:578:26)\r\n at async asyncRunEntryPointWithESMLoader (node:internal/modules/run_main:116:5)\r\n\r\nNode.js v22.14.0', stdio: [ undefined, '', 'file:///D:/a/eslint-config/eslint-config/node_modules/.pnpm/[email protected]/node_modules/cac/dist/index.mjs:400\r\n throw new CACError(`Unknown option \`${name.length > 1 ? `--${name}` : `-${name}`}\``);\r\n ^\r\n\r\nCACError: Unknown option `--lint`\r\n at Command.checkUnknownOptions (file:///D:/a/eslint-config/eslint-config/node_modules/.pnpm/[email protected]/node_modules/cac/dist/index.mjs:400:17)\r\n at CAC.runMatchedCommand (file:///D:/a/eslint-config/eslint-config/node_modules/.pnpm/[email protected]/node_modules/cac/dist/index.mjs:598:13)\r\n at CAC.parse (file:///D:/a/eslint-config/eslint-config/node_modules/.pnpm/[email protected]/node_modules/cac/dist/index.mjs:537:12)\r\n at file:///D:/a/eslint-config/eslint-config/dist/cli.js:596:5\r\n at ModuleJob.run (node:internal/modules/esm/module_job:271:25)\r\n at async onImport.tracePromise.__proto__ (

Check failure on line 69 in test/cli.spec.ts

View workflow job for this annotation

GitHub Actions / test (lts/*, macos-latest)

test/cli.spec.ts > lint script - check should add check script

ExecaError: Command failed with exit code 1: node /Users/runner/work/eslint-config/eslint-config/bin/index.js '--lint=check' file:///Users/runner/work/eslint-config/eslint-config/node_modules/.pnpm/[email protected]/node_modules/cac/dist/index.mjs:400 throw new CACError(`Unknown option \`${name.length > 1 ? `--${name}` : `-${name}`}\``); ^ CACError: Unknown option `--lint` at Command.checkUnknownOptions (file:///Users/runner/work/eslint-config/eslint-config/node_modules/.pnpm/[email protected]/node_modules/cac/dist/index.mjs:400:17) at CAC.runMatchedCommand (file:///Users/runner/work/eslint-config/eslint-config/node_modules/.pnpm/[email protected]/node_modules/cac/dist/index.mjs:598:13) at CAC.parse (file:///Users/runner/work/eslint-config/eslint-config/node_modules/.pnpm/[email protected]/node_modules/cac/dist/index.mjs:537:12) at file:///Users/runner/work/eslint-config/eslint-config/dist/cli.js:596:5 at ModuleJob.run (node:internal/modules/esm/module_job:271:25) at async onImport.tracePromise.__proto__ (node:internal/modules/esm/loader:547:26) at async asyncRunEntryPointWithESMLoader (node:internal/modules/run_main:116:5) Node.js v22.13.0 ❯ Command.checkUnknownOptions node_modules/.pnpm/[email protected]/node_modules/cac/dist/index.mjs:400:17 ❯ CAC.runMatchedCommand node_modules/.pnpm/[email protected]/node_modules/cac/dist/index.mjs:598:13 ❯ CAC.parse node_modules/.pnpm/[email protected]/node_modules/cac/dist/index.mjs:537:12 ❯ dist/cli.js:596:5 ❯ getFinalError node_modules/.pnpm/[email protected]/node_modules/execa/lib/return/final-error.js:6:9 ❯ makeError node_modules/.pnpm/[email protected]/node_modules/execa/lib/return/result.js:108:16 ❯ getAsyncResult node_modules/.pnpm/[email protected]/node_modules/execa/lib/methods/main-async.js:167:4 ❯ handlePromise node_modules/.pnpm/[email protected]/node_modules/execa/lib/methods/main-async.js:150:17 ❯ test/cli.spec.ts:69:22 ⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯ Serialized Error: { shortMessage: 'Command failed with exit code 1: node /Users/runner/work/eslint-config/eslint-config/bin/index.js \'--lint=check\'', command: 'node /Users/runner/work/eslint-config/eslint-config/bin/index.js --lint=check', escapedCommand: 'node /Users/runner/work/eslint-config/eslint-config/bin/index.js \'--lint=check\'', cwd: '/Users/runner/work/eslint-config/eslint-config/.temp/bd3kcaau5yv', durationMs: 256.600167, failed: true, timedOut: false, isCanceled: false, isGracefullyCanceled: false, isTerminated: false, isMaxBuffer: false, isForcefullyTerminated: false, exitCode: 1, stdout: '', stderr: 'file:///Users/runner/work/eslint-config/eslint-config/node_modules/.pnpm/[email protected]/node_modules/cac/dist/index.mjs:400\n throw new CACError(`Unknown option \`${name.length > 1 ? `--${name}` : `-${name}`}\``);\n ^\n\nCACError: Unknown option `--lint`\n at Command.checkUnknownOptions (file:///Users/runner/work/eslint-config/eslint-config/node_modules/.pnpm/[email protected]/node_modules/cac/dist/index.mjs:400:17)\n at CAC.runMatchedCommand (file:///Users/runner/work/eslint-config/eslint-config/node_modules/.pnpm/[email protected]/node_modules/cac/dist/index.mjs:598:13)\n at CAC.parse (file:///Users/runner/work/eslint-config/eslint-config/node_modules/.pnpm/[email protected]/node_modules/cac/dist/index.mjs:537:12)\n at file:///Users/runner/work/eslint-config/eslint-config/dist/cli.js:596:5\n at ModuleJob.run (node:internal/modules/esm/module_job:271:25)\n at async onImport.tracePromise.__proto__ (node:internal/modules/esm/loader:547:26)\n at async asyncRunEntryPointWithESMLoader (node:internal/modules/run_main:116:5)\n\nNode.js v22.13.0', stdio: [ undefined, '', 'file:///Users/runner/work/eslint-config/eslint-config/node_modules/.pnpm/[email protected]/node_modules/cac/dist/index.mjs:400\n throw new CACError(`Unknown option \`${name.length > 1 ? `--${name}` : `-${name}`}\``);\n ^\n\nCACError: Unknown option `--lint`\n at Command.checkUnknownOptions (file:///Users/runner/work/eslint-config/eslint-config/node_modules/.pnpm/[email protected]/node_modules/cac/dist/index.mjs:400:17)\n

const pkgContent: Record<string, any> = await fs.readJSON(join(genPath, 'package.json'))
expect(pkgContent.scripts?.lint).toBe('eslint --cache')
expect(stdout).toContain('Changes wrote to package.json')
})

it('lint script - fix should add fix script', async () => {
const { stdout } = await run(['--lint=fix'])

Check failure on line 77 in test/cli.spec.ts

View workflow job for this annotation

GitHub Actions / test (lts/*, ubuntu-latest)

test/cli.spec.ts > lint script - fix should add fix script

ExecaError: Command failed with exit code 1: node /home/runner/work/eslint-config/eslint-config/bin/index.js '--lint=fix' file:///home/runner/work/eslint-config/eslint-config/node_modules/.pnpm/[email protected]/node_modules/cac/dist/index.mjs:400 throw new CACError(`Unknown option \`${name.length > 1 ? `--${name}` : `-${name}`}\``); ^ CACError: Unknown option `--lint` at Command.checkUnknownOptions (file:///home/runner/work/eslint-config/eslint-config/node_modules/.pnpm/[email protected]/node_modules/cac/dist/index.mjs:400:17) at CAC.runMatchedCommand (file:///home/runner/work/eslint-config/eslint-config/node_modules/.pnpm/[email protected]/node_modules/cac/dist/index.mjs:598:13) at CAC.parse (file:///home/runner/work/eslint-config/eslint-config/node_modules/.pnpm/[email protected]/node_modules/cac/dist/index.mjs:537:12) at file:///home/runner/work/eslint-config/eslint-config/dist/cli.js:596:5 at ModuleJob.run (node:internal/modules/esm/module_job:271:25) at async onImport.tracePromise.__proto__ (node:internal/modules/esm/loader:578:26) at async asyncRunEntryPointWithESMLoader (node:internal/modules/run_main:116:5) Node.js v22.14.0 ❯ Command.checkUnknownOptions node_modules/.pnpm/[email protected]/node_modules/cac/dist/index.mjs:400:17 ❯ CAC.runMatchedCommand node_modules/.pnpm/[email protected]/node_modules/cac/dist/index.mjs:598:13 ❯ CAC.parse node_modules/.pnpm/[email protected]/node_modules/cac/dist/index.mjs:537:12 ❯ dist/cli.js:596:5 ❯ getFinalError node_modules/.pnpm/[email protected]/node_modules/execa/lib/return/final-error.js:6:9 ❯ makeError node_modules/.pnpm/[email protected]/node_modules/execa/lib/return/result.js:108:16 ❯ getAsyncResult node_modules/.pnpm/[email protected]/node_modules/execa/lib/methods/main-async.js:167:4 ❯ handlePromise node_modules/.pnpm/[email protected]/node_modules/execa/lib/methods/main-async.js:150:17 ❯ test/cli.spec.ts:77:22 ⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯ Serialized Error: { shortMessage: 'Command failed with exit code 1: node /home/runner/work/eslint-config/eslint-config/bin/index.js \'--lint=fix\'', command: 'node /home/runner/work/eslint-config/eslint-config/bin/index.js --lint=fix', escapedCommand: 'node /home/runner/work/eslint-config/eslint-config/bin/index.js \'--lint=fix\'', cwd: '/home/runner/work/eslint-config/eslint-config/.temp/bm4py64byyq', durationMs: 180.18769, failed: true, timedOut: false, isCanceled: false, isGracefullyCanceled: false, isTerminated: false, isMaxBuffer: false, isForcefullyTerminated: false, exitCode: 1, stdout: '', stderr: 'file:///home/runner/work/eslint-config/eslint-config/node_modules/.pnpm/[email protected]/node_modules/cac/dist/index.mjs:400\n throw new CACError(`Unknown option \`${name.length > 1 ? `--${name}` : `-${name}`}\``);\n ^\n\nCACError: Unknown option `--lint`\n at Command.checkUnknownOptions (file:///home/runner/work/eslint-config/eslint-config/node_modules/.pnpm/[email protected]/node_modules/cac/dist/index.mjs:400:17)\n at CAC.runMatchedCommand (file:///home/runner/work/eslint-config/eslint-config/node_modules/.pnpm/[email protected]/node_modules/cac/dist/index.mjs:598:13)\n at CAC.parse (file:///home/runner/work/eslint-config/eslint-config/node_modules/.pnpm/[email protected]/node_modules/cac/dist/index.mjs:537:12)\n at file:///home/runner/work/eslint-config/eslint-config/dist/cli.js:596:5\n at ModuleJob.run (node:internal/modules/esm/module_job:271:25)\n at async onImport.tracePromise.__proto__ (node:internal/modules/esm/loader:578:26)\n at async asyncRunEntryPointWithESMLoader (node:internal/modules/run_main:116:5)\n\nNode.js v22.14.0', stdio: [ undefined, '', 'file:///home/runner/work/eslint-config/eslint-config/node_modules/.pnpm/[email protected]/node_modules/cac/dist/index.mjs:400\n throw new CACError(`Unknown option \`${name.length > 1 ? `--${name}` : `-${name}`}\``);\n ^\n\nCACError: Unknown option `--lint`\n at Command.checkUnknownOptions (file:///home/runner/work/eslint-config/eslint-config/node_modules/.pnpm/[email protected]/node_modules/cac/dist/index.mjs:400:17)\n at CAC.runMatchedComman

Check failure on line 77 in test/cli.spec.ts

View workflow job for this annotation

GitHub Actions / test (lts/*, windows-latest)

test/cli.spec.ts > lint script - fix should add fix script

ExecaError: Command failed with exit code 1: node "D:\a\eslint-config\eslint-config\bin\index.js" "--lint=fix" file:///D:/a/eslint-config/eslint-config/node_modules/.pnpm/[email protected]/node_modules/cac/dist/index.mjs:400\r throw new CACError(`Unknown option \`${name.length > 1 ? `--${name}` : `-${name}`}\``);\r ^\r \r CACError: Unknown option `--lint`\r at Command.checkUnknownOptions (file:///D:/a/eslint-config/eslint-config/node_modules/.pnpm/[email protected]/node_modules/cac/dist/index.mjs:400:17)\r at CAC.runMatchedCommand (file:///D:/a/eslint-config/eslint-config/node_modules/.pnpm/[email protected]/node_modules/cac/dist/index.mjs:598:13)\r at CAC.parse (file:///D:/a/eslint-config/eslint-config/node_modules/.pnpm/[email protected]/node_modules/cac/dist/index.mjs:537:12)\r at file:///D:/a/eslint-config/eslint-config/dist/cli.js:596:5\r at ModuleJob.run (node:internal/modules/esm/module_job:271:25)\r at async onImport.tracePromise.__proto__ (node:internal/modules/esm/loader:578:26)\r at async asyncRunEntryPointWithESMLoader (node:internal/modules/run_main:116:5)\r \r Node.js v22.14.0 ❯ getFinalError node_modules/.pnpm/[email protected]/node_modules/execa/lib/return/final-error.js:6:9 ❯ makeError node_modules/.pnpm/[email protected]/node_modules/execa/lib/return/result.js:108:16 ❯ getAsyncResult node_modules/.pnpm/[email protected]/node_modules/execa/lib/methods/main-async.js:167:4 ❯ handlePromise node_modules/.pnpm/[email protected]/node_modules/execa/lib/methods/main-async.js:150:17 ❯ test/cli.spec.ts:77:22 ⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯ Serialized Error: { shortMessage: 'Command failed with exit code 1: node "D:\a\eslint-config\eslint-config\bin\index.js" "--lint=fix"', command: 'node D:\a\eslint-config\eslint-config\bin\index.js --lint=fix', escapedCommand: 'node "D:\a\eslint-config\eslint-config\bin\index.js" "--lint=fix"', cwd: 'D:\a\eslint-config\eslint-config\.temp\topu1a2z6b', durationMs: 480.989, failed: true, timedOut: false, isCanceled: false, isGracefullyCanceled: false, isTerminated: false, isMaxBuffer: false, isForcefullyTerminated: false, exitCode: 1, stdout: '', stderr: 'file:///D:/a/eslint-config/eslint-config/node_modules/.pnpm/[email protected]/node_modules/cac/dist/index.mjs:400\r\n throw new CACError(`Unknown option \`${name.length > 1 ? `--${name}` : `-${name}`}\``);\r\n ^\r\n\r\nCACError: Unknown option `--lint`\r\n at Command.checkUnknownOptions (file:///D:/a/eslint-config/eslint-config/node_modules/.pnpm/[email protected]/node_modules/cac/dist/index.mjs:400:17)\r\n at CAC.runMatchedCommand (file:///D:/a/eslint-config/eslint-config/node_modules/.pnpm/[email protected]/node_modules/cac/dist/index.mjs:598:13)\r\n at CAC.parse (file:///D:/a/eslint-config/eslint-config/node_modules/.pnpm/[email protected]/node_modules/cac/dist/index.mjs:537:12)\r\n at file:///D:/a/eslint-config/eslint-config/dist/cli.js:596:5\r\n at ModuleJob.run (node:internal/modules/esm/module_job:271:25)\r\n at async onImport.tracePromise.__proto__ (node:internal/modules/esm/loader:578:26)\r\n at async asyncRunEntryPointWithESMLoader (node:internal/modules/run_main:116:5)\r\n\r\nNode.js v22.14.0', stdio: [ undefined, '', 'file:///D:/a/eslint-config/eslint-config/node_modules/.pnpm/[email protected]/node_modules/cac/dist/index.mjs:400\r\n throw new CACError(`Unknown option \`${name.length > 1 ? `--${name}` : `-${name}`}\``);\r\n ^\r\n\r\nCACError: Unknown option `--lint`\r\n at Command.checkUnknownOptions (file:///D:/a/eslint-config/eslint-config/node_modules/.pnpm/[email protected]/node_modules/cac/dist/index.mjs:400:17)\r\n at CAC.runMatchedCommand (file:///D:/a/eslint-config/eslint-config/node_modules/.pnpm/[email protected]/node_modules/cac/dist/index.mjs:598:13)\r\n at CAC.parse (file:///D:/a/eslint-config/eslint-config/node_modules/.pnpm/[email protected]/node_modules/cac/dist/index.mjs:537:12)\r\n at file:///D:/a/eslint-config/eslint-config/dist/cli.js:596:5\r\n at ModuleJob.run (node:internal/modules/esm/module_job:271:25)\r\n at async onImport.tracePromise.__proto__ (node:inte

Check failure on line 77 in test/cli.spec.ts

View workflow job for this annotation

GitHub Actions / test (lts/*, macos-latest)

test/cli.spec.ts > lint script - fix should add fix script

ExecaError: Command failed with exit code 1: node /Users/runner/work/eslint-config/eslint-config/bin/index.js '--lint=fix' file:///Users/runner/work/eslint-config/eslint-config/node_modules/.pnpm/[email protected]/node_modules/cac/dist/index.mjs:400 throw new CACError(`Unknown option \`${name.length > 1 ? `--${name}` : `-${name}`}\``); ^ CACError: Unknown option `--lint` at Command.checkUnknownOptions (file:///Users/runner/work/eslint-config/eslint-config/node_modules/.pnpm/[email protected]/node_modules/cac/dist/index.mjs:400:17) at CAC.runMatchedCommand (file:///Users/runner/work/eslint-config/eslint-config/node_modules/.pnpm/[email protected]/node_modules/cac/dist/index.mjs:598:13) at CAC.parse (file:///Users/runner/work/eslint-config/eslint-config/node_modules/.pnpm/[email protected]/node_modules/cac/dist/index.mjs:537:12) at file:///Users/runner/work/eslint-config/eslint-config/dist/cli.js:596:5 at ModuleJob.run (node:internal/modules/esm/module_job:271:25) at async onImport.tracePromise.__proto__ (node:internal/modules/esm/loader:547:26) at async asyncRunEntryPointWithESMLoader (node:internal/modules/run_main:116:5) Node.js v22.13.0 ❯ Command.checkUnknownOptions node_modules/.pnpm/[email protected]/node_modules/cac/dist/index.mjs:400:17 ❯ CAC.runMatchedCommand node_modules/.pnpm/[email protected]/node_modules/cac/dist/index.mjs:598:13 ❯ CAC.parse node_modules/.pnpm/[email protected]/node_modules/cac/dist/index.mjs:537:12 ❯ dist/cli.js:596:5 ❯ getFinalError node_modules/.pnpm/[email protected]/node_modules/execa/lib/return/final-error.js:6:9 ❯ makeError node_modules/.pnpm/[email protected]/node_modules/execa/lib/return/result.js:108:16 ❯ getAsyncResult node_modules/.pnpm/[email protected]/node_modules/execa/lib/methods/main-async.js:167:4 ❯ handlePromise node_modules/.pnpm/[email protected]/node_modules/execa/lib/methods/main-async.js:150:17 ❯ test/cli.spec.ts:77:22 ⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯ Serialized Error: { shortMessage: 'Command failed with exit code 1: node /Users/runner/work/eslint-config/eslint-config/bin/index.js \'--lint=fix\'', command: 'node /Users/runner/work/eslint-config/eslint-config/bin/index.js --lint=fix', escapedCommand: 'node /Users/runner/work/eslint-config/eslint-config/bin/index.js \'--lint=fix\'', cwd: '/Users/runner/work/eslint-config/eslint-config/.temp/bd3kcaau5yv', durationMs: 179.564583, failed: true, timedOut: false, isCanceled: false, isGracefullyCanceled: false, isTerminated: false, isMaxBuffer: false, isForcefullyTerminated: false, exitCode: 1, stdout: '', stderr: 'file:///Users/runner/work/eslint-config/eslint-config/node_modules/.pnpm/[email protected]/node_modules/cac/dist/index.mjs:400\n throw new CACError(`Unknown option \`${name.length > 1 ? `--${name}` : `-${name}`}\``);\n ^\n\nCACError: Unknown option `--lint`\n at Command.checkUnknownOptions (file:///Users/runner/work/eslint-config/eslint-config/node_modules/.pnpm/[email protected]/node_modules/cac/dist/index.mjs:400:17)\n at CAC.runMatchedCommand (file:///Users/runner/work/eslint-config/eslint-config/node_modules/.pnpm/[email protected]/node_modules/cac/dist/index.mjs:598:13)\n at CAC.parse (file:///Users/runner/work/eslint-config/eslint-config/node_modules/.pnpm/[email protected]/node_modules/cac/dist/index.mjs:537:12)\n at file:///Users/runner/work/eslint-config/eslint-config/dist/cli.js:596:5\n at ModuleJob.run (node:internal/modules/esm/module_job:271:25)\n at async onImport.tracePromise.__proto__ (node:internal/modules/esm/loader:547:26)\n at async asyncRunEntryPointWithESMLoader (node:internal/modules/run_main:116:5)\n\nNode.js v22.13.0', stdio: [ undefined, '', 'file:///Users/runner/work/eslint-config/eslint-config/node_modules/.pnpm/[email protected]/node_modules/cac/dist/index.mjs:400\n throw new CACError(`Unknown option \`${name.length > 1 ? `--${name}` : `-${name}`}\``);\n ^\n\nCACError: Unknown option `--lint`\n at Command.checkUnknownOptions (file:///Users/runner/work/eslint-config/eslint-config/node_modules/.pnpm/[email protected]/node_modules/cac/dist/index.mjs:400:17)\n at CA

const pkgContent: Record<string, any> = await fs.readJSON(join(genPath, 'package.json'))
expect(pkgContent.scripts?.lint).toBe('eslint --fix --cache')
expect(stdout).toContain('Changes wrote to package.json')
})

it('lint script - keep should not add script if none exists', async () => {
const { stdout } = await run(['--lint=keep'])

Check failure on line 85 in test/cli.spec.ts

View workflow job for this annotation

GitHub Actions / test (lts/*, ubuntu-latest)

test/cli.spec.ts > lint script - keep should not add script if none exists

ExecaError: Command failed with exit code 1: node /home/runner/work/eslint-config/eslint-config/bin/index.js '--lint=keep' file:///home/runner/work/eslint-config/eslint-config/node_modules/.pnpm/[email protected]/node_modules/cac/dist/index.mjs:400 throw new CACError(`Unknown option \`${name.length > 1 ? `--${name}` : `-${name}`}\``); ^ CACError: Unknown option `--lint` at Command.checkUnknownOptions (file:///home/runner/work/eslint-config/eslint-config/node_modules/.pnpm/[email protected]/node_modules/cac/dist/index.mjs:400:17) at CAC.runMatchedCommand (file:///home/runner/work/eslint-config/eslint-config/node_modules/.pnpm/[email protected]/node_modules/cac/dist/index.mjs:598:13) at CAC.parse (file:///home/runner/work/eslint-config/eslint-config/node_modules/.pnpm/[email protected]/node_modules/cac/dist/index.mjs:537:12) at file:///home/runner/work/eslint-config/eslint-config/dist/cli.js:596:5 at ModuleJob.run (node:internal/modules/esm/module_job:271:25) at async onImport.tracePromise.__proto__ (node:internal/modules/esm/loader:578:26) at async asyncRunEntryPointWithESMLoader (node:internal/modules/run_main:116:5) Node.js v22.14.0 ❯ Command.checkUnknownOptions node_modules/.pnpm/[email protected]/node_modules/cac/dist/index.mjs:400:17 ❯ CAC.runMatchedCommand node_modules/.pnpm/[email protected]/node_modules/cac/dist/index.mjs:598:13 ❯ CAC.parse node_modules/.pnpm/[email protected]/node_modules/cac/dist/index.mjs:537:12 ❯ dist/cli.js:596:5 ❯ getFinalError node_modules/.pnpm/[email protected]/node_modules/execa/lib/return/final-error.js:6:9 ❯ makeError node_modules/.pnpm/[email protected]/node_modules/execa/lib/return/result.js:108:16 ❯ getAsyncResult node_modules/.pnpm/[email protected]/node_modules/execa/lib/methods/main-async.js:167:4 ❯ handlePromise node_modules/.pnpm/[email protected]/node_modules/execa/lib/methods/main-async.js:150:17 ❯ test/cli.spec.ts:85:22 ⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯ Serialized Error: { shortMessage: 'Command failed with exit code 1: node /home/runner/work/eslint-config/eslint-config/bin/index.js \'--lint=keep\'', command: 'node /home/runner/work/eslint-config/eslint-config/bin/index.js --lint=keep', escapedCommand: 'node /home/runner/work/eslint-config/eslint-config/bin/index.js \'--lint=keep\'', cwd: '/home/runner/work/eslint-config/eslint-config/.temp/bm4py64byyq', durationMs: 123.678533, failed: true, timedOut: false, isCanceled: false, isGracefullyCanceled: false, isTerminated: false, isMaxBuffer: false, isForcefullyTerminated: false, exitCode: 1, stdout: '', stderr: 'file:///home/runner/work/eslint-config/eslint-config/node_modules/.pnpm/[email protected]/node_modules/cac/dist/index.mjs:400\n throw new CACError(`Unknown option \`${name.length > 1 ? `--${name}` : `-${name}`}\``);\n ^\n\nCACError: Unknown option `--lint`\n at Command.checkUnknownOptions (file:///home/runner/work/eslint-config/eslint-config/node_modules/.pnpm/[email protected]/node_modules/cac/dist/index.mjs:400:17)\n at CAC.runMatchedCommand (file:///home/runner/work/eslint-config/eslint-config/node_modules/.pnpm/[email protected]/node_modules/cac/dist/index.mjs:598:13)\n at CAC.parse (file:///home/runner/work/eslint-config/eslint-config/node_modules/.pnpm/[email protected]/node_modules/cac/dist/index.mjs:537:12)\n at file:///home/runner/work/eslint-config/eslint-config/dist/cli.js:596:5\n at ModuleJob.run (node:internal/modules/esm/module_job:271:25)\n at async onImport.tracePromise.__proto__ (node:internal/modules/esm/loader:578:26)\n at async asyncRunEntryPointWithESMLoader (node:internal/modules/run_main:116:5)\n\nNode.js v22.14.0', stdio: [ undefined, '', 'file:///home/runner/work/eslint-config/eslint-config/node_modules/.pnpm/[email protected]/node_modules/cac/dist/index.mjs:400\n throw new CACError(`Unknown option \`${name.length > 1 ? `--${name}` : `-${name}`}\``);\n ^\n\nCACError: Unknown option `--lint`\n at Command.checkUnknownOptions (file:///home/runner/work/eslint-config/eslint-config/node_modules/.pnpm/[email protected]/node_modules/cac/dist/index.mjs:400:17)\n at CAC.runMatchedC

Check failure on line 85 in test/cli.spec.ts

View workflow job for this annotation

GitHub Actions / test (lts/*, windows-latest)

test/cli.spec.ts > lint script - keep should not add script if none exists

ExecaError: Command failed with exit code 1: node "D:\a\eslint-config\eslint-config\bin\index.js" "--lint=keep" file:///D:/a/eslint-config/eslint-config/node_modules/.pnpm/[email protected]/node_modules/cac/dist/index.mjs:400\r throw new CACError(`Unknown option \`${name.length > 1 ? `--${name}` : `-${name}`}\``);\r ^\r \r CACError: Unknown option `--lint`\r at Command.checkUnknownOptions (file:///D:/a/eslint-config/eslint-config/node_modules/.pnpm/[email protected]/node_modules/cac/dist/index.mjs:400:17)\r at CAC.runMatchedCommand (file:///D:/a/eslint-config/eslint-config/node_modules/.pnpm/[email protected]/node_modules/cac/dist/index.mjs:598:13)\r at CAC.parse (file:///D:/a/eslint-config/eslint-config/node_modules/.pnpm/[email protected]/node_modules/cac/dist/index.mjs:537:12)\r at file:///D:/a/eslint-config/eslint-config/dist/cli.js:596:5\r at ModuleJob.run (node:internal/modules/esm/module_job:271:25)\r at async onImport.tracePromise.__proto__ (node:internal/modules/esm/loader:578:26)\r at async asyncRunEntryPointWithESMLoader (node:internal/modules/run_main:116:5)\r \r Node.js v22.14.0 ❯ getFinalError node_modules/.pnpm/[email protected]/node_modules/execa/lib/return/final-error.js:6:9 ❯ makeError node_modules/.pnpm/[email protected]/node_modules/execa/lib/return/result.js:108:16 ❯ getAsyncResult node_modules/.pnpm/[email protected]/node_modules/execa/lib/methods/main-async.js:167:4 ❯ handlePromise node_modules/.pnpm/[email protected]/node_modules/execa/lib/methods/main-async.js:150:17 ❯ test/cli.spec.ts:85:22 ⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯ Serialized Error: { shortMessage: 'Command failed with exit code 1: node "D:\a\eslint-config\eslint-config\bin\index.js" "--lint=keep"', command: 'node D:\a\eslint-config\eslint-config\bin\index.js --lint=keep', escapedCommand: 'node "D:\a\eslint-config\eslint-config\bin\index.js" "--lint=keep"', cwd: 'D:\a\eslint-config\eslint-config\.temp\topu1a2z6b', durationMs: 678.4638, failed: true, timedOut: false, isCanceled: false, isGracefullyCanceled: false, isTerminated: false, isMaxBuffer: false, isForcefullyTerminated: false, exitCode: 1, stdout: '', stderr: 'file:///D:/a/eslint-config/eslint-config/node_modules/.pnpm/[email protected]/node_modules/cac/dist/index.mjs:400\r\n throw new CACError(`Unknown option \`${name.length > 1 ? `--${name}` : `-${name}`}\``);\r\n ^\r\n\r\nCACError: Unknown option `--lint`\r\n at Command.checkUnknownOptions (file:///D:/a/eslint-config/eslint-config/node_modules/.pnpm/[email protected]/node_modules/cac/dist/index.mjs:400:17)\r\n at CAC.runMatchedCommand (file:///D:/a/eslint-config/eslint-config/node_modules/.pnpm/[email protected]/node_modules/cac/dist/index.mjs:598:13)\r\n at CAC.parse (file:///D:/a/eslint-config/eslint-config/node_modules/.pnpm/[email protected]/node_modules/cac/dist/index.mjs:537:12)\r\n at file:///D:/a/eslint-config/eslint-config/dist/cli.js:596:5\r\n at ModuleJob.run (node:internal/modules/esm/module_job:271:25)\r\n at async onImport.tracePromise.__proto__ (node:internal/modules/esm/loader:578:26)\r\n at async asyncRunEntryPointWithESMLoader (node:internal/modules/run_main:116:5)\r\n\r\nNode.js v22.14.0', stdio: [ undefined, '', 'file:///D:/a/eslint-config/eslint-config/node_modules/.pnpm/[email protected]/node_modules/cac/dist/index.mjs:400\r\n throw new CACError(`Unknown option \`${name.length > 1 ? `--${name}` : `-${name}`}\``);\r\n ^\r\n\r\nCACError: Unknown option `--lint`\r\n at Command.checkUnknownOptions (file:///D:/a/eslint-config/eslint-config/node_modules/.pnpm/[email protected]/node_modules/cac/dist/index.mjs:400:17)\r\n at CAC.runMatchedCommand (file:///D:/a/eslint-config/eslint-config/node_modules/.pnpm/[email protected]/node_modules/cac/dist/index.mjs:598:13)\r\n at CAC.parse (file:///D:/a/eslint-config/eslint-config/node_modules/.pnpm/[email protected]/node_modules/cac/dist/index.mjs:537:12)\r\n at file:///D:/a/eslint-config/eslint-config/dist/cli.js:596:5\r\n at ModuleJob.run (node:internal/modules/esm/module_job:271:25)\r\n at async onImport.tracePromise.__proto__ (node

Check failure on line 85 in test/cli.spec.ts

View workflow job for this annotation

GitHub Actions / test (lts/*, macos-latest)

test/cli.spec.ts > lint script - keep should not add script if none exists

ExecaError: Command failed with exit code 1: node /Users/runner/work/eslint-config/eslint-config/bin/index.js '--lint=keep' file:///Users/runner/work/eslint-config/eslint-config/node_modules/.pnpm/[email protected]/node_modules/cac/dist/index.mjs:400 throw new CACError(`Unknown option \`${name.length > 1 ? `--${name}` : `-${name}`}\``); ^ CACError: Unknown option `--lint` at Command.checkUnknownOptions (file:///Users/runner/work/eslint-config/eslint-config/node_modules/.pnpm/[email protected]/node_modules/cac/dist/index.mjs:400:17) at CAC.runMatchedCommand (file:///Users/runner/work/eslint-config/eslint-config/node_modules/.pnpm/[email protected]/node_modules/cac/dist/index.mjs:598:13) at CAC.parse (file:///Users/runner/work/eslint-config/eslint-config/node_modules/.pnpm/[email protected]/node_modules/cac/dist/index.mjs:537:12) at file:///Users/runner/work/eslint-config/eslint-config/dist/cli.js:596:5 at ModuleJob.run (node:internal/modules/esm/module_job:271:25) at async onImport.tracePromise.__proto__ (node:internal/modules/esm/loader:547:26) at async asyncRunEntryPointWithESMLoader (node:internal/modules/run_main:116:5) Node.js v22.13.0 ❯ Command.checkUnknownOptions node_modules/.pnpm/[email protected]/node_modules/cac/dist/index.mjs:400:17 ❯ CAC.runMatchedCommand node_modules/.pnpm/[email protected]/node_modules/cac/dist/index.mjs:598:13 ❯ CAC.parse node_modules/.pnpm/[email protected]/node_modules/cac/dist/index.mjs:537:12 ❯ dist/cli.js:596:5 ❯ getFinalError node_modules/.pnpm/[email protected]/node_modules/execa/lib/return/final-error.js:6:9 ❯ makeError node_modules/.pnpm/[email protected]/node_modules/execa/lib/return/result.js:108:16 ❯ getAsyncResult node_modules/.pnpm/[email protected]/node_modules/execa/lib/methods/main-async.js:167:4 ❯ handlePromise node_modules/.pnpm/[email protected]/node_modules/execa/lib/methods/main-async.js:150:17 ❯ test/cli.spec.ts:85:22 ⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯ Serialized Error: { shortMessage: 'Command failed with exit code 1: node /Users/runner/work/eslint-config/eslint-config/bin/index.js \'--lint=keep\'', command: 'node /Users/runner/work/eslint-config/eslint-config/bin/index.js --lint=keep', escapedCommand: 'node /Users/runner/work/eslint-config/eslint-config/bin/index.js \'--lint=keep\'', cwd: '/Users/runner/work/eslint-config/eslint-config/.temp/bd3kcaau5yv', durationMs: 153.429125, failed: true, timedOut: false, isCanceled: false, isGracefullyCanceled: false, isTerminated: false, isMaxBuffer: false, isForcefullyTerminated: false, exitCode: 1, stdout: '', stderr: 'file:///Users/runner/work/eslint-config/eslint-config/node_modules/.pnpm/[email protected]/node_modules/cac/dist/index.mjs:400\n throw new CACError(`Unknown option \`${name.length > 1 ? `--${name}` : `-${name}`}\``);\n ^\n\nCACError: Unknown option `--lint`\n at Command.checkUnknownOptions (file:///Users/runner/work/eslint-config/eslint-config/node_modules/.pnpm/[email protected]/node_modules/cac/dist/index.mjs:400:17)\n at CAC.runMatchedCommand (file:///Users/runner/work/eslint-config/eslint-config/node_modules/.pnpm/[email protected]/node_modules/cac/dist/index.mjs:598:13)\n at CAC.parse (file:///Users/runner/work/eslint-config/eslint-config/node_modules/.pnpm/[email protected]/node_modules/cac/dist/index.mjs:537:12)\n at file:///Users/runner/work/eslint-config/eslint-config/dist/cli.js:596:5\n at ModuleJob.run (node:internal/modules/esm/module_job:271:25)\n at async onImport.tracePromise.__proto__ (node:internal/modules/esm/loader:547:26)\n at async asyncRunEntryPointWithESMLoader (node:internal/modules/run_main:116:5)\n\nNode.js v22.13.0', stdio: [ undefined, '', 'file:///Users/runner/work/eslint-config/eslint-config/node_modules/.pnpm/[email protected]/node_modules/cac/dist/index.mjs:400\n throw new CACError(`Unknown option \`${name.length > 1 ? `--${name}` : `-${name}`}\``);\n ^\n\nCACError: Unknown option `--lint`\n at Command.checkUnknownOptions (file:///Users/runner/work/eslint-config/eslint-config/node_modules/.pnpm/[email protected]/node_modules/cac/dist/index.mjs:400:17)\n a

const pkgContent: Record<string, any> = await fs.readJSON(join(genPath, 'package.json'))
expect(pkgContent.scripts?.lint).toBeUndefined()
expect(stdout).toContain('Changes wrote to package.json')
})

it('esm eslint.config.js', async () => {
const pkgContent = await fs.readFile('package.json', 'utf-8')
await fs.writeFile(join(genPath, 'package.json'), JSON.stringify({ ...JSON.parse(pkgContent), type: 'module' }, null, 2))
Expand Down
Loading