-
-
Notifications
You must be signed in to change notification settings - Fork 19
/
Copy pathtypes.ts
93 lines (86 loc) · 2.53 KB
/
types.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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
import type { JSONSchema4 } from "json-schema";
import type { Rule } from "eslint";
import type {
BuiltInRuleListenerExits,
BuiltInRuleListeners,
RuleListener,
} from "jsonc-eslint-parser";
import type { AST as ESLintAST } from "eslint";
import type * as ESTree from "estree";
import type { AnyNode } from "@humanwhocodes/momoa";
export type Token = ESLintAST.Token;
export type Comment = ESTree.Comment;
export { RuleListener };
export type MomoaNode = AnyNode;
type MomoaRuleFunction<Node extends MomoaNode = never> = (node: Node) => void;
type MomoaBuiltInRuleListeners = {
[Node in MomoaNode as Node["type"]]?: MomoaRuleFunction<Node>;
};
type MomoaBuiltInRuleListenerExits = {
[Node in MomoaNode as `${Node["type"]}:exit`]?: MomoaRuleFunction<Node>;
};
export type MomoaRuleListener = MomoaBuiltInRuleListeners &
MomoaBuiltInRuleListenerExits;
export type BaseRuleListener = MomoaRuleListener &
BuiltInRuleListeners &
BuiltInRuleListenerExits;
export interface RuleModule<RuleOptions = unknown[]> {
meta: RuleMetaData;
jsoncDefineRule: PartialRuleModule<RuleOptions>;
create(context: Rule.RuleContext & { options: RuleOptions }): RuleListener;
}
export interface RuleMetaData {
docs: {
description: string;
recommended: ("json" | "jsonc" | "json5")[] | null;
url: string;
ruleId: string;
ruleName: string;
default?: "error" | "warn";
extensionRule:
| boolean
| string
| {
plugin: string;
url: string;
};
layout: boolean;
};
messages: { [messageId: string]: string };
fixable?: "code" | "whitespace";
hasSuggestions?: boolean;
schema: false | JSONSchema4 | JSONSchema4[];
deprecated?: boolean;
replacedBy?: [];
type: "problem" | "suggestion" | "layout";
}
export interface PartialRuleModule<RuleOptions = unknown[]> {
meta: PartialRuleMetaData;
create: (
context: Rule.RuleContext & { options: RuleOptions },
params: { customBlock: boolean },
) => BaseRuleListener;
}
export interface PartialRuleMetaData {
docs: {
description: string;
recommended: ("json" | "jsonc" | "json5")[] | null;
default?: "error" | "warn";
extensionRule:
| boolean
| string
| {
plugin: string;
url: string;
};
layout: boolean;
};
messages: { [messageId: string]: string };
fixable?: "code" | "whitespace";
hasSuggestions?: boolean;
defaultOptions?: any[];
schema: false | JSONSchema4 | JSONSchema4[];
deprecated?: boolean;
replacedBy?: [];
type: "problem" | "suggestion" | "layout";
}