-
-
Notifications
You must be signed in to change notification settings - Fork 24
/
Copy pathindex.test-d.ts
50 lines (43 loc) · 1.54 KB
/
index.test-d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
import type {ESLint} from 'eslint';
import {expectType} from 'tsd';
import eslintFormatterPretty, {
type LintResult,
type LintMessage,
type Severity,
} from './index.js';
// Test LintResult interface members
declare const lintResult: LintResult;
expectType<string>(lintResult.filePath);
expectType<number>(lintResult.errorCount);
expectType<number>(lintResult.warningCount);
expectType<LintMessage[]>(lintResult.messages);
// Test LintMessage interface members
const lintMessage = lintResult.messages[0];
expectType<Severity>(lintMessage.severity);
expectType<string>(lintMessage.message);
expectType<true | undefined>(lintMessage.fatal);
expectType<number>(lintMessage.line);
expectType<number>(lintMessage.column);
expectType<string | null >(lintMessage.ruleId); // eslint-disable-line @typescript-eslint/ban-types
// Test formatterPretty()
declare const lintResults: LintResult[];
declare const eslintLintResults: ESLint.LintResult[];
declare const lintResultData: ESLint.LintResultData;
expectType<string>(eslintFormatterPretty(lintResults));
expectType<string>(eslintFormatterPretty(eslintLintResults));
expectType<string>(eslintFormatterPretty(eslintLintResults, lintResultData));
// FIXME
// type PartialLintResult = {
// filePath: string;
// errorCount: number;
// warningCount: number;
// messages: Array<{
// fileName: string;
// message: string;
// severity: 0 | 1 | 2;
// line?: number;
// column?: number;
// }>;
// };
// declare const partialLintResults: PartialLintResult[];
// expectType<string>(eslintFormatterPretty(partialLintResults));