generated from JoshuaKGoldberg/create-typescript-app
-
Notifications
You must be signed in to change notification settings - Fork 21
feat: use LinterHost for linting #1605
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
Merged
Merged
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
457dbd5
feat: use LinterHost for linting
auvred be2e67f
changeset
auvred 8c23780
pnpm dedupe
auvred ea95237
oooops
auvred c387f80
move disk backed linter host to rule tester ctor
auvred 5130279
lint fix
auvred 29d80c3
Merge branch 'main' into use-vfs-for-linting
auvred 8b4a854
Merge branch 'main' into use-vfs-for-linting
auvred 41194ca
update changeset
auvred 4fd5867
sync
auvred 5f201f3
sync2
auvred b9ce605
Merge branch 'main' into use-vfs-for-linting
auvred f331ff9
add fs root to plugin-flint tests
auvred e28e4ae
few touchups
auvred File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| --- | ||
| "@flint.fyi/rule-tester": minor | ||
| "@flint.fyi/core": minor | ||
| "@flint.fyi/cli": minor | ||
| "@flint.fyi/typescript-language": minor | ||
| --- | ||
|
|
||
| feat: use LinterHost for linting |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,8 +1,15 @@ | ||
| import { RuleTester } from "@flint.fyi/rule-tester"; | ||
| import { createRuleTesterTSConfig } from "@flint.fyi/typescript-language"; | ||
| import { describe, it } from "vitest"; | ||
|
|
||
| export const ruleTester = new RuleTester({ | ||
| defaults: { fileName: "file.ts" }, | ||
| defaults: { | ||
| fileName: "file.ts", | ||
| files: createRuleTesterTSConfig({ | ||
| lib: ["esnext", "DOM"], | ||
| }), | ||
| }, | ||
| describe, | ||
| diskBackedFSRoot: import.meta.dirname, | ||
| it, | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| import type { LinterHost } from "../types/host.ts"; | ||
|
|
||
| /** | ||
| * Creates a one-shot `LinterHost` that disables file/directory watching. | ||
| * | ||
| * Useful for single-run linting (e.g. CLI execution, rule tester), | ||
| * where persistent watchers are unnecessary and can affect performance. | ||
| */ | ||
| export function createEphemeralLinterHost(baseHost: LinterHost): LinterHost { | ||
auvred marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| return { | ||
| ...baseHost, | ||
| watchDirectory() { | ||
| return { | ||
| [Symbol.dispose]() { | ||
| // Intentionally empty to satisfy the Disposable interface. | ||
| }, | ||
| }; | ||
| }, | ||
| watchFile() { | ||
| return { | ||
| [Symbol.dispose]() { | ||
| // Intentionally empty to satisfy the Disposable interface. | ||
| }, | ||
| }; | ||
| }, | ||
| }; | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,8 +1,8 @@ | ||
| export function makeDisposable<T extends object>(obj: T): Disposable & T { | ||
| return { | ||
| ...obj, | ||
| [Symbol.dispose]: () => () => { | ||
| // Intentionally empty to satisfy the Disposable interface. | ||
| }, | ||
| ...obj, | ||
| }; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,8 +1,9 @@ | ||
| import { RuleTester } from "@flint.fyi/rule-tester"; | ||
| import { createRuleTesterTSConfig } from "@flint.fyi/typescript-language"; | ||
| import { describe, it } from "vitest"; | ||
|
|
||
| export const ruleTester = new RuleTester({ | ||
| defaults: { fileName: "file.tsx" }, | ||
| defaults: { fileName: "file.tsx", files: createRuleTesterTSConfig() }, | ||
| describe, | ||
| it, | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3,7 +3,7 @@ | |
| "tsBuildInfoFile": "node_modules/.cache/tsbuild/info.test.json", | ||
| "rootDir": "src/", | ||
| "outDir": "node_modules/.cache/tsbuild/test", | ||
| "types": [] | ||
| "types": ["node"] | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We need this so that |
||
| }, | ||
| "extends": "../../tsconfig.base.json", | ||
| "include": ["src/**/*.test.ts", "src/rules/ruleTester.ts"], | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,8 +1,17 @@ | ||
| import { RuleTester } from "@flint.fyi/rule-tester"; | ||
| import { createRuleTesterTSConfig } from "@flint.fyi/typescript-language"; | ||
| import { describe, it } from "vitest"; | ||
|
|
||
| export const ruleTester = new RuleTester({ | ||
| defaults: { fileName: "file.ts" }, | ||
| defaults: { | ||
| fileName: "file.ts", | ||
| files: createRuleTesterTSConfig({ | ||
| types: ["node"], | ||
| // TODO: remove this; there is a bug in blobReadingMethods - it doesn't respect type from @types/node | ||
| lib: ["dom"], | ||
| }), | ||
| }, | ||
| describe, | ||
| diskBackedFSRoot: import.meta.dirname, | ||
| it, | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,8 +1,12 @@ | ||
| import { RuleTester } from "@flint.fyi/rule-tester"; | ||
| import { createRuleTesterTSConfig } from "@flint.fyi/typescript-language"; | ||
| import { describe, it } from "vitest"; | ||
|
|
||
| export const ruleTester = new RuleTester({ | ||
| defaults: { fileName: "file.ts" }, | ||
| defaults: { | ||
| fileName: "file.ts", | ||
| files: createRuleTesterTSConfig(), | ||
| }, | ||
| describe, | ||
| it, | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,8 +1,13 @@ | ||
| import { RuleTester } from "@flint.fyi/rule-tester"; | ||
| import { createRuleTesterTSConfig } from "@flint.fyi/typescript-language"; | ||
| import { describe, it } from "vitest"; | ||
|
|
||
| export const ruleTester = new RuleTester({ | ||
| defaults: { fileName: "file.test.ts" }, | ||
| defaults: { | ||
| fileName: "file.test.ts", | ||
| files: createRuleTesterTSConfig(), | ||
| }, | ||
| describe, | ||
| diskBackedFSRoot: import.meta.dirname, | ||
| it, | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[Non-Actionable] Hmm,
runCliOnceis called byrunCliWatch.runCliWatchmight want to set up a longer-lived linter host... but I don't think we should block this PR on that. That's a nice-to-have optimization for now IMO.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep, we could also reuse disk-backed LinterHost's
watchDirectorythere. I'll file a followup.