Skip to content

Commit 1020373

Browse files
committed
ci(linter/plugins): lint apps/oxlint with oxlint (#15887)
2nd try at #14573. Run oxlint on oxlint. Linter inception.
1 parent 6ce2f7a commit 1020373

File tree

8 files changed

+22
-5
lines changed

8 files changed

+22
-5
lines changed

.github/workflows/ci.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -274,6 +274,11 @@ jobs:
274274
- run: cargo lint -- -D warnings
275275
- run: cargo lint --profile dev-no-debug-assertions -- -D warnings
276276
- run: RUSTDOCFLAGS='-D warnings' cargo doc --no-deps --document-private-items
277+
# Need to build Oxlint's JS bundle before linting `apps/oxlint`, because the tests reference
278+
# the `index.d.ts` file produced by TSDown. Type-aware rules rely on this `.d.ts` file being present.
279+
- name: Build Oxlint
280+
working-directory: apps/oxlint
281+
run: pnpm run build-js
277282
- run: node --run lint
278283

279284
conformance:

apps/oxlint/src-js/plugins/context.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -315,7 +315,7 @@ export interface Context extends FileContext {
315315
/**
316316
* Report an error/warning.
317317
*/
318-
report(diagnostic: Diagnostic): void;
318+
report(this: void, diagnostic: Diagnostic): void;
319319
}
320320

321321
/**
@@ -367,7 +367,7 @@ export function createContext(fullRuleName: string, ruleDetails: RuleDetails): R
367367
* @param diagnostic - Diagnostic object
368368
* @throws {TypeError} If `diagnostic` is invalid
369369
*/
370-
report(diagnostic: Diagnostic): void {
370+
report(this: void, diagnostic: Diagnostic): void {
371371
// Delegate to `report` implementation shared between all rules, passing rule-specific details (`RuleDetails`)
372372
report(diagnostic, ruleDetails);
373373
},

apps/oxlint/test/compile-visitor.test.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
// oxlint-disable jest/no-conditional-expect
2+
13
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
24
import { LEAF_NODE_TYPES_COUNT, NODE_TYPE_IDS_MAP } from '../src-js/generated/type_ids.js';
35
import {
@@ -49,8 +51,8 @@ describe('compile visitor', () => {
4951
});
5052

5153
it('accepts unknown visitor key', () => {
52-
addVisitorToCompiled({ Foo() {} });
53-
addVisitorToCompiled({ 'Foo:exit'() {} });
54+
expect(() => addVisitorToCompiled({ Foo() {} })).not.toThrow();
55+
expect(() => addVisitorToCompiled({ 'Foo:exit'() {} })).not.toThrow();
5456
});
5557

5658
describe('registers enter visitor', () => {

apps/oxlint/test/e2e.test.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
// oxlint-disable jest/expect-expect
2+
13
import fs from 'node:fs/promises';
24
import { join as pathJoin } from 'node:path';
35
import { describe, it } from 'vitest';

apps/oxlint/test/eslint-compat.test.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
// oxlint-disable jest/expect-expect
2+
13
import { join as pathJoin } from 'node:path';
24
import { describe, it } from 'vitest';
35
import { testFixtureWithCommand } from './utils.js';
@@ -19,6 +21,7 @@ async function testFixture(fixtureName: string): Promise<void> {
1921
}
2022

2123
// These tests take longer than 5 seconds on CI, so increase timeout to 10 seconds
24+
// oxlint-disable-next-line jest/valid-describe-callback
2225
describe('ESLint compatibility', { timeout: 10_000 }, () => {
2326
it('`definePlugin` should work', async () => {
2427
await testFixture('definePlugin');

apps/oxlint/test/fixtures/estree/plugin.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
// oxlint-disable typescript/restrict-template-expressions
2+
13
import assert from 'node:assert';
24

35
import type { Plugin } from '../../../dist/index.js';

apps/oxlint/test/fixtures/utf16_offsets/plugin.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
// oxlint-disable typescript/restrict-template-expressions
2+
13
import type { Plugin } from '../../../dist/index.js';
24

35
const plugin: Plugin = {

oxlintrc.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343
"tasks/coverage/**",
4444
"crates/oxc_semantic/tests/**",
4545
"napi/minify/**", // TODO
46-
"apps/oxlint" // TODO
46+
"!apps/oxlint/test/fixtures/**",
47+
"apps/oxlint/test/fixtures/*/files/**"
4748
]
4849
}

0 commit comments

Comments
 (0)