Skip to content
Merged
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
12 changes: 12 additions & 0 deletions .nsprc
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"1240992": {
"active": true,
"notes": "braces DoS via skott > depcheck > findup-sync > micromatch; no patched release. Dev-time tool on own source.",
"expiry": "2026-10-13"
},
"1241202": {
"active": true,
"notes": "sprintf-js DoS via skott > depcheck > js-yaml@3 > argparse; no patched release. Dev-time tool on own source.",
"expiry": "2026-10-13"
}
}
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ Flags on the bare `verifyx` command:
| `forbidden-strings` | native | Disallowed JSON config values, from rules in your verify config. |
| `lint` | external | Linting; auto-fixes locally, checks in CI ([oxlint](https://oxc.rs)). |
| `format` | external | Formatting; writes locally, checks in CI ([oxfmt](https://oxc.rs)). |
| `check-types` | external | TypeScript type check (`tsc --noEmit`); skips when there is no `tsconfig.json`. |
| `check-types` | external | TypeScript type check (`tsc --noEmit`, or `tsc -b` when `tsconfig.json` has `references`, so referenced configs need `noEmit`); skips when there is no `tsconfig.json`. |
| `unused-code` | external | Unused files, exports and dependencies ([knip](https://knip.dev)). |
| `circular-deps` | external | Circular dependencies ([skott](https://github.com/antoine-coulon/skott)). |
| `duplicate-code` | external | Copy-paste detection ([jscpd](https://github.com/kucherenko/jscpd)). |
Expand Down
898 changes: 458 additions & 440 deletions package-lock.json

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -68,18 +68,18 @@
"@rollup/plugin-typescript": "^12.3.0",
"@types/cross-spawn": "^6.0.6",
"@types/node": "^26.1.1",
"@vitest/coverage-v8": "^4.1.10",
"@vitest/coverage-v8": "^5.0.3",
"better-npm-audit": "^3.11.0",
"jscpd": "^5.0.11",
"knip": "^6.25.0",
"npm-run-all2": "^9.0.2",
"oxfmt": "^0.58.0",
"oxfmt": "^0.71.0",
"oxlint": "^1.73.0",
"rimraf": "^6.1.3",
"rollup": "^4.62.2",
"skott": "^0.35.11",
"tslib": "^2.8.1",
"vitest": "^4.1.10"
"vitest": "^5.0.3"
},
"peerDependencies": {
"jscpd": "^5.0.11",
Expand Down
6 changes: 5 additions & 1 deletion src/checks/registry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { defineExternalCheck } from './external.ts'
import { runForbiddenStrings } from './forbidden-strings.ts'
import { runHardcodedColors } from './hardcoded-colors.ts'
import { jscpdCount } from './maxWarnings.ts'
import { typeCheckCommand } from './tsconfig.ts'
import type { Check, CheckResult } from './types.ts'

function nativeCheck(name: string, description: string, recommended: boolean, run: () => CheckResult, script = `verifyx ${name}`): Check {
Expand Down Expand Up @@ -57,7 +58,10 @@ export const CHECKS: Check[] = [
name: 'check-types',
description: 'TypeScript type check',
bin: 'tsc',
checkCommand: ['tsc', '--noEmit'],
// Use a getter so the command is resolved per run/eject in the target project.
get checkCommand() {
return typeCheckCommand()
},
devDeps: ['typescript'],
canRun: () => fs.existsSync('tsconfig.json'),
recommended: true,
Expand Down
42 changes: 42 additions & 0 deletions src/checks/tsconfig.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import fs from 'node:fs'
import os from 'node:os'
import path from 'node:path'

import { afterEach, beforeEach, describe, expect, it } from 'vitest'

import { typeCheckCommand } from './tsconfig.ts'

let dir: string
beforeEach(() => {
dir = fs.mkdtempSync(path.join(os.tmpdir(), 'verifyx-tsconfig-'))
})
afterEach(() => {
fs.rmSync(dir, { recursive: true, force: true })
})

const writeTsconfig = (text: string) => fs.writeFileSync(path.join(dir, 'tsconfig.json'), text)

describe('typeCheckCommand', () => {
it('uses tsc --noEmit for a plain tsconfig', () => {
writeTsconfig('{ "compilerOptions": { "strict": true } }')
expect(typeCheckCommand(dir)).toEqual(['tsc', '--noEmit'])
})

it('uses build mode for a solution-style tsconfig with references, tolerating JSONC', () => {
writeTsconfig(`{
// Vite template
"files": [],
"references": [{ "path": "./tsconfig.app.json" }, { "path": "./tsconfig.node.json" },],
}`)
expect(typeCheckCommand(dir)).toEqual(['tsc', '-b'])
})

it('uses tsc --noEmit when references is empty', () => {
writeTsconfig('{ "references": [] }')
expect(typeCheckCommand(dir)).toEqual(['tsc', '--noEmit'])
})

it('returns tsc --noEmit rather than throwing when tsconfig is missing (eject ignores canRun)', () => {
expect(typeCheckCommand(dir)).toEqual(['tsc', '--noEmit'])
})
})
14 changes: 14 additions & 0 deletions src/checks/tsconfig.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import path from 'node:path'

import ts from 'typescript'

/** returns `true` when the tsconfig declares project `references` (e.g. Vite's solution-style root) */
function hasProjectReferences(cwd: string = process.cwd()): boolean {
const { config } = ts.readConfigFile(path.join(cwd, 'tsconfig.json'), ts.sys.readFile)
return Array.isArray(config?.references) && config.references.length > 0
}

/** Generate the appropriate type-check command for the project's tsconfig */
export function typeCheckCommand(cwd: string = process.cwd()): readonly string[] {
return hasProjectReferences(cwd) ? ['tsc', '-b'] : ['tsc', '--noEmit']
}
Loading