eslint 9.26.0 → 9.27.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +7 -2
- package/bin/eslint.js +7 -11
- package/conf/rule-type-list.json +2 -1
- package/lib/cli-engine/cli-engine.js +7 -7
- package/lib/cli.js +5 -4
- package/lib/config/config-loader.js +10 -18
- package/lib/config/config.js +328 -5
- package/lib/eslint/eslint-helpers.js +3 -1
- package/lib/eslint/eslint.js +26 -9
- package/lib/eslint/legacy-eslint.js +6 -6
- package/lib/languages/js/source-code/source-code.js +10 -6
- package/lib/linter/apply-disable-directives.js +1 -1
- package/lib/linter/file-context.js +11 -0
- package/lib/linter/linter.js +75 -82
- package/lib/linter/report-translator.js +2 -1
- package/lib/rule-tester/rule-tester.js +3 -3
- package/lib/rules/index.js +1 -0
- package/lib/rules/max-params.js +32 -7
- package/lib/rules/no-array-constructor.js +51 -1
- package/lib/rules/no-unassigned-vars.js +72 -0
- package/lib/rules/no-useless-escape.js +24 -2
- package/lib/rules/prefer-named-capture-group.js +7 -1
- package/lib/services/processor-service.js +1 -1
- package/lib/services/suppressions-service.js +5 -3
- package/lib/shared/flags.js +1 -0
- package/lib/types/index.d.ts +122 -4
- package/lib/types/rules.d.ts +19 -1
- package/package.json +6 -8
- package/lib/config/flat-config-helpers.js +0 -128
- package/lib/config/rule-validator.js +0 -199
- package/lib/mcp/mcp-server.js +0 -66
- package/lib/shared/types.js +0 -229
@@ -1,128 +0,0 @@
|
|
1
|
-
/**
|
2
|
-
* @fileoverview Shared functions to work with configs.
|
3
|
-
* @author Nicholas C. Zakas
|
4
|
-
*/
|
5
|
-
|
6
|
-
"use strict";
|
7
|
-
|
8
|
-
//------------------------------------------------------------------------------
|
9
|
-
// Typedefs
|
10
|
-
//------------------------------------------------------------------------------
|
11
|
-
|
12
|
-
/**
|
13
|
-
* @import { RuleDefinition } from "@eslint/core";
|
14
|
-
* @import { Linter } from "eslint";
|
15
|
-
*/
|
16
|
-
|
17
|
-
//------------------------------------------------------------------------------
|
18
|
-
// Private Members
|
19
|
-
//------------------------------------------------------------------------------
|
20
|
-
|
21
|
-
// JSON schema that disallows passing any options
|
22
|
-
const noOptionsSchema = Object.freeze({
|
23
|
-
type: "array",
|
24
|
-
minItems: 0,
|
25
|
-
maxItems: 0,
|
26
|
-
});
|
27
|
-
|
28
|
-
//-----------------------------------------------------------------------------
|
29
|
-
// Functions
|
30
|
-
//-----------------------------------------------------------------------------
|
31
|
-
|
32
|
-
/**
|
33
|
-
* Parses a ruleId into its plugin and rule parts.
|
34
|
-
* @param {string} ruleId The rule ID to parse.
|
35
|
-
* @returns {{pluginName:string,ruleName:string}} The plugin and rule
|
36
|
-
* parts of the ruleId;
|
37
|
-
*/
|
38
|
-
function parseRuleId(ruleId) {
|
39
|
-
let pluginName, ruleName;
|
40
|
-
|
41
|
-
// distinguish between core rules and plugin rules
|
42
|
-
if (ruleId.includes("/")) {
|
43
|
-
// mimic scoped npm packages
|
44
|
-
if (ruleId.startsWith("@")) {
|
45
|
-
pluginName = ruleId.slice(0, ruleId.lastIndexOf("/"));
|
46
|
-
} else {
|
47
|
-
pluginName = ruleId.slice(0, ruleId.indexOf("/"));
|
48
|
-
}
|
49
|
-
|
50
|
-
ruleName = ruleId.slice(pluginName.length + 1);
|
51
|
-
} else {
|
52
|
-
pluginName = "@";
|
53
|
-
ruleName = ruleId;
|
54
|
-
}
|
55
|
-
|
56
|
-
return {
|
57
|
-
pluginName,
|
58
|
-
ruleName,
|
59
|
-
};
|
60
|
-
}
|
61
|
-
|
62
|
-
/**
|
63
|
-
* Retrieves a rule instance from a given config based on the ruleId.
|
64
|
-
* @param {string} ruleId The rule ID to look for.
|
65
|
-
* @param {Linter.Config} config The config to search.
|
66
|
-
* @returns {RuleDefinition|undefined} The rule if found
|
67
|
-
* or undefined if not.
|
68
|
-
*/
|
69
|
-
function getRuleFromConfig(ruleId, config) {
|
70
|
-
const { pluginName, ruleName } = parseRuleId(ruleId);
|
71
|
-
|
72
|
-
return config.plugins?.[pluginName]?.rules?.[ruleName];
|
73
|
-
}
|
74
|
-
|
75
|
-
/**
|
76
|
-
* Gets a complete options schema for a rule.
|
77
|
-
* @param {RuleDefinition} rule A rule object
|
78
|
-
* @throws {TypeError} If `meta.schema` is specified but is not an array, object or `false`.
|
79
|
-
* @returns {Object|null} JSON Schema for the rule's options. `null` if `meta.schema` is `false`.
|
80
|
-
*/
|
81
|
-
function getRuleOptionsSchema(rule) {
|
82
|
-
if (!rule.meta) {
|
83
|
-
return { ...noOptionsSchema }; // default if `meta.schema` is not specified
|
84
|
-
}
|
85
|
-
|
86
|
-
const schema = rule.meta.schema;
|
87
|
-
|
88
|
-
if (typeof schema === "undefined") {
|
89
|
-
return { ...noOptionsSchema }; // default if `meta.schema` is not specified
|
90
|
-
}
|
91
|
-
|
92
|
-
// `schema:false` is an allowed explicit opt-out of options validation for the rule
|
93
|
-
if (schema === false) {
|
94
|
-
return null;
|
95
|
-
}
|
96
|
-
|
97
|
-
if (typeof schema !== "object" || schema === null) {
|
98
|
-
throw new TypeError("Rule's `meta.schema` must be an array or object");
|
99
|
-
}
|
100
|
-
|
101
|
-
// ESLint-specific array form needs to be converted into a valid JSON Schema definition
|
102
|
-
if (Array.isArray(schema)) {
|
103
|
-
if (schema.length) {
|
104
|
-
return {
|
105
|
-
type: "array",
|
106
|
-
items: schema,
|
107
|
-
minItems: 0,
|
108
|
-
maxItems: schema.length,
|
109
|
-
};
|
110
|
-
}
|
111
|
-
|
112
|
-
// `schema:[]` is an explicit way to specify that the rule does not accept any options
|
113
|
-
return { ...noOptionsSchema };
|
114
|
-
}
|
115
|
-
|
116
|
-
// `schema:<object>` is assumed to be a valid JSON Schema definition
|
117
|
-
return schema;
|
118
|
-
}
|
119
|
-
|
120
|
-
//-----------------------------------------------------------------------------
|
121
|
-
// Exports
|
122
|
-
//-----------------------------------------------------------------------------
|
123
|
-
|
124
|
-
module.exports = {
|
125
|
-
parseRuleId,
|
126
|
-
getRuleFromConfig,
|
127
|
-
getRuleOptionsSchema,
|
128
|
-
};
|
@@ -1,199 +0,0 @@
|
|
1
|
-
/**
|
2
|
-
* @fileoverview Rule Validator
|
3
|
-
* @author Nicholas C. Zakas
|
4
|
-
*/
|
5
|
-
|
6
|
-
"use strict";
|
7
|
-
|
8
|
-
//-----------------------------------------------------------------------------
|
9
|
-
// Requirements
|
10
|
-
//-----------------------------------------------------------------------------
|
11
|
-
|
12
|
-
const ajvImport = require("../shared/ajv");
|
13
|
-
const ajv = ajvImport();
|
14
|
-
const {
|
15
|
-
parseRuleId,
|
16
|
-
getRuleFromConfig,
|
17
|
-
getRuleOptionsSchema,
|
18
|
-
} = require("./flat-config-helpers");
|
19
|
-
const ruleReplacements = require("../../conf/replacements.json");
|
20
|
-
|
21
|
-
//-----------------------------------------------------------------------------
|
22
|
-
// Helpers
|
23
|
-
//-----------------------------------------------------------------------------
|
24
|
-
|
25
|
-
/**
|
26
|
-
* Throws a helpful error when a rule cannot be found.
|
27
|
-
* @param {Object} ruleId The rule identifier.
|
28
|
-
* @param {string} ruleId.pluginName The ID of the rule to find.
|
29
|
-
* @param {string} ruleId.ruleName The ID of the rule to find.
|
30
|
-
* @param {Object} config The config to search in.
|
31
|
-
* @throws {TypeError} For missing plugin or rule.
|
32
|
-
* @returns {void}
|
33
|
-
*/
|
34
|
-
function throwRuleNotFoundError({ pluginName, ruleName }, config) {
|
35
|
-
const ruleId = pluginName === "@" ? ruleName : `${pluginName}/${ruleName}`;
|
36
|
-
|
37
|
-
const errorMessageHeader = `Key "rules": Key "${ruleId}"`;
|
38
|
-
|
39
|
-
let errorMessage = `${errorMessageHeader}: Could not find plugin "${pluginName}" in configuration.`;
|
40
|
-
|
41
|
-
const missingPluginErrorMessage = errorMessage;
|
42
|
-
|
43
|
-
// if the plugin exists then we need to check if the rule exists
|
44
|
-
if (config.plugins && config.plugins[pluginName]) {
|
45
|
-
const replacementRuleName = ruleReplacements.rules[ruleName];
|
46
|
-
|
47
|
-
if (pluginName === "@" && replacementRuleName) {
|
48
|
-
errorMessage = `${errorMessageHeader}: Rule "${ruleName}" was removed and replaced by "${replacementRuleName}".`;
|
49
|
-
} else {
|
50
|
-
errorMessage = `${errorMessageHeader}: Could not find "${ruleName}" in plugin "${pluginName}".`;
|
51
|
-
|
52
|
-
// otherwise, let's see if we can find the rule name elsewhere
|
53
|
-
for (const [otherPluginName, otherPlugin] of Object.entries(
|
54
|
-
config.plugins,
|
55
|
-
)) {
|
56
|
-
if (otherPlugin.rules && otherPlugin.rules[ruleName]) {
|
57
|
-
errorMessage += ` Did you mean "${otherPluginName}/${ruleName}"?`;
|
58
|
-
break;
|
59
|
-
}
|
60
|
-
}
|
61
|
-
}
|
62
|
-
|
63
|
-
// falls through to throw error
|
64
|
-
}
|
65
|
-
|
66
|
-
const error = new TypeError(errorMessage);
|
67
|
-
|
68
|
-
if (errorMessage === missingPluginErrorMessage) {
|
69
|
-
error.messageTemplate = "config-plugin-missing";
|
70
|
-
error.messageData = { pluginName, ruleId };
|
71
|
-
}
|
72
|
-
|
73
|
-
throw error;
|
74
|
-
}
|
75
|
-
|
76
|
-
/**
|
77
|
-
* The error type when a rule has an invalid `meta.schema`.
|
78
|
-
*/
|
79
|
-
class InvalidRuleOptionsSchemaError extends Error {
|
80
|
-
/**
|
81
|
-
* Creates a new instance.
|
82
|
-
* @param {string} ruleId Id of the rule that has an invalid `meta.schema`.
|
83
|
-
* @param {Error} processingError Error caught while processing the `meta.schema`.
|
84
|
-
*/
|
85
|
-
constructor(ruleId, processingError) {
|
86
|
-
super(
|
87
|
-
`Error while processing options validation schema of rule '${ruleId}': ${processingError.message}`,
|
88
|
-
{ cause: processingError },
|
89
|
-
);
|
90
|
-
this.code = "ESLINT_INVALID_RULE_OPTIONS_SCHEMA";
|
91
|
-
}
|
92
|
-
}
|
93
|
-
|
94
|
-
//-----------------------------------------------------------------------------
|
95
|
-
// Exports
|
96
|
-
//-----------------------------------------------------------------------------
|
97
|
-
|
98
|
-
/**
|
99
|
-
* Implements validation functionality for the rules portion of a config.
|
100
|
-
*/
|
101
|
-
class RuleValidator {
|
102
|
-
/**
|
103
|
-
* Creates a new instance.
|
104
|
-
*/
|
105
|
-
constructor() {
|
106
|
-
/**
|
107
|
-
* A collection of compiled validators for rules that have already
|
108
|
-
* been validated.
|
109
|
-
* @type {WeakMap}
|
110
|
-
*/
|
111
|
-
this.validators = new WeakMap();
|
112
|
-
}
|
113
|
-
|
114
|
-
/**
|
115
|
-
* Validates all of the rule configurations in a config against each
|
116
|
-
* rule's schema.
|
117
|
-
* @param {Object} config The full config to validate. This object must
|
118
|
-
* contain both the rules section and the plugins section.
|
119
|
-
* @returns {void}
|
120
|
-
* @throws {Error} If a rule's configuration does not match its schema.
|
121
|
-
*/
|
122
|
-
validate(config) {
|
123
|
-
if (!config.rules) {
|
124
|
-
return;
|
125
|
-
}
|
126
|
-
|
127
|
-
for (const [ruleId, ruleOptions] of Object.entries(config.rules)) {
|
128
|
-
// check for edge case
|
129
|
-
if (ruleId === "__proto__") {
|
130
|
-
continue;
|
131
|
-
}
|
132
|
-
|
133
|
-
/*
|
134
|
-
* If a rule is disabled, we don't do any validation. This allows
|
135
|
-
* users to safely set any value to 0 or "off" without worrying
|
136
|
-
* that it will cause a validation error.
|
137
|
-
*
|
138
|
-
* Note: ruleOptions is always an array at this point because
|
139
|
-
* this validation occurs after FlatConfigArray has merged and
|
140
|
-
* normalized values.
|
141
|
-
*/
|
142
|
-
if (ruleOptions[0] === 0) {
|
143
|
-
continue;
|
144
|
-
}
|
145
|
-
|
146
|
-
const rule = getRuleFromConfig(ruleId, config);
|
147
|
-
|
148
|
-
if (!rule) {
|
149
|
-
throwRuleNotFoundError(parseRuleId(ruleId), config);
|
150
|
-
}
|
151
|
-
|
152
|
-
// Precompile and cache validator the first time
|
153
|
-
if (!this.validators.has(rule)) {
|
154
|
-
try {
|
155
|
-
const schema = getRuleOptionsSchema(rule);
|
156
|
-
|
157
|
-
if (schema) {
|
158
|
-
this.validators.set(rule, ajv.compile(schema));
|
159
|
-
}
|
160
|
-
} catch (err) {
|
161
|
-
throw new InvalidRuleOptionsSchemaError(ruleId, err);
|
162
|
-
}
|
163
|
-
}
|
164
|
-
|
165
|
-
const validateRule = this.validators.get(rule);
|
166
|
-
|
167
|
-
if (validateRule) {
|
168
|
-
validateRule(ruleOptions.slice(1));
|
169
|
-
|
170
|
-
if (validateRule.errors) {
|
171
|
-
throw new Error(
|
172
|
-
`Key "rules": Key "${ruleId}":\n${validateRule.errors
|
173
|
-
.map(error => {
|
174
|
-
if (
|
175
|
-
error.keyword === "additionalProperties" &&
|
176
|
-
error.schema === false &&
|
177
|
-
typeof error.parentSchema?.properties ===
|
178
|
-
"object" &&
|
179
|
-
typeof error.params?.additionalProperty ===
|
180
|
-
"string"
|
181
|
-
) {
|
182
|
-
const expectedProperties = Object.keys(
|
183
|
-
error.parentSchema.properties,
|
184
|
-
).map(property => `"${property}"`);
|
185
|
-
|
186
|
-
return `\tValue ${JSON.stringify(error.data)} ${error.message}.\n\t\tUnexpected property "${error.params.additionalProperty}". Expected properties: ${expectedProperties.join(", ")}.\n`;
|
187
|
-
}
|
188
|
-
|
189
|
-
return `\tValue ${JSON.stringify(error.data)} ${error.message}.\n`;
|
190
|
-
})
|
191
|
-
.join("")}`,
|
192
|
-
);
|
193
|
-
}
|
194
|
-
}
|
195
|
-
}
|
196
|
-
}
|
197
|
-
}
|
198
|
-
|
199
|
-
exports.RuleValidator = RuleValidator;
|
package/lib/mcp/mcp-server.js
DELETED
@@ -1,66 +0,0 @@
|
|
1
|
-
/**
|
2
|
-
* @fileoverview MCP Server for handling requests and responses to ESLint.
|
3
|
-
* @author Nicholas C. Zakas
|
4
|
-
*/
|
5
|
-
|
6
|
-
"use strict";
|
7
|
-
|
8
|
-
//-----------------------------------------------------------------------------
|
9
|
-
// Requirements
|
10
|
-
//-----------------------------------------------------------------------------
|
11
|
-
|
12
|
-
const { McpServer } = require("@modelcontextprotocol/sdk/server/mcp.js");
|
13
|
-
const { z } = require("zod");
|
14
|
-
const { ESLint } = require("../eslint");
|
15
|
-
const pkg = require("../../package.json");
|
16
|
-
|
17
|
-
//-----------------------------------------------------------------------------
|
18
|
-
// Server
|
19
|
-
//-----------------------------------------------------------------------------
|
20
|
-
|
21
|
-
const mcpServer = new McpServer({
|
22
|
-
name: "ESLint",
|
23
|
-
version: pkg.version,
|
24
|
-
});
|
25
|
-
|
26
|
-
// Important: Cursor throws an error when `describe()` is used in the schema.
|
27
|
-
const filePathsSchema = {
|
28
|
-
filePaths: z.array(z.string().min(1)).nonempty(),
|
29
|
-
};
|
30
|
-
|
31
|
-
//-----------------------------------------------------------------------------
|
32
|
-
// Tools
|
33
|
-
//-----------------------------------------------------------------------------
|
34
|
-
|
35
|
-
mcpServer.tool(
|
36
|
-
"lint-files",
|
37
|
-
"Lint files using ESLint. You must provide a list of absolute file paths to the files you want to lint. The absolute file paths should be in the correct format for your operating system (e.g., forward slashes on Unix-like systems, backslashes on Windows).",
|
38
|
-
filePathsSchema,
|
39
|
-
async ({ filePaths }) => {
|
40
|
-
const eslint = new ESLint({
|
41
|
-
// enable lookup from file rather than from cwd
|
42
|
-
flags: ["unstable_config_lookup_from_file"],
|
43
|
-
});
|
44
|
-
|
45
|
-
const results = await eslint.lintFiles(filePaths);
|
46
|
-
const content = results.map(result => ({
|
47
|
-
type: "text",
|
48
|
-
text: JSON.stringify(result),
|
49
|
-
}));
|
50
|
-
|
51
|
-
content.unshift({
|
52
|
-
type: "text",
|
53
|
-
text: "Here are the results of running ESLint on the provided files:",
|
54
|
-
});
|
55
|
-
content.push({
|
56
|
-
type: "text",
|
57
|
-
text: "Do not automatically fix these issues. You must ask the user for confirmation before attempting to fix the issues found.",
|
58
|
-
});
|
59
|
-
|
60
|
-
return {
|
61
|
-
content,
|
62
|
-
};
|
63
|
-
},
|
64
|
-
);
|
65
|
-
|
66
|
-
module.exports = { mcpServer };
|
package/lib/shared/types.js
DELETED
@@ -1,229 +0,0 @@
|
|
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.
|
24
|
-
* @property {3|5|6|7|8|9|10|11|12|13|14|15|16|2015|2016|2017|2018|2019|2020|2021|2022|2023|2024|2025} [ecmaVersion] The ECMAScript version (or revision number).
|
25
|
-
* @property {"script"|"module"} [sourceType] The source code type.
|
26
|
-
* @property {boolean} [allowReserved] Allowing the use of reserved words as identifiers in ES3.
|
27
|
-
*/
|
28
|
-
|
29
|
-
/**
|
30
|
-
* @typedef {Object} ConfigData
|
31
|
-
* @property {Record<string, boolean>} [env] The environment settings.
|
32
|
-
* @property {string | string[]} [extends] The path to other config files or the package name of shareable configs.
|
33
|
-
* @property {Record<string, GlobalConf>} [globals] The global variable settings.
|
34
|
-
* @property {string | string[]} [ignorePatterns] The glob patterns that ignore to lint.
|
35
|
-
* @property {boolean} [noInlineConfig] The flag that disables directive comments.
|
36
|
-
* @property {OverrideConfigData[]} [overrides] The override settings per kind of files.
|
37
|
-
* @property {string} [parser] The path to a parser or the package name of a parser.
|
38
|
-
* @property {ParserOptions} [parserOptions] The parser options.
|
39
|
-
* @property {string[]} [plugins] The plugin specifiers.
|
40
|
-
* @property {string} [processor] The processor specifier.
|
41
|
-
* @property {boolean} [reportUnusedDisableDirectives] The flag to report unused `eslint-disable` comments.
|
42
|
-
* @property {boolean} [root] The root flag.
|
43
|
-
* @property {Record<string, RuleConf>} [rules] The rule settings.
|
44
|
-
* @property {Object} [settings] The shared settings.
|
45
|
-
*/
|
46
|
-
|
47
|
-
/**
|
48
|
-
* @typedef {Object} OverrideConfigData
|
49
|
-
* @property {Record<string, boolean>} [env] The environment settings.
|
50
|
-
* @property {string | string[]} [excludedFiles] The glob patterns for excluded files.
|
51
|
-
* @property {string | string[]} [extends] The path to other config files or the package name of shareable configs.
|
52
|
-
* @property {string | string[]} files The glob patterns for target files.
|
53
|
-
* @property {Record<string, GlobalConf>} [globals] The global variable settings.
|
54
|
-
* @property {boolean} [noInlineConfig] The flag that disables directive comments.
|
55
|
-
* @property {OverrideConfigData[]} [overrides] The override settings per kind of files.
|
56
|
-
* @property {string} [parser] The path to a parser or the package name of a parser.
|
57
|
-
* @property {ParserOptions} [parserOptions] The parser options.
|
58
|
-
* @property {string[]} [plugins] The plugin specifiers.
|
59
|
-
* @property {string} [processor] The processor specifier.
|
60
|
-
* @property {boolean} [reportUnusedDisableDirectives] The flag to report unused `eslint-disable` comments.
|
61
|
-
* @property {Record<string, RuleConf>} [rules] The rule settings.
|
62
|
-
* @property {Object} [settings] The shared settings.
|
63
|
-
*/
|
64
|
-
|
65
|
-
/**
|
66
|
-
* @typedef {Object} ParseResult
|
67
|
-
* @property {Object} ast The AST.
|
68
|
-
* @property {ScopeManager} [scopeManager] The scope manager of the AST.
|
69
|
-
* @property {Record<string, any>} [services] The services that the parser provides.
|
70
|
-
* @property {Record<string, string[]>} [visitorKeys] The visitor keys of the AST.
|
71
|
-
*/
|
72
|
-
|
73
|
-
/**
|
74
|
-
* @typedef {Object} Parser
|
75
|
-
* @property {(text:string, options:ParserOptions) => Object} parse The definition of global variables.
|
76
|
-
* @property {(text:string, options:ParserOptions) => ParseResult} [parseForESLint] The parser options that will be enabled under this environment.
|
77
|
-
*/
|
78
|
-
|
79
|
-
/**
|
80
|
-
* @typedef {Object} Environment
|
81
|
-
* @property {Record<string, GlobalConf>} [globals] The definition of global variables.
|
82
|
-
* @property {ParserOptions} [parserOptions] The parser options that will be enabled under this environment.
|
83
|
-
*/
|
84
|
-
|
85
|
-
/**
|
86
|
-
* @typedef {Object} LintMessage
|
87
|
-
* @property {number|undefined} column The 1-based column number.
|
88
|
-
* @property {number} [endColumn] The 1-based column number of the end location.
|
89
|
-
* @property {number} [endLine] The 1-based line number of the end location.
|
90
|
-
* @property {boolean} [fatal] If `true` then this is a fatal error.
|
91
|
-
* @property {{range:[number,number], text:string}} [fix] Information for autofix.
|
92
|
-
* @property {number|undefined} line The 1-based line number.
|
93
|
-
* @property {string} message The error message.
|
94
|
-
* @property {string} [messageId] The ID of the message in the rule's meta.
|
95
|
-
* @property {(string|null)} nodeType Type of node
|
96
|
-
* @property {string|null} ruleId The ID of the rule which makes this message.
|
97
|
-
* @property {0|1|2} severity The severity of this message.
|
98
|
-
* @property {Array<{desc?: string, messageId?: string, fix: {range: [number, number], text: string}}>} [suggestions] Information for suggestions.
|
99
|
-
*/
|
100
|
-
|
101
|
-
/**
|
102
|
-
* @typedef {Object} SuppressedLintMessage
|
103
|
-
* @property {number|undefined} column The 1-based column number.
|
104
|
-
* @property {number} [endColumn] The 1-based column number of the end location.
|
105
|
-
* @property {number} [endLine] The 1-based line number of the end location.
|
106
|
-
* @property {boolean} [fatal] If `true` then this is a fatal error.
|
107
|
-
* @property {{range:[number,number], text:string}} [fix] Information for autofix.
|
108
|
-
* @property {number|undefined} line The 1-based line number.
|
109
|
-
* @property {string} message The error message.
|
110
|
-
* @property {string} [messageId] The ID of the message in the rule's meta.
|
111
|
-
* @property {(string|null)} nodeType Type of node
|
112
|
-
* @property {string|null} ruleId The ID of the rule which makes this message.
|
113
|
-
* @property {0|1|2} severity The severity of this message.
|
114
|
-
* @property {Array<{kind: string, justification: string}>} suppressions The suppression info.
|
115
|
-
* @property {Array<{desc?: string, messageId?: string, fix: {range: [number, number], text: string}}>} [suggestions] Information for suggestions.
|
116
|
-
*/
|
117
|
-
|
118
|
-
/**
|
119
|
-
* @typedef {Record<string, Record<string, { count: number }>>} SuppressedViolations
|
120
|
-
*/
|
121
|
-
|
122
|
-
/**
|
123
|
-
* @typedef {Object} SuggestionResult
|
124
|
-
* @property {string} desc A short description.
|
125
|
-
* @property {string} [messageId] Id referencing a message for the description.
|
126
|
-
* @property {{ text: string, range: number[] }} fix fix result info
|
127
|
-
*/
|
128
|
-
|
129
|
-
/**
|
130
|
-
* @typedef {Object} Processor
|
131
|
-
* @property {(text:string, filename:string) => Array<string | { text:string, filename:string }>} [preprocess] The function to extract code blocks.
|
132
|
-
* @property {(messagesList:LintMessage[][], filename:string) => LintMessage[]} [postprocess] The function to merge messages.
|
133
|
-
* @property {boolean} [supportsAutofix] If `true` then it means the processor supports autofix.
|
134
|
-
*/
|
135
|
-
|
136
|
-
/**
|
137
|
-
* @typedef {Object} RuleMetaDocs
|
138
|
-
* @property {string} description The description of the rule.
|
139
|
-
* @property {boolean} recommended If `true` then the rule is included in `eslint:recommended` preset.
|
140
|
-
* @property {string} url The URL of the rule documentation.
|
141
|
-
*/
|
142
|
-
|
143
|
-
/**
|
144
|
-
* @typedef {Object} DeprecatedInfo
|
145
|
-
* @property {string} [message] General message presented to the user
|
146
|
-
* @property {string} [url] URL to more information about this deprecation in general
|
147
|
-
* @property {ReplacedByInfo[]} [replacedBy] Potential replacements for the rule
|
148
|
-
* @property {string} [deprecatedSince] Version since the rule is deprecated
|
149
|
-
* @property {?string} [availableUntil] Version until it is available or null if indefinite
|
150
|
-
*/
|
151
|
-
|
152
|
-
/**
|
153
|
-
* @typedef {Object} ReplacedByInfo
|
154
|
-
* @property {string} [message] General message presented to the user
|
155
|
-
* @property {string} [url] URL to more information about this replacement in general
|
156
|
-
* @property {{ name?: string, url?: string }} [plugin] Use "eslint" for a core rule. Omit if the rule is in the same plugin.
|
157
|
-
* @property {{ name?: string, url?: string }} [rule] Name and information of the replacement rule
|
158
|
-
*/
|
159
|
-
|
160
|
-
/**
|
161
|
-
* Information of deprecated rules.
|
162
|
-
* @typedef {Object} DeprecatedRuleInfo
|
163
|
-
* @property {string} ruleId The rule ID.
|
164
|
-
* @property {string[]} replacedBy The rule IDs that replace this deprecated rule.
|
165
|
-
* @property {DeprecatedInfo} [info] The raw deprecated info provided by rule. Unset if `deprecated` is a boolean.
|
166
|
-
*/
|
167
|
-
|
168
|
-
/**
|
169
|
-
* A linting result.
|
170
|
-
* @typedef {Object} LintResult
|
171
|
-
* @property {string} filePath The path to the file that was linted.
|
172
|
-
* @property {LintMessage[]} messages All of the messages for the result.
|
173
|
-
* @property {SuppressedLintMessage[]} suppressedMessages All of the suppressed messages for the result.
|
174
|
-
* @property {number} errorCount Number of errors for the result.
|
175
|
-
* @property {number} fatalErrorCount Number of fatal errors for the result.
|
176
|
-
* @property {number} warningCount Number of warnings for the result.
|
177
|
-
* @property {number} fixableErrorCount Number of fixable errors for the result.
|
178
|
-
* @property {number} fixableWarningCount Number of fixable warnings for the result.
|
179
|
-
* @property {Stats} [stats] The performance statistics collected with the `stats` flag.
|
180
|
-
* @property {string} [source] The source code of the file that was linted.
|
181
|
-
* @property {string} [output] The source code of the file that was linted, with as many fixes applied as possible.
|
182
|
-
* @property {DeprecatedRuleInfo[]} usedDeprecatedRules The list of used deprecated rules.
|
183
|
-
*/
|
184
|
-
|
185
|
-
/**
|
186
|
-
* Performance statistics
|
187
|
-
* @typedef {Object} Stats
|
188
|
-
* @property {number} fixPasses The number of times ESLint has applied at least one fix after linting.
|
189
|
-
* @property {Times} times The times spent on (parsing, fixing, linting) a file.
|
190
|
-
*/
|
191
|
-
|
192
|
-
/**
|
193
|
-
* Performance Times for each ESLint pass
|
194
|
-
* @typedef {Object} Times
|
195
|
-
* @property {TimePass[]} passes Time passes
|
196
|
-
*/
|
197
|
-
|
198
|
-
/**
|
199
|
-
* @typedef {Object} TimePass
|
200
|
-
* @property {ParseTime} parse The parse object containing all parse time information.
|
201
|
-
* @property {Record<string, RuleTime>} [rules] The rules object containing all lint time information for each rule.
|
202
|
-
* @property {FixTime} fix The parse object containing all fix time information.
|
203
|
-
* @property {number} total The total time that is spent on (parsing, fixing, linting) a file.
|
204
|
-
*/
|
205
|
-
/**
|
206
|
-
* @typedef {Object} ParseTime
|
207
|
-
* @property {number} total The total time that is spent when parsing a file.
|
208
|
-
*/
|
209
|
-
/**
|
210
|
-
* @typedef {Object} RuleTime
|
211
|
-
* @property {number} total The total time that is spent on a rule.
|
212
|
-
*/
|
213
|
-
/**
|
214
|
-
* @typedef {Object} FixTime
|
215
|
-
* @property {number} total The total time that is spent on applying fixes to the code.
|
216
|
-
*/
|
217
|
-
|
218
|
-
/**
|
219
|
-
* Information provided when the maximum warning threshold is exceeded.
|
220
|
-
* @typedef {Object} MaxWarningsExceeded
|
221
|
-
* @property {number} maxWarnings Number of warnings to trigger nonzero exit code.
|
222
|
-
* @property {number} foundWarnings Number of warnings found while linting.
|
223
|
-
*/
|
224
|
-
|
225
|
-
/**
|
226
|
-
* Metadata about results for formatters.
|
227
|
-
* @typedef {Object} ResultsMeta
|
228
|
-
* @property {MaxWarningsExceeded} [maxWarningsExceeded] Present if the maxWarnings threshold was exceeded.
|
229
|
-
*/
|