Repository navigation
fix(vscode): detect rslint configs above the workspace folder #89
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
9 commits
Select commit
Hold shift + click to select a range
590b45e
fix(vscode): detect rslint configs above the workspace folder
fi3ework 707a78f
refactor(vscode): simplify ancestor rslint config detection
fi3ework 588db7c
test(vscode): cover a nearer ancestor rslint config created while lin…
fi3ework b4eee01
fix(vscode): treat ancestor lockfile changes as dependency changes
fi3ework 454d3d3
test(vscode): temporary macOS CI diagnostics for the ancestor suite
fi3ework a5e1c04
test(vscode): dump ancestor suite traces without the probe delay
fi3ework 91ebde0
fix(vscode): refresh rslint config on ancestor edits before the serve…
fi3ework afacb3c
test(vscode): remove temporary macOS CI diagnostics
fi3ework 72aeb03
fix(vscode): watch ancestor rslint configs for every native runtime
fi3ework 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
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
3 changes: 3 additions & 0 deletions
3
packages/vscode/e2e/lint/fixtures/ancestor/packages/app/src/index.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 |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| export function pause(): void { | ||
| debugger; | ||
| } |
8 changes: 8 additions & 0 deletions
8
packages/vscode/e2e/lint/fixtures/ancestor/packages/app/tsconfig.json
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 @@ | ||
| { | ||
| "compilerOptions": { | ||
| "target": "ES2020", | ||
| "module": "ESNext", | ||
| "strict": true | ||
| }, | ||
| "include": ["src/**/*.ts"] | ||
| } |
10 changes: 10 additions & 0 deletions
10
packages/vscode/e2e/lint/fixtures/ancestor/rslint.config.mjs
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,10 @@ | ||
| // The only Rslint config in this fixture. The opened workspace folder is | ||
| // `packages/app`, so detection must find this file above the folder. | ||
| export default [ | ||
| { | ||
| files: ['**/*.ts'], | ||
| rules: { | ||
| 'no-debugger': 'error', | ||
| }, | ||
| }, | ||
| ]; |
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,95 @@ | ||
| // The opened workspace folder is `packages/app`; the fixture's only | ||
| // `rslint.config.*` sits two levels above it. The rslint CLI and its Go server | ||
| // walk up to the filesystem root for a config, so native lint detection must | ||
| // light this folder, and its ancestor watchers must keep that decision fresh. | ||
| import * as vscode from 'vscode'; | ||
| import path from 'node:path'; | ||
| import fs from 'node:fs'; | ||
| import { | ||
| diagnosticRuleIdIncludes, | ||
| waitForRslintDiagnostics as waitForDiagnostics, | ||
| } from '../utils/diagnostics'; | ||
| import { waitForLintStackRegistration } from '../utils/extension'; | ||
|
|
||
| function configWithNoDebugger(severity: 'error' | 'off'): string { | ||
| return `export default [ | ||
| { | ||
| files: ['**/*.ts'], | ||
| rules: { | ||
| 'no-debugger': '${severity}', | ||
| }, | ||
| }, | ||
| ]; | ||
| `; | ||
| } | ||
|
|
||
| suite('rslint config above the workspace folder', function () { | ||
| this.timeout(120000); | ||
|
|
||
| const folderPath = (): string => | ||
| vscode.workspace.workspaceFolders![0].uri.fsPath; | ||
| const rootConfigPath = (): string => | ||
| path.join(folderPath(), '..', '..', 'rslint.config.mjs'); | ||
| const nearerConfigPath = (): string => | ||
| path.join(folderPath(), '..', 'rslint.config.mjs'); | ||
|
|
||
| async function openIndex(): Promise<vscode.TextDocument> { | ||
| const document = await vscode.workspace.openTextDocument( | ||
| path.join(folderPath(), 'src', 'index.ts'), | ||
| ); | ||
| await vscode.window.showTextDocument(document); | ||
| return document; | ||
| } | ||
|
|
||
| const hasNoDebugger = (diagnostics: vscode.Diagnostic[]): boolean => | ||
| diagnostics.some((diagnostic) => | ||
| diagnosticRuleIdIncludes(diagnostic, 'no-debugger'), | ||
| ); | ||
|
|
||
| teardown(async () => { | ||
| fs.rmSync(nearerConfigPath(), { force: true }); | ||
| fs.writeFileSync(rootConfigPath(), configWithNoDebugger('error')); | ||
| await waitForLintStackRegistration(true); | ||
| }); | ||
|
|
||
| test('lints with the config above the folder and follows its edits', async () => { | ||
| const document = await openIndex(); | ||
| await waitForDiagnostics(document, hasNoDebugger); | ||
|
|
||
| fs.writeFileSync(rootConfigPath(), configWithNoDebugger('off')); | ||
| await waitForDiagnostics( | ||
| document, | ||
| (diagnostics) => !hasNoDebugger(diagnostics), | ||
| ); | ||
|
|
||
| fs.writeFileSync(rootConfigPath(), configWithNoDebugger('error')); | ||
| await waitForDiagnostics(document, hasNoDebugger); | ||
| }); | ||
|
|
||
| // The live runtime keeps its key; the extension's ancestor watchers send | ||
| // configRefresh, as do the Go server's own (`ancestorJSConfigFileWatchers`, | ||
| // registered through the worker) once they are live. | ||
| test('applies a nearer config created above the folder while linting', async () => { | ||
| const document = await openIndex(); | ||
| await waitForDiagnostics(document, hasNoDebugger); | ||
|
|
||
| fs.writeFileSync(nearerConfigPath(), configWithNoDebugger('off')); | ||
| await waitForDiagnostics( | ||
| document, | ||
| (diagnostics) => !hasNoDebugger(diagnostics), | ||
| ); | ||
|
|
||
| fs.rmSync(nearerConfigPath()); | ||
| await waitForDiagnostics(document, hasNoDebugger); | ||
| }); | ||
|
|
||
| test('re-runs detection when the config above the folder is deleted or created', async () => { | ||
| fs.rmSync(rootConfigPath()); | ||
| await waitForLintStackRegistration(false); | ||
|
|
||
| fs.writeFileSync(rootConfigPath(), configWithNoDebugger('error')); | ||
| await waitForLintStackRegistration(true); | ||
| const document = await openIndex(); | ||
| await waitForDiagnostics(document, hasNoDebugger); | ||
| }); | ||
| }); |
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,5 @@ | ||
| import { createRun } from '../runSuite'; | ||
|
|
||
| // The opened folder has no config of its own; the one above it must light the | ||
| // lint stack. | ||
| export const run = createRun(); |
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
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.