Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into deps
Browse files Browse the repository at this point in the history
  • Loading branch information
mmkal committed Jan 26, 2025
2 parents 23837f4 + 29f42a3 commit 46b83fe
Show file tree
Hide file tree
Showing 4 changed files with 102 additions and 1 deletion.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
"@types/node": "22.10.10",
"eslint": "^8.57.0",
"execa": "^9.0.0",
"link": "^2.1.1",
"np": "^10.0.7",
"pkg-pr-new": "^0.0.39",
"tsx": "^4.7.1",
Expand Down
11 changes: 10 additions & 1 deletion pnpm-lock.yaml

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

50 changes: 50 additions & 0 deletions test/__snapshots__/mmkal-repos.test.ts.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html

exports[`lint https://github.com/mmkal/expect-type 1`] = `
"
> [email protected] eslint <dir>/expect-type
> eslint --max-warnings 0 "." "--fix" "--max-warnings" "0"
<dir>/expect-type/src/branding.ts
<line>:<col> error The \`Function\` type accepts any function-like value.
Prefer explicitly defining any function parameters and return type @typescript-eslint/no-unsafe-function-type
<dir>/expect-type/src/index.ts
<line>:<col> error The \`Function\` type accepts any function-like value.
Prefer explicitly defining any function parameters and return type @typescript-eslint/no-unsafe-function-type
<dir>/expect-type/src/utils.ts
<line>:<col> error 'secret' is assigned a value but only used as a type. Allowed unused vars must match /^_/u @typescript-eslint/no-unused-vars
<dir>/expect-type/test/ts-output.ts
<line>:<col> warning Use default import for module \`node:path\` unicorn/import-style
<dir>/expect-type/test/types.test.ts
<line>:<col> error Expected an assignment or function call and instead saw an expression @typescript-eslint/no-unused-expressions
<line>:<col> error Expected an assignment or function call and instead saw an expression @typescript-eslint/no-unused-expressions
<dir>/expect-type/test/usage.test.ts
<line>:<col> error 'A' is defined but only used as a type. Allowed unused vars must match /^_/u @typescript-eslint/no-unused-vars
<line>:<col> error 'B' is defined but only used as a type. Allowed unused vars must match /^_/u @typescript-eslint/no-unused-vars
<line>:<col> error 'C' is defined but only used as a type. Allowed unused vars must match /^_/u @typescript-eslint/no-unused-vars
✖ 9 problems (8 errors, 1 warning)
 ELIFECYCLE  Command failed with exit code 1."
`;
exports[`lint https://github.com/mmkal/trpc-cli 1`] = `
"
<dir>/trpc-cli/src/index.ts
<line>:<col> error The \`Function\` type accepts any function-like value.
Prefer explicitly defining any function parameters and return type @typescript-eslint/no-unsafe-function-type
<line>:<col> error Expected an error object to be thrown @typescript-eslint/only-throw-error
<dir>/trpc-cli/src/util.ts
<line>:<col> error The \`Function\` type accepts any function-like value.
Prefer explicitly defining any function parameters and return type @typescript-eslint/no-unsafe-function-type
✖ 3 problems (3 errors, 0 warnings)
"
`;
41 changes: 41 additions & 0 deletions test/mmkal-repos.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import * as fs from 'fs'
import * as path from 'path'
import {expect, test} from 'vitest'

const reposToTest = [
'https://github.com/mmkal/expect-type', //
'https://github.com/mmkal/trpc-cli',
]

const ts = Date.now().toString()

for (const repo of reposToTest) {
test(
`lint ${repo}`,
async () => {
const {execa} = await import('execa')
await execa('pnpm', ['build'])
const tmp = path.join(`/tmp/eslint-plugin-mmkal-testing`, ts)
fs.mkdirSync(tmp, {recursive: true})
await execa('git', ['clone', repo], {cwd: tmp})
const [cloneName, ...otherFiles] = fs.readdirSync(tmp).filter(f => f === repo.split('/').pop())
const clone = path.join(tmp, cloneName)
expect(otherFiles).toEqual([])
await execa('pnpm', ['install'], {cwd: clone})
await execa(path.join(process.cwd(), 'node_modules', '.bin', 'link'), [process.cwd()], {cwd: clone})
const {all: lint} = await execa('pnpm', ['eslint', '.', '--fix', '--max-warnings', '0'], {
all: true,
cwd: clone,
reject: false,
})

const snapshot = lint
.replaceAll(tmp, '<dir>')
.replaceAll('/private<dir>/', '<dir>/')
.replaceAll(ts, '<timestamp>')
.replaceAll(/\d+:\d+/g, '<line>:<col>')
expect(snapshot).toMatchSnapshot()
},
{timeout: 30_000},
)
}

0 comments on commit 46b83fe

Please sign in to comment.