Skip to content

Commit 7f45762

Browse files
committed
chore(lint): enable type-aware linting
1 parent b6e8661 commit 7f45762

11 files changed

Lines changed: 20 additions & 21 deletions

File tree

‎packages/rstack/src/fmt/lsp/server.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ const redirectConsoleToConnection = (connection: Connection): void => {
8787
counters.set(key, count);
8888
connection.console.log(`${key}: ${count}`);
8989
};
90-
console.countReset = (label?: unknown): void => {
90+
console.countReset = (label?: string): void => {
9191
if (label === undefined) {
9292
counters.clear();
9393
} else {

‎packages/rstack/src/fmt/yukuPlugin.ts‎

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -423,11 +423,7 @@ const indexToPosition = (text: string, index: number): { column: number; line: n
423423
};
424424
};
425425

426-
const createParseError = (error: Diagnostic, text: string): Diagnostic | SyntaxError => {
427-
if (typeof error?.start !== 'number' || typeof error?.end !== 'number') {
428-
return error;
429-
}
430-
426+
const createParseError = (error: Diagnostic, text: string): SyntaxError => {
431427
const start = indexToPosition(text, error.start);
432428
const end = indexToPosition(text, error.end);
433429

‎packages/rstack/src/staged.ts‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,10 @@ export async function runStagedCLI(args: string[]): Promise<void> {
5757

5858
const success = await lintStaged({
5959
allowEmpty: values.allowEmpty,
60-
concurrent: values.concurrent === undefined ? undefined : JSON.parse(values.concurrent),
60+
concurrent:
61+
values.concurrent === undefined
62+
? undefined
63+
: (JSON.parse(values.concurrent) as boolean | number),
6164
config: stagedConfig,
6265
cwd: values.cwd,
6366
debug: values.debug,

‎packages/rstack/tests/cli/staged/index.test.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,9 @@ test('should pass default options to lint-staged', async ({ expect }) => {
5858
});
5959

6060
test('should set the staged environment', async ({ expect }) => {
61-
mocks.lintStaged.mockImplementation(async () => {
61+
mocks.lintStaged.mockImplementation(() => {
6262
expect(process.env.RSTACK_STAGED).toBe('1');
63-
return true;
63+
return Promise.resolve(true);
6464
});
6565

6666
await runStagedCLI([]);

‎packages/rstack/tests/fmt/helpers.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ export const createFmtCacheContext = (rootPath: string): FmtCacheContext => ({
1717
});
1818

1919
export const withTempProject = async (
20-
callback: (rootPath: string) => Promise<void>,
20+
callback: (rootPath: string) => void | Promise<void>,
2121
): Promise<void> => {
2222
const rootPath = mkdtempSync(path.join(import.meta.dirname, 'test-temp-fmt-'));
2323
// Prevent repository-level ignore rules from affecting the fixture.

‎packages/rstack/tests/fmt/lsp/server.test.ts‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { createDocumentEdits } from '../../../src/fmt/lsp/server.ts';
44
test('maps the edit onto the formatted document', async () => {
55
const edits = await createDocumentEdits(
66
() => 'const a = 1;\nconst b=2;\n',
7-
async () => 'const a = 1;\nconst b = 2;\n',
7+
() => Promise.resolve('const a = 1;\nconst b = 2;\n'),
88
);
99

1010
expect(edits).toEqual([
@@ -18,15 +18,15 @@ test('maps the edit onto the formatted document', async () => {
1818
test('returns no edits for an already formatted document', async () => {
1919
const getText = () => 'const a = 1;\n';
2020

21-
expect(await createDocumentEdits(getText, async () => 'const a = 1;\n')).toEqual([]);
22-
expect(await createDocumentEdits(getText, async () => undefined)).toEqual([]);
21+
expect(await createDocumentEdits(getText, () => Promise.resolve('const a = 1;\n'))).toEqual([]);
22+
expect(await createDocumentEdits(getText, () => Promise.resolve(undefined))).toEqual([]);
2323
});
2424

2525
test('returns no edits for a document that is not open', async () => {
2626
expect(
2727
await createDocumentEdits(
2828
() => undefined,
29-
async () => '',
29+
() => Promise.resolve(''),
3030
),
3131
).toEqual([]);
3232
});
@@ -38,10 +38,10 @@ test('returns no edits when the document changes while it is formatted', async (
3838

3939
const edits = await createDocumentEdits(
4040
() => text,
41-
async (source) => {
41+
(source) => {
4242
text = 'const b=2;\n';
4343

44-
return source.replace('const b=2;', 'const b = 2;');
44+
return Promise.resolve(source.replace('const b=2;', 'const b = 2;'));
4545
},
4646
);
4747

‎packages/rstack/tests/fmt/plugins.test.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { createFingerprintResolver, createPluginResolver } from '../../src/fmt/p
44
import { withTempProject, writeProjectFile } from './helpers.ts';
55

66
test('resolves plugin specifiers from the config root', async () => {
7-
await withTempProject(async (rootPath) => {
7+
await withTempProject((rootPath) => {
88
const packageEntry = writeProjectFile(
99
rootPath,
1010
'node_modules/prettier-plugin-packagejson/import.mjs',

‎packages/rstack/tests/setup/install.test.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ test('resolves repository context with a single Git process when unchanged', ()
7979
const starts = readFileSync(tracePath, 'utf8')
8080
.trim()
8181
.split('\n')
82-
.map((line) => JSON.parse(line))
82+
.map((line) => JSON.parse(line) as { argv: string[]; event: string })
8383
.filter((event) => event.event === 'start');
8484
expect(starts).toHaveLength(1);
8585
expect(starts[0].argv).toContain('rev-parse');

‎packages/rstack/tests/types/resolution-bundler/index.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ const configs: Configs = {};
2323
void loadedConfig;
2424
void configs;
2525

26-
createRsbuild({ config: appConfig });
26+
void createRsbuild({ config: appConfig });
2727
define.app(appConfig);
2828
define.lib(libConfig);
2929
define.doc({});

‎packages/rstack/tests/types/resolution-nodenext/index.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ const configs: Configs = {};
2323
void loadedConfig;
2424
void configs;
2525

26-
createRsbuild({ config: appConfig });
26+
void createRsbuild({ config: appConfig });
2727
define.app(appConfig);
2828
define.lib(libConfig);
2929
define.doc({});

0 commit comments

Comments
 (0)