Skip to content

Commit

Permalink
chore: apply eslint --fix
Browse files Browse the repository at this point in the history
  • Loading branch information
aladdin-add committed Jun 7, 2023
1 parent a42eaf2 commit 2a13d2c
Show file tree
Hide file tree
Showing 69 changed files with 271 additions and 273 deletions.
2 changes: 1 addition & 1 deletion lib/cli-engine/cli-engine.js
Original file line number Diff line number Diff line change
Expand Up @@ -1001,7 +1001,7 @@ class CLIEngine {
/**
* Returns the formatter representing the given format or null if the `format` is not a string.
* @param {string} [format] The name of the format to load or the path to a
* custom formatter.
* custom formatter.
* @throws {any} As may be thrown by requiring of formatter
* @returns {(FormatterFunction|null)} The formatter function or null if the `format` is not a string.
*/
Expand Down
2 changes: 1 addition & 1 deletion lib/cli-engine/lint-result-cache.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ class LintResultCache {
* @param {string} filePath The file for which to retrieve lint results.
* @param {ConfigArray} config The config of the file.
* @returns {Object|null} The rebuilt lint results, or null if the file is
* changed or not in the filesystem.
* changed or not in the filesystem.
*/
getCachedLintResults(filePath, config) {

Expand Down
4 changes: 2 additions & 2 deletions lib/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,8 @@ function quietFixPredicate(message) {
/**
* Translates the CLI options into the options expected by the ESLint constructor.
* @param {ParsedCLIOptions} cliOptions The CLI options to translate.
* @param {"flat"|"eslintrc"} [configType="eslintrc"] The format of the
* config to generate.
* @param {"flat"|"eslintrc"} [configType] The format of the
* config to generate.
* @returns {Promise<ESLintOptions>} The options object for the ESLint constructor.
* @private
*/
Expand Down
6 changes: 3 additions & 3 deletions lib/config/flat-config-array.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ const ruleValidator = new RuleValidator();
* Splits a plugin identifier in the form a/b/c into two parts: a/b and c.
* @param {string} identifier The identifier to parse.
* @returns {{objectName: string, pluginName: string}} The parts of the plugin
* name.
* name.
*/
function splitPluginIdentifier(identifier) {
const parts = identifier.split("/");
Expand All @@ -40,7 +40,7 @@ function splitPluginIdentifier(identifier) {
* Returns the name of an object in the config by reading its `meta` key.
* @param {Object} object The object to check.
* @returns {string?} The name of the object if found or `null` if there
* is no name.
* is no name.
*/
function getObjectId(object) {

Expand Down Expand Up @@ -90,7 +90,7 @@ class FlatConfigArray extends ConfigArray {
* Creates a new instance.
* @param {*[]} configs An array of configuration information.
* @param {{basePath: string, shouldIgnore: boolean, baseConfig: FlatConfig}} options The options
* to use for the config array instance.
* to use for the config array instance.
*/
constructor(configs, {
basePath,
Expand Down
4 changes: 2 additions & 2 deletions lib/config/flat-config-helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
* Parses a ruleId into its plugin and rule parts.
* @param {string} ruleId The rule ID to parse.
* @returns {{pluginName:string,ruleName:string}} The plugin and rule
* parts of the ruleId;
* parts of the ruleId;
*/
function parseRuleId(ruleId) {
let pluginName, ruleName;
Expand Down Expand Up @@ -45,7 +45,7 @@ function parseRuleId(ruleId) {
* @param {string} ruleId The rule ID to look for.
* @param {FlatConfig} config The config to search.
* @returns {import("../shared/types").Rule|undefined} The rule if found
* or undefined if not.
* or undefined if not.
*/
function getRuleFromConfig(ruleId, config) {

Expand Down
4 changes: 2 additions & 2 deletions lib/config/flat-config-schema.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@
/**
* @typedef ObjectPropertySchema
* @property {Function|string} merge The function or name of the function to call
* to merge multiple objects with this property.
* to merge multiple objects with this property.
* @property {Function|string} validate The function or name of the function to call
* to validate the value of this property.
* to validate the value of this property.
*/

//-----------------------------------------------------------------------------
Expand Down
2 changes: 1 addition & 1 deletion lib/config/rule-validator.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ class RuleValidator {
* Validates all of the rule configurations in a config against each
* rule's schema.
* @param {Object} config The full config to validate. This object must
* contain both the rules section and the plugins section.
* contain both the rules section and the plugins section.
* @returns {void}
* @throws {Error} If a rule's configuration does not match its schema.
*/
Expand Down
36 changes: 18 additions & 18 deletions lib/eslint/eslint-helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ const MINIMATCH_OPTIONS = { dot: true };
* @typedef {Object} GlobSearch
* @property {Array<string>} patterns The normalized patterns to use for a search.
* @property {Array<string>} rawPatterns The patterns as entered by the user
* before doing any normalization.
* before doing any normalization.
*/

//-----------------------------------------------------------------------------
Expand Down Expand Up @@ -68,11 +68,11 @@ class UnmatchedSearchPatternsError extends Error {
* @param {Object} options The options for the error.
* @param {string} options.basePath The directory that was searched.
* @param {Array<string>} options.unmatchedPatterns The glob patterns
* which were not found.
* which were not found.
* @param {Array<string>} options.patterns The glob patterns that were
* searched.
* searched.
* @param {Array<string>} options.rawPatterns The raw glob patterns that
* were searched.
* were searched.
*/
constructor({ basePath, unmatchedPatterns, patterns, rawPatterns }) {
super(`No files matching '${rawPatterns}' in '${basePath}' were found.`);
Expand Down Expand Up @@ -214,15 +214,15 @@ function globMatch({ basePath, pattern }) {
* @param {Object} options The options for this function.
* @param {string} options.basePath The directory to search.
* @param {Array<string>} options.patterns An array of glob patterns
* to match.
* to match.
* @param {Array<string>} options.rawPatterns An array of glob patterns
* as the user inputted them. Used for errors.
* as the user inputted them. Used for errors.
* @param {FlatConfigArray} options.configs The config array to use for
* determining what to ignore.
* determining what to ignore.
* @param {boolean} options.errorOnUnmatchedPattern Determines if an error
* should be thrown when a pattern is unmatched.
* should be thrown when a pattern is unmatched.
* @returns {Promise<Array<string>>} An array of matching file paths
* or an empty array if there are no matches.
* or an empty array if there are no matches.
* @throws {UnmatchedSearchPatternsError} If there is a pattern that doesn't
* match any files.
*/
Expand Down Expand Up @@ -343,11 +343,11 @@ async function globSearch({
* @param {Object} options The options for this function.
* @param {string} options.basePath The directory to search.
* @param {Array<string>} options.patterns An array of glob patterns
* that were used in the original search.
* that were used in the original search.
* @param {Array<string>} options.rawPatterns An array of glob patterns
* as the user inputted them. Used for errors.
* as the user inputted them. Used for errors.
* @param {Array<string>} options.unmatchedPatterns A non-empty array of glob patterns
* that were unmatched in the original search.
* that were unmatched in the original search.
* @returns {void} Always throws an error.
* @throws {NoFilesFoundError} If the first unmatched pattern
* doesn't match any files even when there are no ignores.
Expand Down Expand Up @@ -381,13 +381,13 @@ async function throwErrorForUnmatchedPatterns({
* Performs multiple glob searches in parallel.
* @param {Object} options The options for this function.
* @param {Map<string,GlobSearch>} options.searches
* An array of glob patterns to match.
* An array of glob patterns to match.
* @param {FlatConfigArray} options.configs The config array to use for
* determining what to ignore.
* determining what to ignore.
* @param {boolean} options.errorOnUnmatchedPattern Determines if an
* unmatched glob pattern should throw an error.
* unmatched glob pattern should throw an error.
* @returns {Promise<Array<string>>} An array of matching file paths
* or an empty array if there are no matches.
* or an empty array if there are no matches.
*/
async function globMultiSearch({ searches, configs, errorOnUnmatchedPattern }) {

Expand Down Expand Up @@ -459,11 +459,11 @@ async function globMultiSearch({ searches, configs, errorOnUnmatchedPattern }) {
* @param {Object} args The arguments objects.
* @param {Array<string>} args.patterns An array of glob patterns.
* @param {boolean} args.globInputPaths true to interpret glob patterns,
* false to not interpret glob patterns.
* false to not interpret glob patterns.
* @param {string} args.cwd The current working directory to find from.
* @param {FlatConfigArray} args.configs The configs for the current run.
* @param {boolean} args.errorOnUnmatchedPattern Determines if an unmatched pattern
* should throw an error.
* should throw an error.
* @returns {Promise<Array<string>>} The fully resolved file paths.
* @throws {AllFilesIgnoredError} If there are no results due to an ignore pattern.
* @throws {NoFilesFoundError} If no files matched the given patterns.
Expand Down
6 changes: 3 additions & 3 deletions lib/eslint/eslint.js
Original file line number Diff line number Diff line change
Expand Up @@ -601,9 +601,9 @@ class ESLint {
* - `undefined` ... Load `stylish` builtin formatter.
* - A builtin formatter name ... Load the builtin formatter.
* - A third-party formatter name:
* - `foo` → `eslint-formatter-foo`
* - `@foo` → `@foo/eslint-formatter`
* - `@foo/bar` → `@foo/eslint-formatter-bar`
* - `foo` → `eslint-formatter-foo`
* - `@foo` → `@foo/eslint-formatter`
* - `@foo/bar` → `@foo/eslint-formatter-bar`
* - A file path ... Load the file.
* @returns {Promise<LoadedFormatter>} A promise resolving to the formatter object.
* This promise will be rejected if the given formatter was not found or not
Expand Down
16 changes: 8 additions & 8 deletions lib/eslint/flat-eslint.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,8 @@ const LintResultCache = require("../cli-engine/lint-result-cache");
* @property {string[]} [ignorePatterns] Ignore file patterns to use in addition to config ignores. These patterns are relative to `cwd`.
* @property {ConfigData} [overrideConfig] Override config object, overrides all configs used with this instance
* @property {boolean|string} [overrideConfigFile] 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.
* doesn't do any config file lookup when `true`; considered to be a config filename
* when a string.
* @property {Record<string,Plugin>} [plugins] An array of plugin implementations.
* @property {"error" | "warn" | "off"} [reportUnusedDisableDirectives] the severity to report unused eslint-disable directives.
*/
Expand Down Expand Up @@ -328,7 +328,7 @@ async function loadFlatConfigFile(filePath) {
* upwards from the cwd for a file named `eslint.config.js`.
* @param {import("./eslint").ESLintOptions} options The ESLint instance options.
* @returns {{configFilePath:string|undefined,basePath:string,error:Error|null}} Location information for
* the config file.
* the config file.
*/
async function locateConfigFileToUse({ configFile, cwd }) {

Expand Down Expand Up @@ -1075,9 +1075,9 @@ class FlatESLint {
* - `undefined` ... Load `stylish` builtin formatter.
* - A builtin formatter name ... Load the builtin formatter.
* - A third-party formatter name:
* - `foo` → `eslint-formatter-foo`
* - `@foo` → `@foo/eslint-formatter`
* - `@foo/bar` → `@foo/eslint-formatter-bar`
* - `foo` → `eslint-formatter-foo`
* - `@foo` → `@foo/eslint-formatter`
* - `@foo/bar` → `@foo/eslint-formatter-bar`
* - A file path ... Load the file.
* @returns {Promise<Formatter>} A promise resolving to the formatter object.
* This promise will be rejected if the given formatter was not found or not
Expand Down Expand Up @@ -1169,7 +1169,7 @@ class FlatESLint {
* configuration for each file it processes.
* @param {string} filePath The path of the file to retrieve a config object for.
* @returns {Promise<ConfigData|undefined>} A configuration object for the file
* or `undefined` if there is no configuration data for the object.
* or `undefined` if there is no configuration data for the object.
*/
async calculateConfigForFile(filePath) {
if (!isNonEmptyString(filePath)) {
Expand All @@ -1186,7 +1186,7 @@ class FlatESLint {
* Finds the config file being used by this instance based on the options
* passed to the constructor.
* @returns {string|undefined} The path to the config file being used or
* `undefined` if no config file is being used.
* `undefined` if no config file is being used.
*/
async findConfigFile() {
const options = privateMembers.get(this).options;
Expand Down
4 changes: 2 additions & 2 deletions lib/linter/code-path-analysis/code-path-analyzer.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ function isCaseNode(node) {
* Checks if a given node appears as the value of a PropertyDefinition node.
* @param {ASTNode} node THe node to check.
* @returns {boolean} `true` if the node is a PropertyDefinition value,
* false if not.
* false if not.
*/
function isPropertyDefinitionValue(node) {
const parent = node.parent;
Expand Down Expand Up @@ -110,7 +110,7 @@ function isForkingByTrueOrFalse(node) {
* have any `break` statement.
* @param {ASTNode} node A node to get.
* @returns {boolean|undefined} a boolean value if the node is a Literal node,
* otherwise `undefined`.
* otherwise `undefined`.
*/
function getBooleanValueIfSimpleConstant(node) {
if (node.type === "Literal") {
Expand Down
2 changes: 1 addition & 1 deletion lib/linter/code-path-analysis/code-path-segment.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class CodePathSegment {
/**
* @param {string} id An identifier.
* @param {CodePathSegment[]} allPrevSegments An array of the previous segments.
* This array includes unreachable segments.
* This array includes unreachable segments.
* @param {boolean} reachable A flag which shows this is reachable.
*/
constructor(id, allPrevSegments, reachable) {
Expand Down
22 changes: 11 additions & 11 deletions lib/linter/code-path-analysis/code-path-state.js
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ class CodePathState {

/**
* @param {IdGenerator} idGenerator An id generator to generate id for code
* path segments.
* path segments.
* @param {Function} onLooped A callback function to notify looping.
*/
constructor(idGenerator, onLooped) {
Expand Down Expand Up @@ -269,7 +269,7 @@ class CodePathState {
/**
* Creates and stacks new forking context.
* @param {boolean} forkLeavingPath A flag which shows being in a
* "finally" block.
* "finally" block.
* @returns {ForkContext} The created context.
*/
pushForkContext(forkLeavingPath) {
Expand Down Expand Up @@ -338,11 +338,11 @@ class CodePathState {
* a -> b -> foo();
* a -> b -> bar();
* @param {string} kind A kind string.
* If the new context is LogicalExpression's or AssignmentExpression's, this is `"&&"` or `"||"` or `"??"`.
* If it's IfStatement's or ConditionalExpression's, this is `"test"`.
* Otherwise, this is `"loop"`.
* If the new context is LogicalExpression's or AssignmentExpression's, this is `"&&"` or `"||"` or `"??"`.
* If it's IfStatement's or ConditionalExpression's, this is `"test"`.
* Otherwise, this is `"loop"`.
* @param {boolean} isForkingAsResult A flag that shows that goes different
* paths between `true` and `false`.
* paths between `true` and `false`.
* @returns {void}
*/
pushChoiceContext(kind, isForkingAsResult) {
Expand Down Expand Up @@ -622,7 +622,7 @@ class CodePathState {
/**
* Creates a context object of SwitchStatement and stacks it.
* @param {boolean} hasCase `true` if the switch statement has one or more
* case parts.
* case parts.
* @param {string|null} label The label text.
* @returns {void}
*/
Expand Down Expand Up @@ -771,7 +771,7 @@ class CodePathState {
/**
* Creates a context object of TryStatement and stacks it.
* @param {boolean} hasFinalizer `true` if the try statement has a
* `finally` block.
* `finally` block.
* @returns {void}
*/
pushTryContext(hasFinalizer) {
Expand Down Expand Up @@ -963,8 +963,8 @@ class CodePathState {
/**
* Creates a context object of a loop statement and stacks it.
* @param {string} type The type of the node which was triggered. One of
* `WhileStatement`, `DoWhileStatement`, `ForStatement`, `ForInStatement`,
* and `ForStatement`.
* `WhileStatement`, `DoWhileStatement`, `ForStatement`, `ForInStatement`,
* and `ForStatement`.
* @param {string|null} label A label of the node which was triggered.
* @throws {Error} (Unreachable - unknown type.)
* @returns {void}
Expand Down Expand Up @@ -1338,7 +1338,7 @@ class CodePathState {
/**
* Creates new context for BreakStatement.
* @param {boolean} breakable The flag to indicate it can break by
* an unlabeled BreakStatement.
* an unlabeled BreakStatement.
* @param {string|null} label The label of this context.
* @returns {Object} The new context.
*/
Expand Down

0 comments on commit 2a13d2c

Please sign in to comment.