Skip to content
Permalink
Browse files
Chore: Apply comment require-description and check ClassDeclaration (#…
…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 9a4ae3b68a1afd9483d331997635727fb19a1a99
Showing with 145 additions and 143 deletions.
  1. +2 −2 Makefile.js
  2. +1 −1 bin/eslint.js
  3. +1 −1 conf/eslint-recommended.js
  4. +3 −0 lib/cli-engine/cli-engine.js
  5. +0 −2 lib/cli-engine/file-enumerator.js
  6. +1 −1 lib/cli-engine/formatters/html.js
  7. +1 −1 lib/cli-engine/xml-escape.js
  8. +2 −2 lib/config/flat-config-array.js
  9. +1 −1 lib/config/flat-config-schema.js
  10. +3 −0 lib/eslint/eslint.js
  11. +1 −2 lib/init/autoconfig.js
  12. +0 −1 lib/init/config-rule.js
  13. +2 −2 lib/init/source-code-utils.js
  14. +0 −1 lib/linter/code-path-analysis/code-path-analyzer.js
  15. +0 −1 lib/linter/code-path-analysis/code-path-segment.js
  16. +0 −1 lib/linter/code-path-analysis/code-path-state.js
  17. +0 −1 lib/linter/code-path-analysis/code-path.js
  18. +2 −2 lib/linter/code-path-analysis/debug-helpers.js
  19. +0 −1 lib/linter/code-path-analysis/fork-context.js
  20. +0 −1 lib/linter/code-path-analysis/id-generator.js
  21. +1 −1 lib/linter/config-comment-parser.js
  22. +2 −2 lib/linter/linter.js
  23. +0 −1 lib/linter/node-event-generator.js
  24. +3 −0 lib/linter/rules.js
  25. +1 −1 lib/linter/timing.js
  26. +6 −3 lib/rule-tester/rule-tester.js
  27. +1 −1 lib/rules/default-param-last.js
  28. +0 −2 lib/rules/indent.js
  29. +1 −1 lib/rules/index.js
  30. +0 −1 lib/rules/no-dupe-keys.js
  31. +1 −1 lib/rules/no-restricted-globals.js
  32. +4 −4 lib/rules/no-restricted-imports.js
  33. +1 −1 lib/rules/no-restricted-modules.js
  34. +2 −2 lib/rules/no-restricted-properties.js
  35. +1 −1 lib/rules/no-restricted-syntax.js
  36. +1 −2 lib/rules/no-script-url.js
  37. +0 −2 lib/rules/no-sync.js
  38. +4 −4 lib/rules/no-unused-expressions.js
  39. +1 −1 lib/rules/prefer-destructuring.js
  40. +3 −0 lib/rules/require-atomic-updates.js
  41. +1 −1 lib/rules/vars-on-top.js
  42. +1 −1 lib/shared/ajv.js
  43. +1 −1 lib/shared/logging.js
  44. +2 −2 lib/shared/traverser.js
  45. +3 −1 lib/source-code/source-code.js
  46. +1 −1 lib/source-code/token-store/cursor.js
  47. +3 −3 packages/eslint-config-eslint/default.yml
  48. +10 −8 tests/lib/cli-engine/cli-engine.js
  49. +1 −1 tests/lib/cli-engine/file-enumerator.js
  50. +0 −2 tests/lib/cli-engine/formatters/junit.js
  51. +1 −1 tests/lib/cli.js
  52. +10 −8 tests/lib/eslint/eslint.js
  53. +3 −3 tests/lib/linter/code-path-analysis/code-path.js
  54. +3 −3 tests/lib/linter/linter.js
  55. +2 −2 tests/lib/linter/report-translator.js
  56. +1 −1 tests/lib/linter/safe-emitter.js
  57. +1 −1 tests/lib/rule-tester/no-test-runners.js
  58. +2 −2 tests/lib/rule-tester/rule-tester.js
  59. +32 −32 tests/lib/rules/camelcase.js
  60. +7 −7 tests/lib/rules/utils/ast-utils.js
  61. +1 −1 tests/tools/eslint-fuzzer.js
  62. +1 −1 tools/internal-rules/multiline-comment-style.js
  63. +1 −1 tools/internal-testers/event-generator-tester.js
  64. +4 −4 tools/update-readme.js
@@ -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";

//------------------------------------------------------------------------------
@@ -5,7 +5,7 @@
* @author Nicholas C. Zakas
*/

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

"use strict";

@@ -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 = {
@@ -562,6 +562,9 @@ function directoryExists(resolvedPath) {
// Public Interface
//------------------------------------------------------------------------------

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

/**
@@ -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.
@@ -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.
*/
@@ -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.
@@ -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;";
@@ -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
@@ -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 */

}

@@ -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;
}
@@ -422,6 +422,9 @@ function compareResultsByFilePath(a, b) {
return 0;
}

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

/**
@@ -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
*/
@@ -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
}
});

@@ -174,7 +174,6 @@ function combinePropertyObjects(objArr1, objArr2) {
*/
class RuleConfigSet {

// eslint-disable-next-line jsdoc/require-description
/**
* @param {ruleConfig[]} configs Valid rule configurations
*/
@@ -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");

@@ -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
}
});

@@ -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.
*/
@@ -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.
@@ -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.
@@ -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.
@@ -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 ? "" : "!");
}

@@ -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}[`;
@@ -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.
@@ -18,7 +18,6 @@
*/
class IdGenerator {

// eslint-disable-next-line jsdoc/require-description
/**
* @param {string} prefix Optional. A prefix of generated ids.
*/
@@ -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";

//------------------------------------------------------------------------------
@@ -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
@@ -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;
}

@@ -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
@@ -30,6 +30,9 @@ function normalizeRule(rule) {
// Public Interface
//------------------------------------------------------------------------------

/**
* A storage for rules.
*/
class Rules {
constructor() {
this._rules = Object.create(null);
@@ -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 */
@@ -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
@@ -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
@@ -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")}`
);
}
@@ -338,6 +338,9 @@ function describeDefaultHandler(text, method) {
return method.call(this);
}

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

/**
@@ -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}
*/
@@ -190,7 +190,6 @@ class BinarySearchTree {
*/
class TokenInfo {

// eslint-disable-next-line jsdoc/require-description
/**
* @param {SourceCode} sourceCode A SourceCode object
*/
@@ -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
@@ -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");

@@ -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.
@@ -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}}"
}
},
@@ -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}}"
},

@@ -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."
}

0 comments on commit 9a4ae3b

Please sign in to comment.