Skip to content
Permalink
Browse files
Chore: Enforce jsdoc check-line-alignment never (#14955)
  • Loading branch information
brettz9 committed Aug 24, 2021
1 parent a8bcef7 commit a79c9f35d665c2bcc63267bdf359a8176e0a84ce
Show file tree
Hide file tree
Showing 27 changed files with 112 additions and 112 deletions.
@@ -149,8 +149,8 @@ function generateBlogPost(releaseInfo, prereleaseMajorVersion) {

/**
* Generates a doc page with formatter result examples
* @param {Object} formatterInfo Linting results from each formatter
* @param {string} [prereleaseVersion] The version used for a prerelease. This
* @param {Object} formatterInfo Linting results from each formatter
* @param {string} [prereleaseVersion] The version used for a prerelease. This
* changes where the output is stored.
* @returns {void}
*/
@@ -280,7 +280,7 @@ function verifyText({
/**
* Returns result with warning by ignore settings
* @param {string} filePath File path of checked code
* @param {string} baseDir Absolute path of base directory
* @param {string} baseDir Absolute path of base directory
* @returns {LintResult} Result with single warning
* @private
*/
@@ -21,8 +21,8 @@ const murmur = require("imurmurhash");

/**
* hash the given string
* @param {string} str the string to hash
* @returns {string} the hash
* @param {string} str the string to hash
* @returns {string} the hash
*/
function hash(str) {
return murmur(str).result().toString(36);
@@ -36,9 +36,9 @@ const MAX_CONFIG_COMBINATIONS = 17, // 16 combinations + 1 for severity only
/**
* Information about a rule configuration, in the context of a Registry.
* @typedef {Object} registryItem
* @property {ruleConfig} config A valid configuration for the rule
* @property {number} specificity The number of elements in the ruleConfig array
* @property {number} errorCount The number of errors encountered when linting with the config
* @property {ruleConfig} config A valid configuration for the rule
* @property {number} specificity The number of elements in the ruleConfig array
* @property {number} errorCount The number of errors encountered when linting with the config
*/

/**
@@ -49,8 +49,8 @@ const MAX_CONFIG_COMBINATIONS = 17, // 16 combinations + 1 for severity only

/**
* Create registryItems for rules
* @param {rulesConfig} rulesConfig Hash of rule names and arrays of ruleConfig items
* @returns {Object} registryItems for each rule in provided rulesConfig
* @param {rulesConfig} rulesConfig Hash of rule names and arrays of ruleConfig items
* @returns {Object} registryItems for each rule in provided rulesConfig
*/
function makeRegistryItems(rulesConfig) {
return Object.keys(rulesConfig).reduce((accumulator, ruleId) => {
@@ -103,7 +103,7 @@ class Registry {
* configurations.
*
* The length of the returned array will be <= MAX_CONFIG_COMBINATIONS.
* @returns {Object[]} "rules" configurations to use for linting
* @returns {Object[]} "rules" configurations to use for linting
*/
buildRuleSets() {
let idx = 0;
@@ -115,7 +115,7 @@ class Registry {
*
* This is broken out into its own function so that it doesn't need to be
* created inside of the while loop.
* @param {string} rule The ruleId to add.
* @param {string} rule The ruleId to add.
* @returns {void}
*/
const addRuleToRuleSet = function(rule) {
@@ -202,7 +202,7 @@ class Registry {
* Creates a registry of rules which had no error-free configs.
* The new registry is intended to be analyzed to determine whether its rules
* should be disabled or set to warning.
* @returns {Registry} A registry of failing rules.
* @returns {Registry} A registry of failing rules.
*/
getFailingRulesRegistry() {
const ruleIds = Object.keys(this.rules),
@@ -239,8 +239,8 @@ class Registry {

/**
* Return a cloned registry containing only configs with a desired specificity
* @param {number} specificity Only keep configs with this specificity
* @returns {Registry} A registry of rules
* @param {number} specificity Only keep configs with this specificity
* @returns {Registry} A registry of rules
*/
filterBySpecificity(specificity) {
const ruleIds = Object.keys(this.rules),
@@ -256,10 +256,10 @@ class Registry {

/**
* Lint SourceCodes against all configurations in the registry, and record results
* @param {Object[]} sourceCodes SourceCode objects for each filename
* @param {Object} config ESLint config object
* @param {progressCallback} [cb] Optional callback for reporting execution status
* @returns {Registry} New registry with errorCount populated
* @param {Object[]} sourceCodes SourceCode objects for each filename
* @param {Object} config ESLint config object
* @param {progressCallback} [cb] Optional callback for reporting execution status
* @returns {Registry} New registry with errorCount populated
*/
lintSourceCode(sourceCodes, config, cb) {
let lintedRegistry = new Registry();
@@ -321,8 +321,8 @@ class Registry {
*
* This will return a new config with `["extends": [ ..., "eslint:recommended"]` and
* only the rules which have configurations different from the recommended config.
* @param {Object} config config object
* @returns {Object} config object using `"extends": ["eslint:recommended"]`
* @param {Object} config config object
* @returns {Object} config object using `"extends": ["eslint:recommended"]`
*/
function extendFromRecommended(config) {
const newConfig = Object.assign({}, config);
@@ -23,9 +23,9 @@ const debug = require("debug")("eslint:config-file");
* Determines sort order for object keys for json-stable-stringify
*
* see: https://github.com/samn/json-stable-stringify#cmp
* @param {Object} a The first comparison object ({key: akey, value: avalue})
* @param {Object} b The second comparison object ({key: bkey, value: bvalue})
* @returns {number} 1 or -1, used in stringify cmp method
* @param {Object} a The first comparison object ({key: akey, value: avalue})
* @param {Object} b The second comparison object ({key: bkey, value: bvalue})
* @returns {number} 1 or -1, used in stringify cmp method
*/
function sortByKey(a, b) {
return a.key > b.key ? 1 : -1;
@@ -102,8 +102,8 @@ getPeerDependencies.cache = new Map();

/**
* Return necessary plugins, configs, parsers, etc. based on the config
* @param {Object} config config object
* @param {boolean} [installESLint=true] If `false` is given, it does not install eslint.
* @param {Object} config config object
* @param {boolean} [installESLint=true] If `false` is given, it does not install eslint.
* @returns {string[]} An array of modules to be installed.
*/
function getModulesList(config, installESLint) {
@@ -161,10 +161,10 @@ function getModulesList(config, installESLint) {
*
* Note: This clones the config object and returns a new config to avoid mutating
* the original config parameter.
* @param {Object} answers answers received from enquirer
* @param {Object} config config object
* @param {Object} answers answers received from enquirer
* @param {Object} config config object
* @throws {Error} If source code retrieval fails or source code file count is 0.
* @returns {Object} config object with configured rules
* @returns {Object} config object with configured rules
*/
function configureRules(answers, config) {
const BAR_TOTAL = 20,
@@ -416,7 +416,7 @@ function hasESLintVersionConflict(answers) {

/**
* Install modules.
* @param {string[]} modules Modules to be installed.
* @param {string[]} modules Modules to be installed.
* @returns {void}
*/
function installModules(modules) {
@@ -427,8 +427,8 @@ function installModules(modules) {
/* istanbul ignore next: no need to test enquirer */
/**
* Ask user to install modules.
* @param {string[]} modules Array of modules to be installed.
* @param {boolean} packageJsonExists Indicates if package.json is existed.
* @param {string[]} modules Array of modules to be installed.
* @param {boolean} packageJsonExists Indicates if package.json is existed.
* @returns {Promise<void>} Answer that indicates if user wants to install.
*/
function askInstallModules(modules, packageJsonExists) {
@@ -17,8 +17,8 @@ const builtInRules = require("../rules");

/**
* Wrap all of the elements of an array into arrays.
* @param {*[]} xs Any array.
* @returns {Array[]} An array of arrays.
* @param {*[]} xs Any array.
* @returns {Array[]} An array of arrays.
*/
function explodeArray(xs) {
return xs.reduce((accumulator, x) => {
@@ -33,9 +33,9 @@ function explodeArray(xs) {
*
* For example:
* combineArrays([a, [b, c]], [x, y]); // -> [[a, x], [a, y], [b, c, x], [b, c, y]]
* @param {Array} arr1 The first array to combine.
* @param {Array} arr2 The second array to combine.
* @returns {Array} A mixture of the elements of the first and second arrays.
* @param {Array} arr1 The first array to combine.
* @param {Array} arr2 The second array to combine.
* @returns {Array} A mixture of the elements of the first and second arrays.
*/
function combineArrays(arr1, arr2) {
const res = [];
@@ -70,8 +70,8 @@ function combineArrays(arr1, arr2) {
* [{before: true}, {before: false}],
* [{after: true}, {after: false}]
* ]
* @param {Object[]} objects Array of objects, each with one property/value pair
* @returns {Array[]} Array of arrays of objects grouped by property
* @param {Object[]} objects Array of objects, each with one property/value pair
* @returns {Array[]} Array of arrays of objects grouped by property
*/
function groupByProperty(objects) {
const groupedObj = objects.reduce((accumulator, obj) => {
@@ -97,7 +97,7 @@ function groupByProperty(objects) {
* Configs may also have one or more additional elements to specify rule
* configuration or options.
* @typedef {Array|number} ruleConfig
* @param {number} 0 The rule's severity (0, 1, 2).
* @param {number} 0 The rule's severity (0, 1, 2).
*/

/**
@@ -131,9 +131,9 @@ function groupByProperty(objects) {
* {before: false, after: true},
* {before: false, after: false}
* ]
* @param {Object[]} objArr1 Single key/value objects, all with the same key
* @param {Object[]} objArr2 Single key/value objects, all with another key
* @returns {Object[]} Combined objects for each combination of input properties and values
* @param {Object[]} objArr1 Single key/value objects, all with the same key
* @param {Object[]} objArr2 Single key/value objects, all with another key
* @returns {Object[]} Combined objects for each combination of input properties and values
*/
function combinePropertyObjects(objArr1, objArr2) {
const res = [];
@@ -205,7 +205,7 @@ class RuleConfigSet {

/**
* Add rule configs from an array of strings (schema enums)
* @param {string[]} enums Array of valid rule options (e.g. ["always", "never"])
* @param {string[]} enums Array of valid rule options (e.g. ["always", "never"])
* @returns {void}
*/
addEnums(enums) {
@@ -214,7 +214,7 @@ class RuleConfigSet {

/**
* Add rule configurations from a schema object
* @param {Object} obj Schema item with type === "object"
* @param {Object} obj Schema item with type === "object"
* @returns {boolean} true if at least one schema for the object could be generated, false otherwise
*/
addObject(obj) {
@@ -259,8 +259,8 @@ class RuleConfigSet {

/**
* Generate valid rule configurations based on a schema object
* @param {Object} schema A rule's schema object
* @returns {Array[]} Valid rule configurations
* @param {Object} schema A rule's schema object
* @returns {Array[]} Valid rule configurations
*/
function generateConfigsFromSchema(schema) {
const configSet = new RuleConfigSet();
@@ -21,8 +21,8 @@ const fs = require("fs"),
/**
* Find the closest package.json file, starting at process.cwd (by default),
* and working up to root.
* @param {string} [startDir=process.cwd()] Starting directory
* @returns {string} Absolute path to closest package.json file
* @param {string} [startDir=process.cwd()] Starting directory
* @returns {string} Absolute path to closest package.json file
*/
function findPackageJson(startDir) {
let dir = path.resolve(startDir || process.cwd());
@@ -45,7 +45,7 @@ function findPackageJson(startDir) {

/**
* Install node modules synchronously and save to devDependencies in package.json
* @param {string|string[]} packages Node module or modules to install
* @param {string|string[]} packages Node module or modules to install
* @returns {void}
*/
function installSyncSaveDev(packages) {
@@ -86,13 +86,13 @@ function fetchPeerDependencies(packageName) {

/**
* Check whether node modules are include in a project's package.json.
* @param {string[]} packages Array of node module names
* @param {Object} opt Options Object
* @param {boolean} opt.dependencies Set to true to check for direct dependencies
* @param {boolean} opt.devDependencies Set to true to check for development dependencies
* @param {boolean} opt.startdir Directory to begin searching from
* @param {string[]} packages Array of node module names
* @param {Object} opt Options Object
* @param {boolean} opt.dependencies Set to true to check for direct dependencies
* @param {boolean} opt.devDependencies Set to true to check for development dependencies
* @param {boolean} opt.startdir Directory to begin searching from
* @throws {Error} If cannot find valid `package.json` file.
* @returns {Object} An object whose keys are the module names
* @returns {Object} An object whose keys are the module names
* and values are booleans indicating installation.
*/
function check(packages, opt) {
@@ -134,9 +134,9 @@ function check(packages, opt) {
* package.json.
*
* Convenience wrapper around check().
* @param {string[]} packages Array of node modules to check.
* @param {string} rootDir The directory containing a package.json
* @returns {Object} An object whose keys are the module names
* @param {string[]} packages Array of node modules to check.
* @param {string} rootDir The directory containing a package.json
* @returns {Object} An object whose keys are the module names
* and values are booleans indicating installation.
*/
function checkDeps(packages, rootDir) {
@@ -148,8 +148,8 @@ function checkDeps(packages, rootDir) {
* package.json.
*
* Convenience wrapper around check().
* @param {string[]} packages Array of node modules to check.
* @returns {Object} An object whose keys are the module names
* @param {string[]} packages Array of node modules to check.
* @returns {Object} An object whose keys are the module names
* and values are booleans indicating installation.
*/
function checkDevDeps(packages) {
@@ -158,7 +158,7 @@ function checkDevDeps(packages) {

/**
* Check whether package.json is found in current path.
* @param {string} [startDir] Starting directory
* @param {string} [startDir] Starting directory
* @returns {boolean} Whether a package.json is found in current path.
*/
function checkPackageJson(startDir) {
@@ -33,10 +33,10 @@ const debug = require("debug")("eslint:source-code-utils");

/**
* Get the SourceCode object for a single file
* @param {string} filename The fully resolved filename to get SourceCode from.
* @param {Object} engine A CLIEngine.
* @param {string} filename The fully resolved filename to get SourceCode from.
* @param {Object} engine A CLIEngine.
* @throws {Error} Upon fatal errors from execution.
* @returns {Array} Array of the SourceCode object representing the file
* @returns {Array} Array of the SourceCode object representing the file
* and fatal error message.
*/
function getSourceCodeOfFile(filename, engine) {
@@ -1067,7 +1067,7 @@ class Linter {
/**
* Initialize the Linter.
* @param {Object} [config] the config object
* @param {string} [config.cwd] path to a directory that should be considered as the current working directory, can be undefined.
* @param {string} [config.cwd] path to a directory that should be considered as the current working directory, can be undefined.
*/
constructor({ cwd } = {}) {
internalSlotsMap.set(this, {
@@ -80,8 +80,8 @@ SourceCodeFixer.applyFixes = function(sourceText, messages, shouldFix) {

/**
* Try to use the 'fix' from a problem.
* @param {Message} problem The message object to apply fixes from
* @returns {boolean} Whether fix was successfully applied
* @param {Message} problem The message object to apply fixes from
* @returns {boolean} Whether fix was successfully applied
*/
function attemptFix(problem) {
const fix = problem.fix;
@@ -47,7 +47,7 @@ module.exports = {
* Reports that a variable declarator or assignment expression is assigning
* a non-'this' value to the specified alias.
* @param {ASTNode} node The assigning node.
* @param {string} name the name of the alias that was incorrectly used.
* @param {string} name the name of the alias that was incorrectly used.
* @returns {void}
*/
function reportBadAssignment(node, name) {
@@ -50,7 +50,7 @@ module.exports = {

/**
* Shortcut to get last element of array
* @param {*[]} collection Array
* @param {*[]} collection Array
* @returns {any} Last element
*/
function last(collection) {
@@ -78,7 +78,7 @@ module.exports = {

/**
* Checks if an expression is a typeof expression
* @param {ASTNode} node The node to check
* @param {ASTNode} node The node to check
* @returns {boolean} if the node is a typeof expression
*/
function isTypeOf(node) {

0 comments on commit a79c9f3

Please sign in to comment.