]>
Commit | Line | Data |
---|---|---|
eb39fafa DC |
1 | /** |
2 | * @fileoverview Define common types for input completion. | |
3 | * @author Toru Nagashima <https://github.com/mysticatea> | |
4 | */ | |
5 | "use strict"; | |
6 | ||
7 | /** @type {any} */ | |
8 | module.exports = {}; | |
9 | ||
10 | /** @typedef {boolean | "off" | "readable" | "readonly" | "writable" | "writeable"} GlobalConf */ | |
11 | /** @typedef {0 | 1 | 2 | "off" | "warn" | "error"} SeverityConf */ | |
12 | /** @typedef {SeverityConf | [SeverityConf, ...any[]]} RuleConf */ | |
13 | ||
14 | /** | |
15 | * @typedef {Object} EcmaFeatures | |
16 | * @property {boolean} [globalReturn] Enabling `return` statements at the top-level. | |
17 | * @property {boolean} [jsx] Enabling JSX syntax. | |
18 | * @property {boolean} [impliedStrict] Enabling strict mode always. | |
19 | */ | |
20 | ||
21 | /** | |
22 | * @typedef {Object} ParserOptions | |
23 | * @property {EcmaFeatures} [ecmaFeatures] The optional features. | |
6f036462 | 24 | * @property {3|5|6|7|8|9|10|11|12|2015|2016|2017|2018|2019|2020|2021} [ecmaVersion] The ECMAScript version (or revision number). |
eb39fafa DC |
25 | * @property {"script"|"module"} [sourceType] The source code type. |
26 | */ | |
27 | ||
28 | /** | |
29 | * @typedef {Object} ConfigData | |
30 | * @property {Record<string, boolean>} [env] The environment settings. | |
31 | * @property {string | string[]} [extends] The path to other config files or the package name of shareable configs. | |
32 | * @property {Record<string, GlobalConf>} [globals] The global variable settings. | |
33 | * @property {string | string[]} [ignorePatterns] The glob patterns that ignore to lint. | |
34 | * @property {boolean} [noInlineConfig] The flag that disables directive comments. | |
35 | * @property {OverrideConfigData[]} [overrides] The override settings per kind of files. | |
36 | * @property {string} [parser] The path to a parser or the package name of a parser. | |
37 | * @property {ParserOptions} [parserOptions] The parser options. | |
38 | * @property {string[]} [plugins] The plugin specifiers. | |
39 | * @property {string} [processor] The processor specifier. | |
40 | * @property {boolean} [reportUnusedDisableDirectives] The flag to report unused `eslint-disable` comments. | |
41 | * @property {boolean} [root] The root flag. | |
42 | * @property {Record<string, RuleConf>} [rules] The rule settings. | |
43 | * @property {Object} [settings] The shared settings. | |
44 | */ | |
45 | ||
46 | /** | |
47 | * @typedef {Object} OverrideConfigData | |
48 | * @property {Record<string, boolean>} [env] The environment settings. | |
49 | * @property {string | string[]} [excludedFiles] The glob pattarns for excluded files. | |
50 | * @property {string | string[]} [extends] The path to other config files or the package name of shareable configs. | |
51 | * @property {string | string[]} files The glob pattarns for target files. | |
52 | * @property {Record<string, GlobalConf>} [globals] The global variable settings. | |
53 | * @property {boolean} [noInlineConfig] The flag that disables directive comments. | |
54 | * @property {OverrideConfigData[]} [overrides] The override settings per kind of files. | |
55 | * @property {string} [parser] The path to a parser or the package name of a parser. | |
56 | * @property {ParserOptions} [parserOptions] The parser options. | |
57 | * @property {string[]} [plugins] The plugin specifiers. | |
58 | * @property {string} [processor] The processor specifier. | |
59 | * @property {boolean} [reportUnusedDisableDirectives] The flag to report unused `eslint-disable` comments. | |
60 | * @property {Record<string, RuleConf>} [rules] The rule settings. | |
61 | * @property {Object} [settings] The shared settings. | |
62 | */ | |
63 | ||
64 | /** | |
65 | * @typedef {Object} ParseResult | |
66 | * @property {Object} ast The AST. | |
67 | * @property {ScopeManager} [scopeManager] The scope manager of the AST. | |
68 | * @property {Record<string, any>} [services] The services that the parser provides. | |
69 | * @property {Record<string, string[]>} [visitorKeys] The visitor keys of the AST. | |
70 | */ | |
71 | ||
72 | /** | |
73 | * @typedef {Object} Parser | |
74 | * @property {(text:string, options:ParserOptions) => Object} parse The definition of global variables. | |
75 | * @property {(text:string, options:ParserOptions) => ParseResult} [parseForESLint] The parser options that will be enabled under this environment. | |
76 | */ | |
77 | ||
78 | /** | |
79 | * @typedef {Object} Environment | |
80 | * @property {Record<string, GlobalConf>} [globals] The definition of global variables. | |
81 | * @property {ParserOptions} [parserOptions] The parser options that will be enabled under this environment. | |
82 | */ | |
83 | ||
84 | /** | |
85 | * @typedef {Object} LintMessage | |
86 | * @property {number} column The 1-based column number. | |
87 | * @property {number} [endColumn] The 1-based column number of the end location. | |
88 | * @property {number} [endLine] The 1-based line number of the end location. | |
89 | * @property {boolean} fatal If `true` then this is a fatal error. | |
90 | * @property {{range:[number,number], text:string}} [fix] Information for autofix. | |
91 | * @property {number} line The 1-based line number. | |
92 | * @property {string} message The error message. | |
93 | * @property {string|null} ruleId The ID of the rule which makes this message. | |
94 | * @property {0|1|2} severity The severity of this message. | |
95 | * @property {Array<{desc?: string, messageId?: string, fix: {range: [number, number], text: string}}>} [suggestions] Information for suggestions. | |
96 | */ | |
97 | ||
98 | /** | |
99 | * @typedef {Object} SuggestionResult | |
100 | * @property {string} desc A short description. | |
101 | * @property {string} [messageId] Id referencing a message for the description. | |
102 | * @property {{ text: string, range: number[] }} fix fix result info | |
103 | */ | |
104 | ||
105 | /** | |
106 | * @typedef {Object} Processor | |
107 | * @property {(text:string, filename:string) => Array<string | { text:string, filename:string }>} [preprocess] The function to extract code blocks. | |
108 | * @property {(messagesList:LintMessage[][], filename:string) => LintMessage[]} [postprocess] The function to merge messages. | |
109 | * @property {boolean} [supportsAutofix] If `true` then it means the processor supports autofix. | |
110 | */ | |
111 | ||
112 | /** | |
113 | * @typedef {Object} RuleMetaDocs | |
114 | * @property {string} category The category of the rule. | |
115 | * @property {string} description The description of the rule. | |
116 | * @property {boolean} recommended If `true` then the rule is included in `eslint:recommended` preset. | |
117 | * @property {string} url The URL of the rule documentation. | |
118 | */ | |
119 | ||
120 | /** | |
121 | * @typedef {Object} RuleMeta | |
122 | * @property {boolean} [deprecated] If `true` then the rule has been deprecated. | |
123 | * @property {RuleMetaDocs} docs The document information of the rule. | |
124 | * @property {"code"|"whitespace"} [fixable] The autofix type. | |
125 | * @property {Record<string,string>} [messages] The messages the rule reports. | |
126 | * @property {string[]} [replacedBy] The IDs of the alternative rules. | |
127 | * @property {Array|Object} schema The option schema of the rule. | |
128 | * @property {"problem"|"suggestion"|"layout"} type The rule type. | |
129 | */ | |
130 | ||
131 | /** | |
132 | * @typedef {Object} Rule | |
133 | * @property {Function} create The factory of the rule. | |
134 | * @property {RuleMeta} meta The meta data of the rule. | |
135 | */ | |
136 | ||
137 | /** | |
138 | * @typedef {Object} Plugin | |
139 | * @property {Record<string, ConfigData>} [configs] The definition of plugin configs. | |
140 | * @property {Record<string, Environment>} [environments] The definition of plugin environments. | |
141 | * @property {Record<string, Processor>} [processors] The definition of plugin processors. | |
142 | * @property {Record<string, Function | Rule>} [rules] The definition of plugin rules. | |
143 | */ | |
56c4a2cb DC |
144 | |
145 | /** | |
146 | * Information of deprecated rules. | |
147 | * @typedef {Object} DeprecatedRuleInfo | |
148 | * @property {string} ruleId The rule ID. | |
149 | * @property {string[]} replacedBy The rule IDs that replace this deprecated rule. | |
150 | */ |