Skip to content

Commit be2854b

Browse files
committed
feat(editor): add off to oxc.lint.run configuration
1 parent 1f4a71b commit be2854b

File tree

4 files changed

+38
-4
lines changed

4 files changed

+38
-4
lines changed

editors/vscode/client/WorkspaceConfig.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { ConfigService } from './ConfigService';
33

44
export const oxlintConfigFileName = '.oxlintrc.json';
55

6-
export type Trigger = 'onSave' | 'onType';
6+
export type Trigger = 'onSave' | 'onType' | 'off';
77

88
type UnusedDisableDirectives = 'allow' | 'warn' | 'deny';
99

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/* 😊 */debugger;

editors/vscode/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,8 @@
6969
"type": "string",
7070
"enum": [
7171
"onSave",
72-
"onType"
72+
"onType",
73+
"off"
7374
],
7475
"default": "onType",
7576
"description": "Run the linter on save (onSave) or on type (onType)"

editors/vscode/tests/e2e_server.spec.ts

Lines changed: 34 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ suiteSetup(async () => {
3232
});
3333

3434
teardown(async () => {
35+
await workspace.getConfiguration('oxc').update('lint.run', undefined);
3536
await workspace.getConfiguration('oxc').update('flags', undefined);
3637
await workspace.getConfiguration('oxc').update('tsConfigPath', undefined);
3738
await workspace.getConfiguration('oxc').update('typeAware', undefined);
@@ -74,7 +75,6 @@ suite('E2E Diagnostics', () => {
7475
testSingleFolderMode('detects diagnostics on run', async () =>
7576
{
7677
await loadFixture('lint_on_run');
77-
await sleep(250);
7878
const diagnostics = await getDiagnosticsWithoutClose(`onType.ts`);
7979
strictEqual(diagnostics.length, 0);
8080

@@ -92,7 +92,6 @@ suite('E2E Diagnostics', () => {
9292

9393
test('empty oxlint configuration behaves like default configuration', async () => {
9494
await loadFixture('debugger_empty_config');
95-
await sleep(250);
9695
const diagnostics = await getDiagnostics('debugger.js');
9796

9897
strictEqual(diagnostics.length, 1);
@@ -194,6 +193,39 @@ suite('E2E Diagnostics', () => {
194193
strictEqual(nestedDiagnostics[0].severity, DiagnosticSeverity.Error);
195194
});
196195

196+
197+
test('setting `oxc.lint.run` to `off` clears diagnostics', async () => {
198+
await workspace.getConfiguration('oxc').update('lint.run', undefined);
199+
await loadFixture('disabling_lint');
200+
await sleep(250);
201+
const firstDiagnostics = await getDiagnosticsWithoutClose('debugger.js');
202+
203+
strictEqual(firstDiagnostics.length, 1);
204+
205+
await workspace.getConfiguration('oxc').update('lint.run', 'off');
206+
await workspace.saveAll();
207+
await waitForDiagnosticChange();
208+
209+
const secondDiagnostics = await getDiagnostics('debugger.js');
210+
strictEqual(secondDiagnostics.length, 0);
211+
});
212+
213+
test('setting `oxc.lint.run` from `off` to `onType`, shows the diagnostics', async () => {
214+
await workspace.getConfiguration('oxc').update('lint.run', "off");
215+
await loadFixture('disabling_lint');
216+
await sleep(250);
217+
const firstDiagnostics = await getDiagnosticsWithoutClose('debugger.js');
218+
219+
strictEqual(firstDiagnostics.length, 0);
220+
221+
await workspace.getConfiguration('oxc').update('lint.run', 'onType');
222+
await workspace.saveAll();
223+
await waitForDiagnosticChange();
224+
225+
const secondDiagnostics = await getDiagnostics('debugger.js');
226+
strictEqual(secondDiagnostics.length, 1);
227+
});
228+
197229
// somehow this test is flaky in CI
198230
// testMultiFolderMode('different diagnostic severity', async () => {
199231
// await loadFixture('debugger', WORKSPACE_DIR);

0 commit comments

Comments
 (0)