Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test other repos #40

Merged
merged 3 commits into from
Jan 26, 2025
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
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": "20.16.5",
"eslint": "^8.57.0",
"execa": "^9.0.0",
"link": "^2.1.1",
"np": "^10.0.7",
"pkg-pr-new": "^0.0.25",
"tsx": "^4.7.1",
Expand Down
9 changes: 9 additions & 0 deletions 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},
)
}
Loading