Skip to content

Commit e972c88

Browse files
authored
docs: merge ESLint option descriptions into type definitions (#20608)
* docs: merge ESLint option descriptions into type definitions * fix typo
1 parent f65e5d3 commit e972c88

2 files changed

Lines changed: 53 additions & 29 deletions

File tree

lib/eslint/eslint.js

Lines changed: 2 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -68,38 +68,11 @@ const { resolve } = require("../shared/relative-module-resolver.js");
6868

6969
/** @typedef {import("../types").Linter.Config} Config */
7070
/** @typedef {import("../types").ESLint.DeprecatedRuleUse} DeprecatedRuleInfo */
71+
/** @typedef {import("../types").ESLint.Options} ESLintOptions */
7172
/** @typedef {import("../types").ESLint.LintResult} LintResult */
7273
/** @typedef {import("../types").ESLint.Plugin} Plugin */
7374
/** @typedef {import("../types").ESLint.ResultsMeta} ResultsMeta */
7475

75-
/**
76-
* The options with which to configure the ESLint instance.
77-
* @typedef {Object} ESLintOptions
78-
* @property {boolean} [allowInlineConfig] Enable or disable inline configuration comments.
79-
* @property {Config|Array<Config>} [baseConfig] Base config, extended by all configs used with this instance
80-
* @property {boolean} [cache] Enable result caching.
81-
* @property {string} [cacheLocation] The cache file to use instead of .eslintcache.
82-
* @property {"metadata" | "content"} [cacheStrategy] The strategy used to detect changed files.
83-
* @property {number | "auto" | "off"} [concurrency] Maximum number of linting threads, "auto" to choose automatically, "off" for no multithreading.
84-
* @property {string} [cwd] The value to use for the current working directory.
85-
* @property {boolean} [errorOnUnmatchedPattern] If `false` then `ESLint#lintFiles()` doesn't throw even if no target files found. Defaults to `true`.
86-
* @property {boolean|Function} [fix] Execute in autofix mode. If a function, should return a boolean.
87-
* @property {string[]} [fixTypes] Array of rule types to apply fixes for.
88-
* @property {string[]} [flags] Array of feature flags to enable.
89-
* @property {boolean} [globInputPaths] Set to false to skip glob resolution of input file paths to lint (default: true). If false, each input file paths is assumed to be a non-glob path to an existing file.
90-
* @property {boolean} [ignore] False disables all ignore patterns except for the default ones.
91-
* @property {string[]} [ignorePatterns] Ignore file patterns to use in addition to config ignores. These patterns are relative to `cwd`.
92-
* @property {Config|Array<Config>} [overrideConfig] Override config, overrides all configs used with this instance
93-
* @property {boolean|string} [overrideConfigFile] Searches for default config file when falsy;
94-
* doesn't do any config file lookup when `true`; considered to be a config filename
95-
* when a string.
96-
* @property {boolean} [passOnNoPatterns=false] When set to true, missing patterns cause
97-
* the linting operation to short circuit and not report any failures.
98-
* @property {Record<string,Plugin>} [plugins] An array of plugin implementations.
99-
* @property {boolean} [stats] True enables added statistics on lint results.
100-
* @property {boolean} [warnIgnored] Show warnings when the file list includes ignored files
101-
*/
102-
10376
//------------------------------------------------------------------------------
10477
// Helpers
10578
//------------------------------------------------------------------------------
@@ -237,7 +210,7 @@ function compareResultsByFilePath(a, b) {
237210
*
238211
* This function is used primarily by the `--inspect-config` option. For now,
239212
* we will maintain the existing behavior, which is to search up from the cwd.
240-
* @param {ESLintOptions} options The ESLint instance options.
213+
* @param {{ configFile: string | undefined; cwd: string; }} options Config file location options.
241214
* @returns {Promise<{configFilePath:string|undefined;basePath:string}>} Location information for
242215
* the config file.
243216
*/

lib/types/index.d.ts

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1195,41 +1195,92 @@ export namespace ESLint {
11951195

11961196
type CacheStrategy = "content" | "metadata";
11971197

1198+
/** The options with which to configure the ESLint instance. */
11981199
interface Options {
11991200
// File enumeration
1201+
1202+
/** The value to use for the current working directory. */
12001203
cwd?: string | undefined;
1204+
1205+
/** If `false` then `ESLint#lintFiles()` doesn't throw even if no target files found. Defaults to `true`. */
12011206
errorOnUnmatchedPattern?: boolean | undefined;
1207+
1208+
/**
1209+
* Set to false to skip glob resolution of input file paths to lint (default: true).
1210+
* If false, each input file path is assumed to be a non-glob path to an existing file.
1211+
*/
12021212
globInputPaths?: boolean | undefined;
1213+
1214+
/** False disables all ignore patterns except for the default ones. */
12031215
ignore?: boolean | undefined;
1216+
1217+
/** Ignore file patterns to use in addition to config ignores. These patterns are relative to `cwd`. */
12041218
ignorePatterns?: string[] | null | undefined;
1219+
1220+
/** When set to true, missing patterns cause the linting operation to short circuit and not report any failures. */
12051221
passOnNoPatterns?: boolean | undefined;
1222+
1223+
/** Show warnings when the file list includes ignored files. */
12061224
warnIgnored?: boolean | undefined;
12071225

12081226
// Linting
1227+
1228+
/** Enable or disable inline configuration comments. */
12091229
allowInlineConfig?: boolean | undefined;
1230+
1231+
/** Base config, extended by all configs used with this instance. */
12101232
baseConfig?: Linter.Config | Linter.Config[] | null | undefined;
1233+
1234+
/** Override config, overrides all configs used with this instance. */
12111235
overrideConfig?: Linter.Config | Linter.Config[] | null | undefined;
1236+
1237+
/**
1238+
* Searches for default config file when falsy; doesn't do any config file lookup when `true`; considered to be a config filename when a string.
1239+
*/
12121240
overrideConfigFile?: string | true | null | undefined;
1241+
1242+
/** An array of plugin implementations. */
12131243
plugins?: Record<string, Plugin> | null | undefined;
1244+
1245+
/**
1246+
* Default is `() => true`. A predicate function that filters rules to be run.
1247+
* This function is called with an object containing `ruleId` and `severity`, and returns `true` if the rule should be run.
1248+
*/
12141249
ruleFilter?:
12151250
| ((arg: {
12161251
ruleId: string;
12171252
severity: Exclude<Linter.Severity, 0>;
12181253
}) => boolean)
12191254
| undefined;
1255+
1256+
/** True enables added statistics on lint results. */
12201257
stats?: boolean | undefined;
12211258

12221259
// Autofix
1260+
1261+
/** Execute in autofix mode. If a function, should return a boolean. */
12231262
fix?: boolean | ((message: Linter.LintMessage) => boolean) | undefined;
1263+
1264+
/** Array of rule types to apply fixes for. */
12241265
fixTypes?: FixType[] | null | undefined;
12251266

12261267
// Cache-related
1268+
1269+
/** Enable result caching. */
12271270
cache?: boolean | undefined;
1271+
1272+
/** The cache file to use instead of .eslintcache. */
12281273
cacheLocation?: string | undefined;
1274+
1275+
/** The strategy used to detect changed files. */
12291276
cacheStrategy?: CacheStrategy | undefined;
12301277

12311278
// Other Options
1279+
1280+
/** Maximum number of linting threads, "auto" to choose automatically, "off" for no multithreading. */
12321281
concurrency?: number | "auto" | "off" | undefined;
1282+
1283+
/** Array of feature flags to enable. */
12331284
flags?: string[] | undefined;
12341285
}
12351286

0 commit comments

Comments
 (0)