Skip to content

Commit

Permalink
Chore: Apply comment require-description and check ClassDeclaration (#…
Browse files Browse the repository at this point in the history
…14949)

* Chore: Apply comment require-description and check ClassDeclaration's

* Update Makefile.js

Co-authored-by: Bryan Mishkin <698306+bmish@users.noreply.github.com>

* Fix: Avoid eslintrc for tests to avoid requiring comment description

Co-authored-by: Bryan Mishkin <698306+bmish@users.noreply.github.com>
  • Loading branch information
brettz9 and bmish committed Aug 21, 2021
1 parent 8344675 commit 9a4ae3b
Show file tree
Hide file tree
Showing 64 changed files with 145 additions and 143 deletions.
4 changes: 2 additions & 2 deletions Makefile.js
Expand Up @@ -3,8 +3,8 @@
* @author nzakas
*/

/* global target */
/* eslint no-use-before-define: "off", no-console: "off" */
/* global target -- TODO: figure out where this is coming from and update this description */
/* eslint no-use-before-define: "off", no-console: "off" -- CLI */
"use strict";

//------------------------------------------------------------------------------
Expand Down
2 changes: 1 addition & 1 deletion bin/eslint.js
Expand Up @@ -5,7 +5,7 @@
* @author Nicholas C. Zakas
*/

/* eslint no-console:off */
/* eslint no-console:off -- CLI */

"use strict";

Expand Down
2 changes: 1 addition & 1 deletion conf/eslint-recommended.js
Expand Up @@ -6,7 +6,7 @@

"use strict";

/* eslint sort-keys: ["error", "asc"] */
/* eslint sort-keys: ["error", "asc"] -- Long, so make more readable */

/** @type {import("../lib/shared/types").ConfigData} */
module.exports = {
Expand Down
3 changes: 3 additions & 0 deletions lib/cli-engine/cli-engine.js
Expand Up @@ -562,6 +562,9 @@ function directoryExists(resolvedPath) {
// Public Interface
//------------------------------------------------------------------------------

/**
* Core CLI.
*/
class CLIEngine {

/**
Expand Down
2 changes: 0 additions & 2 deletions lib/cli-engine/file-enumerator.js
Expand Up @@ -175,7 +175,6 @@ function createExtensionRegExp(extensions) {
*/
class NoFilesFoundError extends Error {

// eslint-disable-next-line jsdoc/require-description
/**
* @param {string} pattern The glob pattern which was not found.
* @param {boolean} globDisabled If `true` then the pattern was a glob pattern, but glob was disabled.
Expand All @@ -192,7 +191,6 @@ class NoFilesFoundError extends Error {
*/
class AllFilesIgnoredError extends Error {

// eslint-disable-next-line jsdoc/require-description
/**
* @param {string} pattern The glob pattern which was not found.
*/
Expand Down
2 changes: 1 addition & 1 deletion lib/cli-engine/formatters/html.js
Expand Up @@ -281,8 +281,8 @@ function resultTemplate(it) {
`.trimLeft();
}

// eslint-disable-next-line jsdoc/require-description
/**
* Render the results.
* @param {Array} results Test results.
* @param {Object} rulesMeta Dictionary containing metadata for each rule executed by the analysis.
* @returns {string} HTML string describing the results.
Expand Down
2 changes: 1 addition & 1 deletion lib/cli-engine/xml-escape.js
Expand Up @@ -15,7 +15,7 @@
* @private
*/
module.exports = function(s) {
return (`${s}`).replace(/[<>&"'\x00-\x1F\x7F\u0080-\uFFFF]/gu, c => { // eslint-disable-line no-control-regex
return (`${s}`).replace(/[<>&"'\x00-\x1F\x7F\u0080-\uFFFF]/gu, c => { // eslint-disable-line no-control-regex -- Converting controls to entities
switch (c) {
case "<":
return "&lt;";
Expand Down
4 changes: 2 additions & 2 deletions lib/config/flat-config-array.js
Expand Up @@ -61,7 +61,7 @@ class FlatConfigArray extends ConfigArray {
this.unshift(baseConfig);
}

/* eslint-disable class-methods-use-this */
/* eslint-disable class-methods-use-this -- Desired as instance method */
/**
* Replaces a config with another config to allow us to put strings
* in the config array that will be replaced by objects before
Expand Down Expand Up @@ -118,7 +118,7 @@ class FlatConfigArray extends ConfigArray {

return config;
}
/* eslint-enable class-methods-use-this */
/* eslint-enable class-methods-use-this -- Desired as instance method */

}

Expand Down
2 changes: 1 addition & 1 deletion lib/config/flat-config-schema.js
Expand Up @@ -336,7 +336,7 @@ const rulesSchema = {
// avoid hairy edge case
if (ruleId === "__proto__") {

/* eslint-disable-next-line no-proto */
/* eslint-disable-next-line no-proto -- Though deprecated, may still be present */
delete result.__proto__;
continue;
}
Expand Down
3 changes: 3 additions & 0 deletions lib/eslint/eslint.js
Expand Up @@ -422,6 +422,9 @@ function compareResultsByFilePath(a, b) {
return 0;
}

/**
* Main API.
*/
class ESLint {

/**
Expand Down
3 changes: 1 addition & 2 deletions lib/init/autoconfig.js
Expand Up @@ -73,7 +73,6 @@ function makeRegistryItems(rulesConfig) {
*/
class Registry {

// eslint-disable-next-line jsdoc/require-description
/**
* @param {rulesConfig} [rulesConfig] Hash of rule names and arrays of possible configurations
*/
Expand Down Expand Up @@ -305,7 +304,7 @@ class Registry {
ruleSetIdx += 1;

if (cb) {
cb(totalFilesLinting); // eslint-disable-line node/callback-return
cb(totalFilesLinting); // eslint-disable-line node/callback-return -- End of function
}
});

Expand Down
1 change: 0 additions & 1 deletion lib/init/config-rule.js
Expand Up @@ -174,7 +174,6 @@ function combinePropertyObjects(objArr1, objArr2) {
*/
class RuleConfigSet {

// eslint-disable-next-line jsdoc/require-description
/**
* @param {ruleConfig[]} configs Valid rule configurations
*/
Expand Down
4 changes: 2 additions & 2 deletions lib/init/source-code-utils.js
Expand Up @@ -23,7 +23,7 @@ const { CLIEngine } = require("../cli-engine");
* TODO1: Expose the API that enumerates target files.
* TODO2: Extract the creation logic of `SourceCode` from `Linter` class.
*/
const { getCLIEngineInternalSlots } = require("../cli-engine/cli-engine"); // eslint-disable-line node/no-restricted-require
const { getCLIEngineInternalSlots } = require("../cli-engine/cli-engine"); // eslint-disable-line node/no-restricted-require -- Todo

const debug = require("debug")("eslint:source-code-utils");

Expand Down Expand Up @@ -98,7 +98,7 @@ function getSourceCodeOfFiles(patterns, options, callback) {
sourceCodes[filename] = sourceCode;
}
if (callback) {
callback(filenames.length); // eslint-disable-line node/callback-return
callback(filenames.length); // eslint-disable-line node/callback-return -- End of function
}
});

Expand Down
1 change: 0 additions & 1 deletion lib/linter/code-path-analysis/code-path-analyzer.js
Expand Up @@ -674,7 +674,6 @@ function postprocess(analyzer, node) {
*/
class CodePathAnalyzer {

// eslint-disable-next-line jsdoc/require-description
/**
* @param {EventGenerator} eventGenerator An event generator to wrap.
*/
Expand Down
1 change: 0 additions & 1 deletion lib/linter/code-path-analysis/code-path-segment.js
Expand Up @@ -33,7 +33,6 @@ function isReachable(segment) {
*/
class CodePathSegment {

// eslint-disable-next-line jsdoc/require-description
/**
* @param {string} id An identifier.
* @param {CodePathSegment[]} allPrevSegments An array of the previous segments.
Expand Down
1 change: 0 additions & 1 deletion lib/linter/code-path-analysis/code-path-state.js
Expand Up @@ -219,7 +219,6 @@ function finalizeTestSegmentsOfFor(context, choiceContext, head) {
*/
class CodePathState {

// eslint-disable-next-line jsdoc/require-description
/**
* @param {IdGenerator} idGenerator An id generator to generate id for code
* path segments.
Expand Down
1 change: 0 additions & 1 deletion lib/linter/code-path-analysis/code-path.js
Expand Up @@ -21,7 +21,6 @@ const IdGenerator = require("./id-generator");
*/
class CodePath {

// eslint-disable-next-line jsdoc/require-description
/**
* @param {string} id An identifier.
* @param {CodePath|null} upper The code path of the upper function scope.
Expand Down
4 changes: 2 additions & 2 deletions lib/linter/code-path-analysis/debug-helpers.js
Expand Up @@ -21,7 +21,7 @@ const debug = require("debug")("eslint:code-path");
* @returns {string} Id of the segment.
*/
/* istanbul ignore next */
function getId(segment) { // eslint-disable-line jsdoc/require-jsdoc
function getId(segment) { // eslint-disable-line jsdoc/require-jsdoc -- Ignoring
return segment.id + (segment.reachable ? "" : "!");
}

Expand Down Expand Up @@ -115,7 +115,7 @@ module.exports = {
const traceMap = Object.create(null);
const arrows = this.makeDotArrows(codePath, traceMap);

for (const id in traceMap) { // eslint-disable-line guard-for-in
for (const id in traceMap) { // eslint-disable-line guard-for-in -- Want ability to traverse prototype
const segment = traceMap[id];

text += `${id}[`;
Expand Down
1 change: 0 additions & 1 deletion lib/linter/code-path-analysis/fork-context.js
Expand Up @@ -97,7 +97,6 @@ function mergeExtraSegments(context, segments) {
*/
class ForkContext {

// eslint-disable-next-line jsdoc/require-description
/**
* @param {IdGenerator} idGenerator An identifier generator for segments.
* @param {ForkContext|null} upper An upper fork context.
Expand Down
1 change: 0 additions & 1 deletion lib/linter/code-path-analysis/id-generator.js
Expand Up @@ -18,7 +18,6 @@
*/
class IdGenerator {

// eslint-disable-next-line jsdoc/require-description
/**
* @param {string} prefix Optional. A prefix of generated ids.
*/
Expand Down
2 changes: 1 addition & 1 deletion lib/linter/config-comment-parser.js
Expand Up @@ -3,7 +3,7 @@
* @author Nicholas C. Zakas
*/

/* eslint class-methods-use-this: off */
/* eslint class-methods-use-this: off -- Methods desired on instance */
"use strict";

//------------------------------------------------------------------------------
Expand Down
4 changes: 2 additions & 2 deletions lib/linter/linter.js
Expand Up @@ -65,7 +65,7 @@ const parserSymbol = Symbol.for("eslint.RuleTester.parser");
* @template T
* @typedef {{ [P in keyof T]-?: T[P] }} Required
*/
/* eslint-enable jsdoc/valid-types */
/* eslint-enable jsdoc/valid-types -- https://github.com/jsdoc-type-pratt-parser/jsdoc-type-pratt-parser/issues/4#issuecomment-778805577 */

/**
* @typedef {Object} DisableDirective
Expand Down Expand Up @@ -1044,7 +1044,7 @@ function normalizeCwd(cwd) {
}

// It's more explicit to assign the undefined
// eslint-disable-next-line no-undefined
// eslint-disable-next-line no-undefined -- Consistently returning a value
return undefined;
}

Expand Down
1 change: 0 additions & 1 deletion lib/linter/node-event-generator.js
Expand Up @@ -237,7 +237,6 @@ function parseSelector(rawSelector) {
*/
class NodeEventGenerator {

// eslint-disable-next-line jsdoc/require-description
/**
* @param {SafeEmitter} emitter
* An SafeEmitter which is the destination of events. This emitter must already
Expand Down
3 changes: 3 additions & 0 deletions lib/linter/rules.js
Expand Up @@ -30,6 +30,9 @@ function normalizeRule(rule) {
// Public Interface
//------------------------------------------------------------------------------

/**
* A storage for rules.
*/
class Rules {
constructor() {
this._rules = Object.create(null);
Expand Down
2 changes: 1 addition & 1 deletion lib/linter/timing.js
Expand Up @@ -116,7 +116,7 @@ function display(data) {
return ALIGN[index](":", width + extraAlignment, "-");
}).join("|"));

console.log(table.join("\n")); // eslint-disable-line no-console
console.log(table.join("\n")); // eslint-disable-line no-console -- Debugging function
}

/* istanbul ignore next */
Expand Down
9 changes: 6 additions & 3 deletions lib/rule-tester/rule-tester.js
Expand Up @@ -4,7 +4,7 @@
*/
"use strict";

/* global describe, it */
/* eslint-env mocha -- Mocha wrapper */

/*
* This is a wrapper around mocha to allow for DRY unittests for eslint
Expand Down Expand Up @@ -106,7 +106,7 @@ const { SourceCode } = require("../source-code");
* @property {number} [endLine] The 1-based line number of the reported end location.
* @property {number} [endColumn] The 1-based column number of the reported end location.
*/
/* eslint-enable jsdoc/valid-types */
/* eslint-enable jsdoc/valid-types -- https://github.com/jsdoc-type-pratt-parser/jsdoc-type-pratt-parser/issues/4#issuecomment-778805577 */

//------------------------------------------------------------------------------
// Private Members
Expand Down Expand Up @@ -214,7 +214,7 @@ function freezeDeeply(x) {
*/
function sanitize(text) {
return text.replace(
/[\u0000-\u0009\u000b-\u001a]/gu, // eslint-disable-line no-control-regex
/[\u0000-\u0009\u000b-\u001a]/gu, // eslint-disable-line no-control-regex -- Escaping controls
c => `\\u${c.codePointAt(0).toString(16).padStart(4, "0")}`
);
}
Expand Down Expand Up @@ -338,6 +338,9 @@ function describeDefaultHandler(text, method) {
return method.call(this);
}

/**
* Mocha test wrapper.
*/
class RuleTester {

/**
Expand Down
2 changes: 1 addition & 1 deletion lib/rules/default-param-last.js
Expand Up @@ -25,8 +25,8 @@ module.exports = {

create(context) {

// eslint-disable-next-line jsdoc/require-description
/**
* Handler for function contexts.
* @param {ASTNode} node function node
* @returns {void}
*/
Expand Down
2 changes: 0 additions & 2 deletions lib/rules/indent.js
Expand Up @@ -190,7 +190,6 @@ class BinarySearchTree {
*/
class TokenInfo {

// eslint-disable-next-line jsdoc/require-description
/**
* @param {SourceCode} sourceCode A SourceCode object
*/
Expand Down Expand Up @@ -240,7 +239,6 @@ class TokenInfo {
*/
class OffsetStorage {

// eslint-disable-next-line jsdoc/require-description
/**
* @param {TokenInfo} tokenInfo a TokenInfo instance
* @param {number} indentSize The desired size of each indentation level
Expand Down
2 changes: 1 addition & 1 deletion lib/rules/index.js
Expand Up @@ -6,7 +6,7 @@

"use strict";

/* eslint sort-keys: ["error", "asc"] */
/* eslint sort-keys: ["error", "asc"] -- More readable for long list */

const { LazyLoadingRuleMap } = require("./utils/lazy-loading-rule-map");

Expand Down
1 change: 0 additions & 1 deletion lib/rules/no-dupe-keys.js
Expand Up @@ -23,7 +23,6 @@ const SET_KIND = /^(?:init|set)$/u;
*/
class ObjectInfo {

// eslint-disable-next-line jsdoc/require-description
/**
* @param {ObjectInfo|null} upper The information of the outer object.
* @param {ASTNode} node The ObjectExpression node of this information.
Expand Down
2 changes: 1 addition & 1 deletion lib/rules/no-restricted-globals.js
Expand Up @@ -43,7 +43,7 @@ module.exports = {

messages: {
defaultMessage: "Unexpected use of '{{name}}'.",
// eslint-disable-next-line eslint-plugin/report-message-format
// eslint-disable-next-line eslint-plugin/report-message-format -- Custom message might not end in a period
customMessage: "Unexpected use of '{{name}}'. {{customMessage}}"
}
},
Expand Down
8 changes: 4 additions & 4 deletions lib/rules/no-restricted-imports.js
Expand Up @@ -86,19 +86,19 @@ module.exports = {

messages: {
path: "'{{importSource}}' import is restricted from being used.",
// eslint-disable-next-line eslint-plugin/report-message-format
// eslint-disable-next-line eslint-plugin/report-message-format -- Custom message might not end in a period
pathWithCustomMessage: "'{{importSource}}' import is restricted from being used. {{customMessage}}",

patterns: "'{{importSource}}' import is restricted from being used by a pattern.",
// eslint-disable-next-line eslint-plugin/report-message-format
// eslint-disable-next-line eslint-plugin/report-message-format -- Custom message might not end in a period
patternWithCustomMessage: "'{{importSource}}' import is restricted from being used by a pattern. {{customMessage}}",

everything: "* import is invalid because '{{importNames}}' from '{{importSource}}' is restricted.",
// eslint-disable-next-line eslint-plugin/report-message-format
// eslint-disable-next-line eslint-plugin/report-message-format -- Custom message might not end in a period
everythingWithCustomMessage: "* import is invalid because '{{importNames}}' from '{{importSource}}' is restricted. {{customMessage}}",

importName: "'{{importName}}' import from '{{importSource}}' is restricted.",
// eslint-disable-next-line eslint-plugin/report-message-format
// eslint-disable-next-line eslint-plugin/report-message-format -- Custom message might not end in a period
importNameWithCustomMessage: "'{{importName}}' import from '{{importSource}}' is restricted. {{customMessage}}"
},

Expand Down
2 changes: 1 addition & 1 deletion lib/rules/no-restricted-modules.js
Expand Up @@ -73,7 +73,7 @@ module.exports = {

messages: {
defaultMessage: "'{{name}}' module is restricted from being used.",
// eslint-disable-next-line eslint-plugin/report-message-format
// eslint-disable-next-line eslint-plugin/report-message-format -- Custom message might not end in a period
customMessage: "'{{name}}' module is restricted from being used. {{customMessage}}",
patternMessage: "'{{name}}' module is restricted from being used by a pattern."
}
Expand Down

0 comments on commit 9a4ae3b

Please sign in to comment.