8000 docs: fix internal usages of `ConfigData` type (#19688) · eslint/eslint@8ed3273 · GitHub
[go: up one dir, main page]

Skip to content

Commit 8ed3273

Browse files
authored
docs: fix internal usages of ConfigData type (#19688)
1 parent f305beb commit 8ed3273

File tree

8 files changed

+33
-69
lines changed

8 files changed

+33
-69
lines changed

docs/src/integrate/nodejs-api.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -140,9 +140,9 @@ The `ESLint` constructor takes an `options` object. If you omit the `options` ob
140140

141141
- `options.allowInlineConfig` (`boolean`)<br>
142142
Default is `true`. If `false` is present, ESLint suppresses directive comments in source code. If this option is `false`, it overrides the `noInlineConfig` setting in your configurations.
143-
- `options.baseConfig` (`ConfigData | ConfigData[] | null`)<br>
143+
- `options.baseConfig` (`Config | Config[] | null`)<br>
144144
Default is `null`. [Configuration object], extended by all configurations used with this instance. You can use this option to define the default settings that will be used if your configuration files don't configure it.
145-
- `options.overrideConfig` (`ConfigData | ConfigData[] | null`)<br>
145+
- `options.overrideConfig` (`Config | Config[] | null`)<br>
146146
Default is `null`. [Configuration object], added after any existing configuration and therefore applies after what's contained in your configuration file (if used).
147147
- `options.overrideConfigFile` (`null | true | string`)<br>
148148
Default is `null`. By default, ESLint searches for a configuration file. When this option is set to `true`, ESLint does not search for a configuration file. When this option is set to a `string` value, ESLint does not search for a configuration file, and uses the provided value as the path to the configuration file.

lib/cli-engine/cli-engine.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,15 +58,15 @@ const validFixTypes = new Set(["directive", "problem", "suggestion", "layout"]);
5858
//------------------------------------------------------------------------------
5959

6060
// For VSCode IntelliSense
61-
/** @typedef {import("../shared/types").ConfigData} ConfigData */
6261
/** @typedef {import("../shared/types").DeprecatedRuleInfo} DeprecatedRuleInfo */
6362
/** @typedef {import("../shared/types").LintMessage} LintMessage */
6463
/** @typedef {import("../shared/types").SuppressedLintMessage} SuppressedLintMessage */
6564
/** @typedef {import("../shared/types").ParserOptions} ParserOptions */
6665
/** @typedef {import("../shared/types").RuleConf} RuleConf */
67-
/** @typedef {import("../types").Rule.RuleModule} Rule */
66+
/** @typedef {import("../types").ESLint.ConfigData} ConfigData */
6867
/** @typedef {import("../types").ESLint.FormatterFunction} FormatterFunction */
6968
/** @typedef {import("../types").ESLint.Plugin} Plugin */
69+
/** @typedef {import("../types").Rule.RuleModule} Rule */
7070
/** @typedef {ReturnType<CascadingConfigArrayFactory.getConfigArrayForFile>} ConfigArray */
7171
/** @typedef {ReturnType<ConfigArray.extractConfig>} ExtractedConfig */
7272

lib/config/config-loader.js

Lines changed: 10 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -20,19 +20,17 @@ const { FlatConfigArray } = require("./flat-config-array");
2020
// Types
2121
//-----------------------------------------------------------------------------
2222

23-
/**
24-
* @import { ConfigData, ConfigData as FlatConfigObject } from "../shared/types.js";
25-
*/
23+
/** @typedef {import("../types").Linter.Config} Config */
2624

2725
/**
2826
* @typedef {Object} ConfigLoaderOptions
2927
* @property {string|false|undefined} configFile The path to the config file to use.
3028
* @property {string} cwd The current working directory.
3129
* @property {boolean} ignoreEnabled Indicates if ignore patterns should be honored.
32-
* @property {FlatConfigArray} [baseConfig] The base config to use.
33-
* @property {Array<FlatConfigObject>} [defaultConfigs] The default configs to use.
30+
* @property {Config|Array<Config>} [baseConfig] The base config to use.
31+
* @property {Array<Config>} [defaultConfigs] The default configs to use.
3432
* @property {Array<string>} [ignorePatterns] The ignore patterns to use.
35-
* @property {FlatConfigObject|Array<FlatConfigObject>} [overrideConfig] The override config to use.
33+
* @property {Config|Array<Config>} [overrideConfig] The override config to use.
3634
* @property {boolean} [hasUnstableNativeNodeJsTSConfigFlag] The flag to indicate whether the `unstable_native_nodejs_ts_config` flag is enabled.
3735
*/
3836

@@ -394,8 +392,7 @@ class ConfigLoader {
394392
* This is the same logic used by the ESLint CLI executable to determine
395393
* configuration for each file it processes.
396394
* @param {string} filePath The path of the file or directory to retrieve config for.
397-
* @returns {Promise<ConfigData|undefined>} A configuration object for the file
398-
* or `undefined` if there is no configuration data for the file.
395+
* @returns {Promise<FlatConfigArray>} A configuration object for the file.
399396
* @throws {Error} If no configuration for `filePath` exists.
400397
*/
401398
async loadConfigArrayForFile(filePath) {
@@ -415,8 +412,7 @@ class ConfigLoader {
415412
* This is the same logic used by the ESLint CLI executable to determine
416413
* configuration for each file it processes.
417414
* @param {string} dirPath The path of the directory to retrieve config for.
418-
* @returns {Promise<ConfigData|undefined>} A configuration object for the directory
419-
* or `undefined` if there is no configuration data for the directory.
415+
* @returns {Promise<FlatConfigArray>} A configuration object for the directory.
420416
*/
421417
async loadConfigArrayForDirectory(dirPath) {
422418
assertValidFilePath(dirPath);
@@ -440,8 +436,7 @@ class ConfigLoader {
440436
* intended to be used in locations where we know the config file has already
441437
* been loaded and we just need to get the configuration for a file.
442438
* @param {string} filePath The path of the file to retrieve a config object for.
443-
* @returns {ConfigData|undefined} A configuration object for the file
444-
* or `undefined` if there is no configuration data for the file.
439+
* @returns {FlatConfigArray} A configuration object for the file.
445440
* @throws {Error} If `filePath` is not a non-empty string.
446441
* @throws {Error} If `filePath` is not an absolute path.
447442
* @throws {Error} If the config file was not already loaded.
@@ -460,8 +455,7 @@ class ConfigLoader {
460455
* intended to be used in locations where we know the config file has already
461456
* been loaded and we just need to get the configuration for a file.
462457
* @param {string} fileOrDirPath The path of the directory to retrieve a config object for.
463-
* @returns {ConfigData|undefined} A configuration object for the directory
464-
* or `undefined` if there is no configuration data for the directory.
458+
* @returns {FlatConfigArray} A configuration object for the directory.
465459
* @throws {Error} If `dirPath` is not a non-empty string.
466460
* @throws {Error} If `dirPath` is not an absolute path.
467461
* @throws {Error} If the config file was not already loaded.
@@ -789,8 +783,7 @@ class LegacyConfigLoader extends ConfigLoader {
789783
* This is the same logic used by the ESLint CLI executable to determine
790784
* configuration for each file it processes.
791785
* @param {string} dirPath The path of the directory to retrieve config for.
792-
* @returns {Promise<ConfigData|undefined>} A configuration object for the file
793-
* or `undefined` if there is no configuration data for the file.
786+
* @returns {Promise<FlatConfigArray>} A configuration object for the file.
794787
*/
795788
async loadConfigArrayForDirectory(dirPath) {
796789
assertValidFilePath(dirPath);
@@ -812,8 +805,7 @@ class LegacyConfigLoader extends ConfigLoader {
812805
* intended to be used in locations where we know the config file has already
813806
* been loaded and we just need to get the configuration for a file.
814807
* @param {string} dirPath The path of the directory to retrieve a config object for.
815-
* @returns {ConfigData|undefined} A configuration object for the file
816-
* or `undefined` if there is no configuration data for the file.
808+
* @returns {FlatConfigArray} A configuration object for the file.
817809
* @throws {Error} If `dirPath` is not a non-empty string.
818810
* @throws {Error} If `dirPath` is not an absolute path.
819811
* @throws {Error} If the config file was not already loaded.

lib/eslint/eslint.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,17 +57,18 @@ const { ConfigLoader, LegacyConfigLoader } = require("../config/config-loader");
5757
* @import { CLIEngineLintReport } from "./legacy-eslint.js";
5858
* @import { FlatConfigArray } from "../config/flat-config-array.js";
5959
* @import { RuleDefinition } from "@eslint/core";
60-
* @import { ConfigData, DeprecatedRuleInfo, LintMessage, LintResult, ResultsMeta } from "../shared/types.js";
60+
* @import { DeprecatedRuleInfo, LintMessage, LintResult, ResultsMeta } from "../shared/types.js";
6161
*/
6262

6363
/** @typedef {ReturnType<ConfigArray.extractConfig>} ExtractedConfig */
64+
/** @typedef {import("../types").Linter.Config} Config */
6465
/** @typedef {import("../types").ESLint.Plugin} Plugin */
6566

6667
/**
6768
* The options with which to configure the ESLint instance.
6869
* @typedef {Object} ESLintOptions
6970
* @property {boolean} [allowInlineConfig] Enable or disable inline configuration comments.
70-
* @property {ConfigData|Array<ConfigData>} [baseConfig] Base config, extended by all configs used with this instance
71+
* @property {Config|Array<Config>} [baseConfig] Base config, extended by all configs used with this instance
7172
* @property {boolean} [cache] Enable result caching.
7273
* @property {string} [cacheLocation] The cache file to use instead of .eslintcache.
7374
* @property {"metadata" | "content"} [cacheStrategy] The strategy used to detect changed files.
@@ -79,7 +80,7 @@ const { ConfigLoader, LegacyConfigLoader } = require("../config/config-loader");
7980
* @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.
8081
* @property {boolean} [ignore] False disables all ignore patterns except for the default ones.
8182
* @property {string[]} [ignorePatterns] Ignore file patterns to use in addition to config ignores. These patterns are relative to `cwd`.
82-
* @property {ConfigData|Array<ConfigData>} [overrideConfig] Override config, overrides all configs used with this instance
83+
* @property {Config|Array<Config>} [overrideConfig] Override config, overrides all configs used with this instance
8384
* @property {boolean|string} [overrideConfigFile] Searches for default config file when falsy;
8485
* doesn't do any config file lookup when `true`; considered to be a config filename
8586
* when a string.
@@ -1068,7 +1069,7 @@ class ESLint {
10681069
* This is the same logic used by the ESLint CLI executable to determine
10691070
* configuration for each file it processes.
10701071
* @param {string} filePath The path of the file to retrieve a config object for.
1071-
* @returns {Promise<ConfigData|undefined>} A configuration object for the file
1072+
* @returns {Promise<Config|undefined>} A configuration object for the file
10721073
* or `undefined` if there is no configuration data for the object.
10731074
*/
10741075
async calculateConfigForFile(filePath) {

lib/eslint/legacy-eslint.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,11 @@ const { version } = require("../../package.json");
3131

3232
/** @typedef {import("../cli-engine/cli-engine").LintReport} CLIEngineLintReport */
3333
/** @typedef {import("../shared/types").DeprecatedRuleInfo} DeprecatedRuleInfo */
34-
/** @typedef {import("../shared/types").ConfigData} ConfigData */
3534
/** @typedef {import("../shared/types").LintMessage} LintMessage */
3635
/** @typedef {import("../shared/types").SuppressedLintMessage} SuppressedLintMessage */
3736
/** @typedef {import("../shared/types").LintResult} LintResult */
3837
/** @typedef {import("../shared/types").ResultsMeta} ResultsMeta */
38+
/** @typedef {import("../types").ESLint.ConfigData} ConfigData */
3939
/** @typedef {import("../types").ESLint.Plugin} Plugin */
4040
/** @typedef {import("../types").Rule.RuleModule} Rule */
4141

lib/linter/linter.js

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -75,14 +75,15 @@ const STEP_KIND_CALL = 2;
7575

7676
/** @import { Language, LanguageOptions, RuleConfig, RuleDefinition, RuleSeverity } from "@eslint/core" */
7777

78-
/** @typedef {import("../shared/types").ConfigData} ConfigData */
7978
/** @typedef {import("../shared/types").Environment} Environment */
8079
/** @typedef {import("../shared/types").GlobalConf} GlobalConf */
8180
/** @typedef {import("../shared/types").LintMessage} LintMessage */
8281
/** @typedef {import("../shared/types").SuppressedLintMessage} SuppressedLintMessage */
8382
/** @typedef {import("../shared/types").ParserOptions} ParserOptions */
8483
/** @typedef {import("../shared/types").Processor} Processor */
8584
/** @typedef {import("../shared/types").Times} Times */
85+
/** @typedef {import("../types").Linter.Config} Config */
86+
/** @typedef {import("../types").ESLint.ConfigData} ConfigData */
8687
/** @typedef {import("../types").Linter.LanguageOptions} JSLanguageOptions */
8788
/** @typedef {import("../types").Linter.StringSeverity} StringSeverity */
8889
/** @typedef {import("../types").Rule.RuleModule} Rule */
@@ -350,7 +351,7 @@ function asArray(value) {
350351

351352
/**
352353
* Pushes a problem to inlineConfigProblems if ruleOptions are redundant.
353-
* @param {ConfigData} config Provided config.
354+
* @param {Config} config Provided config.
354355
* @param {Object} loc A line/column location
355356
* @param {Array} problems Problems that may be added to.
356357
* @param {string} ruleId The rule ID.
@@ -901,7 +902,7 @@ function normalizeFilename(filename) {
901902
* Normalizes the possible options for `linter.verify` and `linter.verifyAndFix` to a
902903
* consistent shape.
903904
* @param {VerifyOptions} providedOptions Options
904-
* @param {ConfigData} config Config.
905+
* @param {Config|ConfigData} config Config.
905906
* @returns {Required<VerifyOptions> & InternalOptions} Normalized options
906907
*/
907908
function normalizeVerifyOptions(providedOptions, config) {
@@ -1885,7 +1886,7 @@ class Linter {
18851886
/**
18861887
* Verify with a processor.
18871888
* @param {string|SourceCode} textOrSourceCode The source code.
1888-
* @param {FlatConfig} config The config array.
1889+
* @param {Config} config The config array.
18891890
* @param {VerifyOptions&ProcessorOptions} options The options.
18901891
* @param {FlatConfigArray} [configForRecursive] The `ConfigArray` object to apply multiple processors recursively.
18911892
* @returns {(LintMessage|SuppressedLintMessage)[]} The found problems.
@@ -1986,7 +1987,7 @@ class Linter {
19861987
/**
19871988
* Verify using flat config and without any processors.
19881989
* @param {VFile} file The file to lint.
1989-
* @param {FlatConfig} providedConfig An ESLintConfig instance to configure everything.
1990+
* @param {Config} providedConfig An ESLintConfig instance to configure everything.
19901991
* @param {VerifyOptions} [providedOptions] The optional filename of the file being checked.
19911992
* @throws {Error} If during rule execution.
19921993
* @returns {(LintMessage|SuppressedLintMessage)[]} The results as an array of messages or an empty array if no messages.
@@ -2348,7 +2349,7 @@ class Linter {
23482349
/**
23492350
* Same as linter.verify, except without support for processors.
23502351
* @param {string|SourceCode} textOrSourceCode The text to parse or a SourceCode object.
2351-
* @param {FlatConfig} providedConfig An ESLintConfig instance to configure everything.
2352+
* @param {Config} providedConfig An ESLintConfig instance to configure everything.
23522353
* @param {VerifyOptions} [providedOptions] The optional filename of the file being checked.
23532354
* @throws {Error} If during rule execution.
23542355
* @returns {(LintMessage|SuppressedLintMessage)[]} The results as an array of messages or an empty array if no messages.

lib/shared/types.js

Lines changed: 0 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -26,42 +26,6 @@ module.exports = {};
2626
* @property {boolean} [allowReserved] Allowing the use of reserved words as identifiers in ES3.
2727
*/
2828

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-
6529
/**
6630
* @typedef {Object} ParseResult
6731
* @property {Object} ast The AST.

tools/eslint-fuzzer.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,12 @@ const SourceCodeFixer = require("../lib/linter/source-code-fixer");
1616
const ruleConfigs = require("./config-rule").createCoreRuleConfigs(true);
1717
const sampleMinimizer = require("./code-sample-minimizer");
1818

19+
//------------------------------------------------------------------------------
20+
// Typedefs
21+
//------------------------------------------------------------------------------
22+
23+
/** @typedef {import("../lib/types").ESLint.ConfigData} ConfigData */
24+
1925
//------------------------------------------------------------------------------
2026
// Helpers
2127
//------------------------------------------------------------------------------

0 commit comments

Comments
 (0)
0