From 2153a267df0755b3d8f62fce888fec51b33451b2 Mon Sep 17 00:00:00 2001
From: Brett Zamir
Date: Tue, 3 Aug 2021 19:37:30 +0800
Subject: [PATCH 1/3] Chore: Apply comment require-description and check
ClassDeclaration's
---
Makefile.js | 4 +-
bin/eslint.js | 2 +-
conf/eslint-recommended.js | 2 +-
lib/cli-engine/cli-engine.js | 3 +
lib/cli-engine/file-enumerator.js | 2 -
lib/cli-engine/formatters/html.js | 2 +-
lib/cli-engine/xml-escape.js | 2 +-
lib/config/flat-config-array.js | 4 +-
lib/config/flat-config-schema.js | 2 +-
lib/eslint/eslint.js | 3 +
lib/init/autoconfig.js | 3 +-
lib/init/config-rule.js | 1 -
lib/init/source-code-utils.js | 4 +-
.../code-path-analysis/code-path-analyzer.js | 1 -
.../code-path-analysis/code-path-segment.js | 1 -
.../code-path-analysis/code-path-state.js | 1 -
lib/linter/code-path-analysis/code-path.js | 1 -
.../code-path-analysis/debug-helpers.js | 4 +-
lib/linter/code-path-analysis/fork-context.js | 1 -
lib/linter/code-path-analysis/id-generator.js | 1 -
lib/linter/config-comment-parser.js | 2 +-
lib/linter/linter.js | 4 +-
lib/linter/node-event-generator.js | 1 -
lib/linter/rules.js | 3 +
lib/linter/timing.js | 2 +-
lib/rule-tester/rule-tester.js | 9 ++-
lib/rules/default-param-last.js | 2 +-
lib/rules/indent.js | 2 -
lib/rules/index.js | 2 +-
lib/rules/no-dupe-keys.js | 1 -
lib/rules/no-restricted-globals.js | 2 +-
lib/rules/no-restricted-imports.js | 8 +--
lib/rules/no-restricted-modules.js | 2 +-
lib/rules/no-restricted-properties.js | 4 +-
lib/rules/no-restricted-syntax.js | 2 +-
lib/rules/no-script-url.js | 3 +-
lib/rules/no-sync.js | 2 -
lib/rules/no-unused-expressions.js | 8 +--
lib/rules/prefer-destructuring.js | 2 +-
lib/rules/require-atomic-updates.js | 3 +
lib/rules/vars-on-top.js | 2 +-
lib/shared/ajv.js | 2 +-
lib/shared/logging.js | 2 +-
lib/shared/traverser.js | 4 +-
lib/source-code/source-code.js | 4 +-
lib/source-code/token-store/cursor.js | 2 +-
packages/eslint-config-eslint/default.yml | 6 +-
tests/lib/cli-engine/cli-engine.js | 16 ++---
tests/lib/cli-engine/file-enumerator.js | 2 +-
tests/lib/cli-engine/formatters/junit.js | 2 -
tests/lib/cli.js | 2 +-
tests/lib/eslint/eslint.js | 16 ++---
.../linter/code-path-analysis/code-path.js | 6 +-
tests/lib/linter/linter.js | 6 +-
tests/lib/linter/report-translator.js | 4 +-
tests/lib/linter/safe-emitter.js | 2 +-
tests/lib/rule-tester/no-test-runners.js | 2 +-
tests/lib/rule-tester/rule-tester.js | 4 +-
tests/lib/rules/camelcase.js | 64 +++++++++----------
tests/lib/rules/utils/ast-utils.js | 14 ++--
tests/tools/eslint-fuzzer.js | 2 +-
.../internal-rules/multiline-comment-style.js | 2 +-
.../event-generator-tester.js | 2 +-
tools/update-readme.js | 8 +--
64 files changed, 141 insertions(+), 143 deletions(-)
diff --git a/Makefile.js b/Makefile.js
index f19ca020063..35d0df87165 100644
--- a/Makefile.js
+++ b/Makefile.js
@@ -3,8 +3,8 @@
* @author nzakas
*/
-/* global target */
-/* eslint no-use-before-define: "off", no-console: "off" */
+/* global target -- How is this being set? */
+/* eslint no-use-before-define: "off", no-console: "off" -- CLI */
"use strict";
//------------------------------------------------------------------------------
diff --git a/bin/eslint.js b/bin/eslint.js
index 5fa5766828e..6b05356b9db 100755
--- a/bin/eslint.js
+++ b/bin/eslint.js
@@ -5,7 +5,7 @@
* @author Nicholas C. Zakas
*/
-/* eslint no-console:off */
+/* eslint no-console:off -- CLI */
"use strict";
diff --git a/conf/eslint-recommended.js b/conf/eslint-recommended.js
index 7d2161a50a7..6f639855a96 100644
--- a/conf/eslint-recommended.js
+++ b/conf/eslint-recommended.js
@@ -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 = {
diff --git a/lib/cli-engine/cli-engine.js b/lib/cli-engine/cli-engine.js
index 9c024e37a28..d89addf3403 100644
--- a/lib/cli-engine/cli-engine.js
+++ b/lib/cli-engine/cli-engine.js
@@ -562,6 +562,9 @@ function directoryExists(resolvedPath) {
// Public Interface
//------------------------------------------------------------------------------
+/**
+ * Core CLI.
+ */
class CLIEngine {
/**
diff --git a/lib/cli-engine/file-enumerator.js b/lib/cli-engine/file-enumerator.js
index 03a408488f1..f1442d150b8 100644
--- a/lib/cli-engine/file-enumerator.js
+++ b/lib/cli-engine/file-enumerator.js
@@ -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.
*/
diff --git a/lib/cli-engine/formatters/html.js b/lib/cli-engine/formatters/html.js
index baddb63079d..e28996f6cd2 100644
--- a/lib/cli-engine/formatters/html.js
+++ b/lib/cli-engine/formatters/html.js
@@ -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.
diff --git a/lib/cli-engine/xml-escape.js b/lib/cli-engine/xml-escape.js
index 175c2c0c2dd..2e52dbaac02 100644
--- a/lib/cli-engine/xml-escape.js
+++ b/lib/cli-engine/xml-escape.js
@@ -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 "<";
diff --git a/lib/config/flat-config-array.js b/lib/config/flat-config-array.js
index ecf396a3314..ef9cb33ca28 100644
--- a/lib/config/flat-config-array.js
+++ b/lib/config/flat-config-array.js
@@ -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 */
}
diff --git a/lib/config/flat-config-schema.js b/lib/config/flat-config-schema.js
index 80785476133..c8cc7114940 100644
--- a/lib/config/flat-config-schema.js
+++ b/lib/config/flat-config-schema.js
@@ -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;
}
diff --git a/lib/eslint/eslint.js b/lib/eslint/eslint.js
index e20bcbaf4e3..b4a1d028db9 100644
--- a/lib/eslint/eslint.js
+++ b/lib/eslint/eslint.js
@@ -422,6 +422,9 @@ function compareResultsByFilePath(a, b) {
return 0;
}
+/**
+ * Main API.
+ */
class ESLint {
/**
diff --git a/lib/init/autoconfig.js b/lib/init/autoconfig.js
index 371b22b1a94..9d87a7f2be8 100644
--- a/lib/init/autoconfig.js
+++ b/lib/init/autoconfig.js
@@ -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
}
});
diff --git a/lib/init/config-rule.js b/lib/init/config-rule.js
index 7aec89c3df0..a93142b8abe 100644
--- a/lib/init/config-rule.js
+++ b/lib/init/config-rule.js
@@ -174,7 +174,6 @@ function combinePropertyObjects(objArr1, objArr2) {
*/
class RuleConfigSet {
- // eslint-disable-next-line jsdoc/require-description
/**
* @param {ruleConfig[]} configs Valid rule configurations
*/
diff --git a/lib/init/source-code-utils.js b/lib/init/source-code-utils.js
index f7b911e4ca2..456eef41b91 100644
--- a/lib/init/source-code-utils.js
+++ b/lib/init/source-code-utils.js
@@ -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
}
});
diff --git a/lib/linter/code-path-analysis/code-path-analyzer.js b/lib/linter/code-path-analysis/code-path-analyzer.js
index 47427c11a3d..59417ab4a4d 100644
--- a/lib/linter/code-path-analysis/code-path-analyzer.js
+++ b/lib/linter/code-path-analysis/code-path-analyzer.js
@@ -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.
*/
diff --git a/lib/linter/code-path-analysis/code-path-segment.js b/lib/linter/code-path-analysis/code-path-segment.js
index ca96ad34189..fad559a2ad2 100644
--- a/lib/linter/code-path-analysis/code-path-segment.js
+++ b/lib/linter/code-path-analysis/code-path-segment.js
@@ -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.
diff --git a/lib/linter/code-path-analysis/code-path-state.js b/lib/linter/code-path-analysis/code-path-state.js
index 4824632775b..118f70a1707 100644
--- a/lib/linter/code-path-analysis/code-path-state.js
+++ b/lib/linter/code-path-analysis/code-path-state.js
@@ -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.
diff --git a/lib/linter/code-path-analysis/code-path.js b/lib/linter/code-path-analysis/code-path.js
index 49b37c6b227..b9f72912fba 100644
--- a/lib/linter/code-path-analysis/code-path.js
+++ b/lib/linter/code-path-analysis/code-path.js
@@ -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.
diff --git a/lib/linter/code-path-analysis/debug-helpers.js b/lib/linter/code-path-analysis/debug-helpers.js
index a4cb99a22e0..ca64862db32 100644
--- a/lib/linter/code-path-analysis/debug-helpers.js
+++ b/lib/linter/code-path-analysis/debug-helpers.js
@@ -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}[`;
diff --git a/lib/linter/code-path-analysis/fork-context.js b/lib/linter/code-path-analysis/fork-context.js
index 2e872b5c0db..04c59b5e417 100644
--- a/lib/linter/code-path-analysis/fork-context.js
+++ b/lib/linter/code-path-analysis/fork-context.js
@@ -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.
diff --git a/lib/linter/code-path-analysis/id-generator.js b/lib/linter/code-path-analysis/id-generator.js
index 4cb2e0e3d87..83787a4ea5a 100644
--- a/lib/linter/code-path-analysis/id-generator.js
+++ b/lib/linter/code-path-analysis/id-generator.js
@@ -18,7 +18,6 @@
*/
class IdGenerator {
- // eslint-disable-next-line jsdoc/require-description
/**
* @param {string} prefix Optional. A prefix of generated ids.
*/
diff --git a/lib/linter/config-comment-parser.js b/lib/linter/config-comment-parser.js
index f5d7b155eb5..34675a76b55 100644
--- a/lib/linter/config-comment-parser.js
+++ b/lib/linter/config-comment-parser.js
@@ -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";
//------------------------------------------------------------------------------
diff --git a/lib/linter/linter.js b/lib/linter/linter.js
index 1b3121fde4d..dd2e830a4a1 100644
--- a/lib/linter/linter.js
+++ b/lib/linter/linter.js
@@ -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;
}
diff --git a/lib/linter/node-event-generator.js b/lib/linter/node-event-generator.js
index 9b058247b3e..89ebd281048 100644
--- a/lib/linter/node-event-generator.js
+++ b/lib/linter/node-event-generator.js
@@ -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
diff --git a/lib/linter/rules.js b/lib/linter/rules.js
index a153266efb3..647bab68784 100644
--- a/lib/linter/rules.js
+++ b/lib/linter/rules.js
@@ -30,6 +30,9 @@ function normalizeRule(rule) {
// Public Interface
//------------------------------------------------------------------------------
+/**
+ * A storage for rules.
+ */
class Rules {
constructor() {
this._rules = Object.create(null);
diff --git a/lib/linter/timing.js b/lib/linter/timing.js
index a5613a4a268..c9ab01ec649 100644
--- a/lib/linter/timing.js
+++ b/lib/linter/timing.js
@@ -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 */
diff --git a/lib/rule-tester/rule-tester.js b/lib/rule-tester/rule-tester.js
index 3e2e639882f..324af7b2cae 100644
--- a/lib/rule-tester/rule-tester.js
+++ b/lib/rule-tester/rule-tester.js
@@ -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 {
/**
diff --git a/lib/rules/default-param-last.js b/lib/rules/default-param-last.js
index 12e0b5950da..84751cdf4fd 100644
--- a/lib/rules/default-param-last.js
+++ b/lib/rules/default-param-last.js
@@ -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}
*/
diff --git a/lib/rules/indent.js b/lib/rules/indent.js
index 75d6715ae16..abd05c63de2 100644
--- a/lib/rules/indent.js
+++ b/lib/rules/indent.js
@@ -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
diff --git a/lib/rules/index.js b/lib/rules/index.js
index 35af38fd108..c88febd85b9 100644
--- a/lib/rules/index.js
+++ b/lib/rules/index.js
@@ -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");
diff --git a/lib/rules/no-dupe-keys.js b/lib/rules/no-dupe-keys.js
index 89e1f2de642..cfddde47666 100644
--- a/lib/rules/no-dupe-keys.js
+++ b/lib/rules/no-dupe-keys.js
@@ -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.
diff --git a/lib/rules/no-restricted-globals.js b/lib/rules/no-restricted-globals.js
index 2c932a7307c..9193c57cd60 100644
--- a/lib/rules/no-restricted-globals.js
+++ b/lib/rules/no-restricted-globals.js
@@ -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}}"
}
},
diff --git a/lib/rules/no-restricted-imports.js b/lib/rules/no-restricted-imports.js
index 414164d29f7..5f595d0d777 100644
--- a/lib/rules/no-restricted-imports.js
+++ b/lib/rules/no-restricted-imports.js
@@ -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}}"
},
diff --git a/lib/rules/no-restricted-modules.js b/lib/rules/no-restricted-modules.js
index d0b8a78a507..d73ecf682c6 100644
--- a/lib/rules/no-restricted-modules.js
+++ b/lib/rules/no-restricted-modules.js
@@ -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."
}
diff --git a/lib/rules/no-restricted-properties.js b/lib/rules/no-restricted-properties.js
index 7ab83995a3e..00b09a30bc0 100644
--- a/lib/rules/no-restricted-properties.js
+++ b/lib/rules/no-restricted-properties.js
@@ -64,9 +64,9 @@ module.exports = {
},
messages: {
- // 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
restrictedObjectProperty: "'{{objectName}}.{{propertyName}}' is restricted from being used.{{message}}",
- // 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
restrictedProperty: "'{{propertyName}}' is restricted from being used.{{message}}"
}
},
diff --git a/lib/rules/no-restricted-syntax.js b/lib/rules/no-restricted-syntax.js
index 9572603a824..e82dd3d56e0 100644
--- a/lib/rules/no-restricted-syntax.js
+++ b/lib/rules/no-restricted-syntax.js
@@ -42,7 +42,7 @@ module.exports = {
},
messages: {
- // 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
restrictedSyntax: "{{message}}"
}
},
diff --git a/lib/rules/no-script-url.js b/lib/rules/no-script-url.js
index 0c820524403..9544730fdcc 100644
--- a/lib/rules/no-script-url.js
+++ b/lib/rules/no-script-url.js
@@ -2,8 +2,7 @@
* @fileoverview Rule to flag when using javascript: urls
* @author Ilya Volodin
*/
-/* jshint scripturl: true */
-/* eslint no-script-url: 0 */
+/* eslint no-script-url: 0 -- Code is checking to report such URLs */
"use strict";
diff --git a/lib/rules/no-sync.js b/lib/rules/no-sync.js
index 06424e0b38f..c114a662a5b 100644
--- a/lib/rules/no-sync.js
+++ b/lib/rules/no-sync.js
@@ -3,8 +3,6 @@
* @author Matt DuVall
*/
-/* jshint node:true */
-
"use strict";
//------------------------------------------------------------------------------
diff --git a/lib/rules/no-unused-expressions.js b/lib/rules/no-unused-expressions.js
index 58c9b334187..a682ded3ce7 100644
--- a/lib/rules/no-unused-expressions.js
+++ b/lib/rules/no-unused-expressions.js
@@ -72,8 +72,8 @@ module.exports = {
allowTaggedTemplates = config.allowTaggedTemplates || false,
enforceForJSX = config.enforceForJSX || false;
- // eslint-disable-next-line jsdoc/require-description
/**
+ * Has AST suggesting a directive.
* @param {ASTNode} node any node
* @returns {boolean} whether the given node structurally represents a directive
*/
@@ -82,8 +82,8 @@ module.exports = {
node.expression.type === "Literal" && typeof node.expression.value === "string";
}
- // eslint-disable-next-line jsdoc/require-description
/**
+ * Gets the leading sequence of members in a list that pass the predicate.
* @param {Function} predicate ([a] -> Boolean) the function used to make the determination
* @param {a[]} list the input list
* @returns {a[]} the leading sequence of members in the given list that pass the given predicate
@@ -97,8 +97,8 @@ module.exports = {
return list.slice();
}
- // eslint-disable-next-line jsdoc/require-description
/**
+ * Gets leading directives nodes in a Node body.
* @param {ASTNode} node a Program or BlockStatement node
* @returns {ASTNode[]} the leading sequence of directive nodes in the given node's body
*/
@@ -106,8 +106,8 @@ module.exports = {
return takeWhile(looksLikeDirective, node.body);
}
- // eslint-disable-next-line jsdoc/require-description
/**
+ * Detect if a Node is a directive.
* @param {ASTNode} node any node
* @param {ASTNode[]} ancestors the given node's ancestors
* @returns {boolean} whether the given node is considered a directive in its current position
diff --git a/lib/rules/prefer-destructuring.js b/lib/rules/prefer-destructuring.js
index f76087e5250..8cde3a47d5d 100644
--- a/lib/rules/prefer-destructuring.js
+++ b/lib/rules/prefer-destructuring.js
@@ -119,8 +119,8 @@ module.exports = {
// Helpers
//--------------------------------------------------------------------------
- // eslint-disable-next-line jsdoc/require-description
/**
+ * Checks if destructuring type should be checked.
* @param {string} nodeType "AssignmentExpression" or "VariableDeclarator"
* @param {string} destructuringType "array" or "object"
* @returns {boolean} `true` if the destructuring type should be checked for the given node
diff --git a/lib/rules/require-atomic-updates.js b/lib/rules/require-atomic-updates.js
index b3df907420c..8a315a8793a 100644
--- a/lib/rules/require-atomic-updates.js
+++ b/lib/rules/require-atomic-updates.js
@@ -79,6 +79,9 @@ function isLocalVariableWithoutEscape(variable, isMemberAccess) {
reference.from.variableScope === functionScope);
}
+/**
+ * Represents segment information.
+ */
class SegmentInfo {
constructor() {
this.info = new WeakMap();
diff --git a/lib/rules/vars-on-top.js b/lib/rules/vars-on-top.js
index 28ddae442b5..592e9be4aa1 100644
--- a/lib/rules/vars-on-top.js
+++ b/lib/rules/vars-on-top.js
@@ -32,8 +32,8 @@ module.exports = {
// Helpers
//--------------------------------------------------------------------------
- // eslint-disable-next-line jsdoc/require-description
/**
+ * Has AST suggesting a directive.
* @param {ASTNode} node any node
* @returns {boolean} whether the given node structurally represents a directive
*/
diff --git a/lib/shared/ajv.js b/lib/shared/ajv.js
index 3fb0fbdd33c..f4f6a62183d 100644
--- a/lib/shared/ajv.js
+++ b/lib/shared/ajv.js
@@ -27,7 +27,7 @@ module.exports = (additionalOptions = {}) => {
});
ajv.addMetaSchema(metaSchema);
- // eslint-disable-next-line no-underscore-dangle
+ // eslint-disable-next-line no-underscore-dangle -- Ajv's API
ajv._opts.defaultMeta = metaSchema.id;
return ajv;
diff --git a/lib/shared/logging.js b/lib/shared/logging.js
index 6aa1f5a1e59..7f06a74e142 100644
--- a/lib/shared/logging.js
+++ b/lib/shared/logging.js
@@ -5,7 +5,7 @@
"use strict";
-/* eslint no-console: "off" */
+/* eslint no-console: "off" -- Logging util */
/* istanbul ignore next */
module.exports = {
diff --git a/lib/shared/traverser.js b/lib/shared/traverser.js
index 32f76779507..be0ed59a4f9 100644
--- a/lib/shared/traverser.js
+++ b/lib/shared/traverser.js
@@ -65,16 +65,16 @@ class Traverser {
this._leave = null;
}
- // eslint-disable-next-line jsdoc/require-description
/**
+ * Gives current node.
* @returns {ASTNode} The current node.
*/
current() {
return this._current;
}
- // eslint-disable-next-line jsdoc/require-description
/**
+ * Gives a a copy of the ancestor nodes.
* @returns {ASTNode[]} The ancestor nodes.
*/
parents() {
diff --git a/lib/source-code/source-code.js b/lib/source-code/source-code.js
index 82a2b328018..49b2820a846 100644
--- a/lib/source-code/source-code.js
+++ b/lib/source-code/source-code.js
@@ -143,10 +143,12 @@ function isSpaceBetween(sourceCode, first, second, checkInsideOfJSXText) {
// Public Interface
//------------------------------------------------------------------------------
+/**
+ * Represents parsed source code.
+ */
class SourceCode extends TokenStore {
/**
- * Represents parsed source code.
* @param {string|Object} textOrConfig The source code text or config object.
* @param {string} textOrConfig.text The source code text.
* @param {ASTNode} textOrConfig.ast The Program node of the AST representing the code. This AST should be created from the text that BOM was stripped.
diff --git a/lib/source-code/token-store/cursor.js b/lib/source-code/token-store/cursor.js
index 4e1595c6dcb..494762acdfa 100644
--- a/lib/source-code/token-store/cursor.js
+++ b/lib/source-code/token-store/cursor.js
@@ -70,7 +70,7 @@ module.exports = class Cursor {
* @abstract
*/
/* istanbul ignore next */
- moveNext() { // eslint-disable-line class-methods-use-this
+ moveNext() { // eslint-disable-line class-methods-use-this -- Unused
throw new Error("Not implemented.");
}
};
diff --git a/packages/eslint-config-eslint/default.yml b/packages/eslint-config-eslint/default.yml
index addce035fe2..efd7a5a1430 100644
--- a/packages/eslint-config-eslint/default.yml
+++ b/packages/eslint-config-eslint/default.yml
@@ -75,7 +75,7 @@ rules:
eslint-comments/disable-enable-pair: ["error"]
eslint-comments/no-unused-disable: "error"
- # eslint-comments/require-description: "error"
+ eslint-comments/require-description: "error"
func-call-spacing: "error"
func-style: ["error", "declaration"]
@@ -96,7 +96,7 @@ rules:
jsdoc/newline-after-description: ["error", "never"]
jsdoc/no-bad-blocks: "error"
jsdoc/require-asterisk-prefix: "error"
- jsdoc/require-description: "error"
+ jsdoc/require-description: ["error", { checkConstructors: false }]
# jsdoc/require-file-overview: "error"
jsdoc/require-hyphen-before-param-description: ["error", "never"]
jsdoc/require-returns: ["error", { forceRequireReturn: true, forceReturnsWithAsync: true }]
@@ -118,7 +118,7 @@ rules:
jsdoc/implements-on-classes: "error"
jsdoc/multiline-blocks: "error"
jsdoc/no-multi-asterisks: "error"
- jsdoc/require-jsdoc: "error"
+ jsdoc/require-jsdoc: ["error", { require: {ClassDeclaration: true} }]
jsdoc/require-param: "error"
jsdoc/require-param-description: "error"
jsdoc/require-param-name: "error"
diff --git a/tests/lib/cli-engine/cli-engine.js b/tests/lib/cli-engine/cli-engine.js
index ea10362d1a5..b3e6ae8faa4 100644
--- a/tests/lib/cli-engine/cli-engine.js
+++ b/tests/lib/cli-engine/cli-engine.js
@@ -92,7 +92,7 @@ describe("CLIEngine", () => {
* exceeds the default test timeout, so raise it just for this hook.
* Mocha uses `this` to set timeouts on an individual hook level.
*/
- this.timeout(60 * 1000); // eslint-disable-line no-invalid-this
+ this.timeout(60 * 1000); // eslint-disable-line no-invalid-this -- Mocha API
shell.mkdir("-p", fixtureDir);
shell.cp("-r", "./tests/fixtures/.", fixtureDir);
});
@@ -120,7 +120,7 @@ describe("CLIEngine", () => {
it("should report one fatal message when given a path by --ignore-path that is not a file when ignore is true.", () => {
assert.throws(() => {
- // eslint-disable-next-line no-new
+ // eslint-disable-next-line no-new -- Testing synchronous throwing
new CLIEngine({ ignorePath: fixtureDir });
}, `Cannot read .eslintignore file: ${fixtureDir}\nError: EISDIR: illegal operation on a directory, read`);
});
@@ -129,7 +129,7 @@ describe("CLIEngine", () => {
it("should not modify baseConfig when format is specified", () => {
const customBaseConfig = { root: true };
- new CLIEngine({ baseConfig: customBaseConfig, format: "foo" }); // eslint-disable-line no-new
+ new CLIEngine({ baseConfig: customBaseConfig, format: "foo" }); // eslint-disable-line no-new -- Test side effects
assert.deepStrictEqual(customBaseConfig, { root: true });
});
@@ -741,7 +741,7 @@ describe("CLIEngine", () => {
const Module = require("module");
let originalFindPath = null;
- /* eslint-disable no-underscore-dangle */
+ /* eslint-disable no-underscore-dangle -- Private Node API overriding */
before(() => {
originalFindPath = Module._findPath;
Module._findPath = function(id, ...otherArgs) {
@@ -754,7 +754,7 @@ describe("CLIEngine", () => {
after(() => {
Module._findPath = originalFindPath;
});
- /* eslint-enable no-underscore-dangle */
+ /* eslint-enable no-underscore-dangle -- Private Node API overriding */
it("should resolve 'plugins:[\"@scope\"]' to 'node_modules/@scope/eslint-plugin'.", () => {
engine = new CLIEngine({ cwd: getFixturePath("plugin-shorthand/basic") });
@@ -4303,7 +4303,7 @@ describe("CLIEngine", () => {
assert.throw(() => {
try {
- // eslint-disable-next-line no-new
+ // eslint-disable-next-line no-new -- Check for throwing
new CLIEngine({ cwd });
} catch (error) {
assert.strictEqual(error.messageTemplate, "failed-to-read-json");
@@ -4329,7 +4329,7 @@ describe("CLIEngine", () => {
const cwd = getFixturePath("ignored-paths", "bad-package-json-ignore");
assert.throws(() => {
- // eslint-disable-next-line no-new
+ // eslint-disable-next-line no-new -- Check for throwing
new CLIEngine({ cwd });
}, "Package.json eslintIgnore property requires an array of paths");
});
@@ -4461,7 +4461,7 @@ describe("CLIEngine", () => {
const ignorePath = getFixturePath("ignored-paths", "not-a-directory", ".foobaz");
assert.throws(() => {
- // eslint-disable-next-line no-new
+ // eslint-disable-next-line no-new -- Check for throwing
new CLIEngine({ ignorePath, cwd });
}, "Cannot read .eslintignore file");
});
diff --git a/tests/lib/cli-engine/file-enumerator.js b/tests/lib/cli-engine/file-enumerator.js
index bea27415f28..1027038d13d 100644
--- a/tests/lib/cli-engine/file-enumerator.js
+++ b/tests/lib/cli-engine/file-enumerator.js
@@ -218,7 +218,7 @@ describe("FileEnumerator", () => {
* it just for this hook. Mocha uses `this` to set timeouts on
* an individual hook level.
*/
- this.timeout(60 * 1000); // eslint-disable-line no-invalid-this
+ this.timeout(60 * 1000); // eslint-disable-line no-invalid-this -- Mocha API
fixtureDir = `${os.tmpdir()}/eslint/tests/fixtures/`;
sh.mkdir("-p", fixtureDir);
sh.cp("-r", "./tests/fixtures/*", fixtureDir);
diff --git a/tests/lib/cli-engine/formatters/junit.js b/tests/lib/cli-engine/formatters/junit.js
index b77c177885a..26a2445b3b3 100644
--- a/tests/lib/cli-engine/formatters/junit.js
+++ b/tests/lib/cli-engine/formatters/junit.js
@@ -3,8 +3,6 @@
* @author Jamund Ferguson
*/
-/* jshint node:true */
-
"use strict";
//------------------------------------------------------------------------------
diff --git a/tests/lib/cli.js b/tests/lib/cli.js
index dbfe03c26ea..b6510bbc009 100644
--- a/tests/lib/cli.js
+++ b/tests/lib/cli.js
@@ -90,7 +90,7 @@ describe("cli", () => {
* exceeds the default test timeout, so raise it just for this hook.
* Mocha uses `this` to set timeouts on an individual hook level.
*/
- this.timeout(60 * 1000); // eslint-disable-line no-invalid-this
+ this.timeout(60 * 1000); // eslint-disable-line no-invalid-this -- Mocha API
fixtureDir = `${os.tmpdir()}/eslint/fixtures`;
sh.mkdir("-p", fixtureDir);
sh.cp("-r", "./tests/fixtures/.", fixtureDir);
diff --git a/tests/lib/eslint/eslint.js b/tests/lib/eslint/eslint.js
index 3ff9707b173..28155dd7fdf 100644
--- a/tests/lib/eslint/eslint.js
+++ b/tests/lib/eslint/eslint.js
@@ -99,7 +99,7 @@ describe("ESLint", () => {
* exceeds the default test timeout, so raise it just for this hook.
* Mocha uses `this` to set timeouts on an individual hook level.
*/
- this.timeout(60 * 1000); // eslint-disable-line no-invalid-this
+ this.timeout(60 * 1000); // eslint-disable-line no-invalid-this -- Mocha API
shell.mkdir("-p", fixtureDir);
shell.cp("-r", "./tests/fixtures/.", fixtureDir);
});
@@ -127,7 +127,7 @@ describe("ESLint", () => {
it("should report one fatal message when given a path by --ignore-path that is not a file when ignore is true.", () => {
assert.throws(() => {
- // eslint-disable-next-line no-new
+ // eslint-disable-next-line no-new -- Check for throwing
new ESLint({ ignorePath: fixtureDir });
}, new RegExp(escapeStringRegExp(`Cannot read .eslintignore file: ${fixtureDir}\nError: EISDIR: illegal operation on a directory, read`), "u"));
});
@@ -136,7 +136,7 @@ describe("ESLint", () => {
it("should not modify baseConfig when format is specified", () => {
const customBaseConfig = { root: true };
- new ESLint({ baseConfig: customBaseConfig }); // eslint-disable-line no-new
+ new ESLint({ baseConfig: customBaseConfig }); // eslint-disable-line no-new -- Check for argument side effects
assert.deepStrictEqual(customBaseConfig, { root: true });
});
@@ -796,7 +796,7 @@ describe("ESLint", () => {
const Module = require("module");
let originalFindPath = null;
- /* eslint-disable no-underscore-dangle */
+ /* eslint-disable no-underscore-dangle -- Override Node API */
before(() => {
originalFindPath = Module._findPath;
Module._findPath = function(id, ...otherArgs) {
@@ -809,7 +809,7 @@ describe("ESLint", () => {
after(() => {
Module._findPath = originalFindPath;
});
- /* eslint-enable no-underscore-dangle */
+ /* eslint-enable no-underscore-dangle -- Override Node API */
it("should resolve 'plugins:[\"@scope\"]' to 'node_modules/@scope/eslint-plugin'.", async () => {
eslint = new ESLint({ cwd: getFixturePath("plugin-shorthand/basic") });
@@ -4311,7 +4311,7 @@ describe("ESLint", () => {
assert.throws(() => {
try {
- // eslint-disable-next-line no-new
+ // eslint-disable-next-line no-new -- Check for error
new ESLint({ cwd });
} catch (error) {
assert.strictEqual(error.messageTemplate, "failed-to-read-json");
@@ -4337,7 +4337,7 @@ describe("ESLint", () => {
const cwd = getFixturePath("ignored-paths", "bad-package-json-ignore");
assert.throws(() => {
- // eslint-disable-next-line no-new
+ // eslint-disable-next-line no-new -- Check for throwing
new ESLint({ cwd });
}, /Package\.json eslintIgnore property requires an array of paths/u);
});
@@ -4466,7 +4466,7 @@ describe("ESLint", () => {
const ignorePath = getFixturePath("ignored-paths", "not-a-directory", ".foobaz");
assert.throws(() => {
- // eslint-disable-next-line no-new
+ // eslint-disable-next-line no-new -- Check for throwing
new ESLint({ ignorePath, cwd });
}, /Cannot read \.eslintignore file/u);
});
diff --git a/tests/lib/linter/code-path-analysis/code-path.js b/tests/lib/linter/code-path-analysis/code-path.js
index 0c4fdd18328..c75b125022f 100644
--- a/tests/lib/linter/code-path-analysis/code-path.js
+++ b/tests/lib/linter/code-path-analysis/code-path.js
@@ -50,7 +50,7 @@ function getOrderOfTraversing(codePath, options, callback) {
codePath.traverseSegments(options, (segment, controller) => {
retv.push(segment.id);
if (callback) {
- callback(segment, controller); // eslint-disable-line node/callback-return
+ callback(segment, controller); // eslint-disable-line node/callback-return -- At end of inner function
}
});
@@ -64,7 +64,7 @@ function getOrderOfTraversing(codePath, options, callback) {
describe("CodePathAnalyzer", () => {
describe(".traverseSegments()", () => {
describe("should traverse segments from the first to the end:", () => {
- /* eslint-disable internal-rules/multiline-comment-style */
+ /* eslint-disable internal-rules/multiline-comment-style -- Commenting out */
it("simple", () => {
const codePath = parseCodePaths("foo(); bar(); baz();")[0];
const order = getOrderOfTraversing(codePath);
@@ -301,6 +301,6 @@ describe("CodePathAnalyzer", () => {
*/
});
- /* eslint-enable internal-rules/multiline-comment-style */
+ /* eslint-enable internal-rules/multiline-comment-style -- Commenting out */
});
});
diff --git a/tests/lib/linter/linter.js b/tests/lib/linter/linter.js
index a542cbd86f0..deaaea37baf 100644
--- a/tests/lib/linter/linter.js
+++ b/tests/lib/linter/linter.js
@@ -3205,7 +3205,7 @@ var a = "test2";
"eslint-enable eqeqeq",
"eslint-env es6"
]) {
- // eslint-disable-next-line no-loop-func
+ // eslint-disable-next-line no-loop-func -- No closures
it(`should warn '/* ${directive} */' if 'noInlineConfig' was given.`, () => {
const messages = linter.verify(`/* ${directive} */`, { noInlineConfig: true });
@@ -3221,7 +3221,7 @@ var a = "test2";
"eslint-disable-line eqeqeq",
"eslint-disable-next-line eqeqeq"
]) {
- // eslint-disable-next-line no-loop-func
+ // eslint-disable-next-line no-loop-func -- No closures
it(`should warn '// ${directive}' if 'noInlineConfig' was given.`, () => {
const messages = linter.verify(`// ${directive}`, { noInlineConfig: true });
@@ -5565,7 +5565,7 @@ var a = "test2";
it("eslint-scope should use the visitorKeys (so 'childVisitorKeys.ClassDeclaration' includes 'experimentalDecorators')", () => {
assert.deepStrictEqual(
- scopeManager.__options.childVisitorKeys.ClassDeclaration, // eslint-disable-line no-underscore-dangle
+ scopeManager.__options.childVisitorKeys.ClassDeclaration, // eslint-disable-line no-underscore-dangle -- ScopeManager API
["experimentalDecorators", "id", "superClass", "body"]
);
});
diff --git a/tests/lib/linter/report-translator.js b/tests/lib/linter/report-translator.js
index c6dd242e330..1235d555e05 100644
--- a/tests/lib/linter/report-translator.js
+++ b/tests/lib/linter/report-translator.js
@@ -1037,7 +1037,7 @@ describe("createReportTranslator", () => {
for (const badRange of [[0], [0, null], [null, 0], [void 0, 1], [0, void 0], [void 0, void 0], []]) {
assert.throws(
- // eslint-disable-next-line no-loop-func
+ // eslint-disable-next-line no-loop-func -- Using arrow functions
() => translateReport(
{ node, messageId: "testMessage", fix: () => ({ range: badRange, text: "foo" }) }
),
@@ -1045,7 +1045,7 @@ describe("createReportTranslator", () => {
);
assert.throws(
- // eslint-disable-next-line no-loop-func
+ // eslint-disable-next-line no-loop-func -- Using arrow functions
() => translateReport(
{
node,
diff --git a/tests/lib/linter/safe-emitter.js b/tests/lib/linter/safe-emitter.js
index e76e1a07d8e..fdcf63085fa 100644
--- a/tests/lib/linter/safe-emitter.js
+++ b/tests/lib/linter/safe-emitter.js
@@ -32,7 +32,7 @@ describe("safe-emitter", () => {
let called = false;
emitter.on("foo", function() {
- assert.strictEqual(this, void 0); // eslint-disable-line no-invalid-this
+ assert.strictEqual(this, void 0); // eslint-disable-line no-invalid-this -- Checking `this` value
called = true;
});
diff --git a/tests/lib/rule-tester/no-test-runners.js b/tests/lib/rule-tester/no-test-runners.js
index f40bdfde992..8e5785cef98 100644
--- a/tests/lib/rule-tester/no-test-runners.js
+++ b/tests/lib/rule-tester/no-test-runners.js
@@ -1,4 +1,4 @@
-/* eslint no-global-assign: off*/
+/* eslint no-global-assign: off -- Resetting Mocha globals */
/**
* @fileoverview Tests for RuleTester without any test runner
* @author Weijia Wang
diff --git a/tests/lib/rule-tester/rule-tester.js b/tests/lib/rule-tester/rule-tester.js
index 5bc4b1f62c3..0ef3dd00e70 100644
--- a/tests/lib/rule-tester/rule-tester.js
+++ b/tests/lib/rule-tester/rule-tester.js
@@ -227,7 +227,7 @@ describe("RuleTester", () => {
before(() => {
originalGlobalIt = global.it;
- // eslint-disable-next-line no-global-assign
+ // eslint-disable-next-line no-global-assign -- Temporarily override Mocha global
it = () => {};
/*
@@ -241,7 +241,7 @@ describe("RuleTester", () => {
});
after(() => {
- // eslint-disable-next-line no-global-assign
+ // eslint-disable-next-line no-global-assign -- Restore Mocha global
it = originalGlobalIt;
RuleTester.describe = originalRuleTesterDescribe;
RuleTester.it = originalRuleTesterIt;
diff --git a/tests/lib/rules/camelcase.js b/tests/lib/rules/camelcase.js
index 40b8d0278c9..c336677dc86 100644
--- a/tests/lib/rules/camelcase.js
+++ b/tests/lib/rules/camelcase.js
@@ -182,90 +182,90 @@ ruleTester.run("camelcase", rule, {
{
code: "var camelCased = a_global_variable",
options: [{ ignoreGlobals: true }],
- globals: { a_global_variable: "readonly" } // eslint-disable-line camelcase
+ globals: { a_global_variable: "readonly" } // eslint-disable-line camelcase -- Testing non-CamelCase
},
{
code: "a_global_variable.foo()",
options: [{ ignoreGlobals: true }],
- globals: { a_global_variable: "readonly" } // eslint-disable-line camelcase
+ globals: { a_global_variable: "readonly" } // eslint-disable-line camelcase -- Testing non-CamelCase
},
{
code: "a_global_variable[undefined]",
options: [{ ignoreGlobals: true }],
- globals: { a_global_variable: "readonly" } // eslint-disable-line camelcase
+ globals: { a_global_variable: "readonly" } // eslint-disable-line camelcase -- Testing non-CamelCase
},
{
code: "var foo = a_global_variable.bar",
options: [{ ignoreGlobals: true }],
- globals: { a_global_variable: "readonly" } // eslint-disable-line camelcase
+ globals: { a_global_variable: "readonly" } // eslint-disable-line camelcase -- Testing non-CamelCase
},
{
code: "a_global_variable.foo = bar",
options: [{ ignoreGlobals: true }],
- globals: { a_global_variable: "readonly" } // eslint-disable-line camelcase
+ globals: { a_global_variable: "readonly" } // eslint-disable-line camelcase -- Testing non-CamelCase
},
{
code: "( { foo: a_global_variable.bar } = baz )",
options: [{ ignoreGlobals: true }],
parserOptions: { ecmaVersion: 6 },
- globals: { a_global_variable: "readonly" } // eslint-disable-line camelcase
+ globals: { a_global_variable: "readonly" } // eslint-disable-line camelcase -- Testing non-CamelCase
},
{
code: "a_global_variable = foo",
options: [{ ignoreGlobals: true }],
- globals: { a_global_variable: "writable" } // eslint-disable-line camelcase
+ globals: { a_global_variable: "writable" } // eslint-disable-line camelcase -- Testing non-CamelCase
},
{
code: "a_global_variable = foo",
options: [{ ignoreGlobals: true }],
- globals: { a_global_variable: "readonly" } // eslint-disable-line camelcase
+ globals: { a_global_variable: "readonly" } // eslint-disable-line camelcase -- Testing non-CamelCase
},
{
code: "({ a_global_variable } = foo)",
options: [{ ignoreGlobals: true }],
parserOptions: { ecmaVersion: 6 },
- globals: { a_global_variable: "writable" } // eslint-disable-line camelcase
+ globals: { a_global_variable: "writable" } // eslint-disable-line camelcase -- Testing non-CamelCase
},
{
code: "({ snake_cased: a_global_variable } = foo)",
options: [{ ignoreGlobals: true }],
parserOptions: { ecmaVersion: 6 },
- globals: { a_global_variable: "writable" } // eslint-disable-line camelcase
+ globals: { a_global_variable: "writable" } // eslint-disable-line camelcase -- Testing non-CamelCase
},
{
code: "({ snake_cased: a_global_variable = foo } = bar)",
options: [{ ignoreGlobals: true }],
parserOptions: { ecmaVersion: 6 },
- globals: { a_global_variable: "writable" } // eslint-disable-line camelcase
+ globals: { a_global_variable: "writable" } // eslint-disable-line camelcase -- Testing non-CamelCase
},
{
code: "[a_global_variable] = bar",
options: [{ ignoreGlobals: true }],
parserOptions: { ecmaVersion: 6 },
- globals: { a_global_variable: "writable" } // eslint-disable-line camelcase
+ globals: { a_global_variable: "writable" } // eslint-disable-line camelcase -- Testing non-CamelCase
},
{
code: "[a_global_variable = foo] = bar",
options: [{ ignoreGlobals: true }],
parserOptions: { ecmaVersion: 6 },
- globals: { a_global_variable: "writable" } // eslint-disable-line camelcase
+ globals: { a_global_variable: "writable" } // eslint-disable-line camelcase -- Testing non-CamelCase
},
{
code: "foo[a_global_variable] = bar",
options: [{ ignoreGlobals: true }],
- globals: { a_global_variable: "readonly" } // eslint-disable-line camelcase
+ globals: { a_global_variable: "readonly" } // eslint-disable-line camelcase -- Testing non-CamelCase
},
{
code: "var foo = { [a_global_variable]: bar }",
options: [{ ignoreGlobals: true }],
parserOptions: { ecmaVersion: 6 },
- globals: { a_global_variable: "readonly" } // eslint-disable-line camelcase
+ globals: { a_global_variable: "readonly" } // eslint-disable-line camelcase -- Testing non-CamelCase
},
{
code: "var { [a_global_variable]: foo } = bar",
options: [{ ignoreGlobals: true }],
parserOptions: { ecmaVersion: 6 },
- globals: { a_global_variable: "readonly" } // eslint-disable-line camelcase
+ globals: { a_global_variable: "readonly" } // eslint-disable-line camelcase -- Testing non-CamelCase
},
{
code: "function foo({ no_camelcased: camelCased }) {};",
@@ -763,7 +763,7 @@ ruleTester.run("camelcase", rule, {
{
code: "var camelCased = snake_cased",
options: [{ ignoreGlobals: false }],
- globals: { snake_cased: "readonly" }, // eslint-disable-line camelcase
+ globals: { snake_cased: "readonly" }, // eslint-disable-line camelcase -- Testing non-CamelCase
errors: [
{
messageId: "notCamelCase",
@@ -775,7 +775,7 @@ ruleTester.run("camelcase", rule, {
{
code: "a_global_variable.foo()",
options: [{ ignoreGlobals: false }],
- globals: { snake_cased: "readonly" }, // eslint-disable-line camelcase
+ globals: { snake_cased: "readonly" }, // eslint-disable-line camelcase -- Testing non-CamelCase
errors: [
{
messageId: "notCamelCase",
@@ -787,7 +787,7 @@ ruleTester.run("camelcase", rule, {
{
code: "a_global_variable[undefined]",
options: [{ ignoreGlobals: false }],
- globals: { snake_cased: "readonly" }, // eslint-disable-line camelcase
+ globals: { snake_cased: "readonly" }, // eslint-disable-line camelcase -- Testing non-CamelCase
errors: [
{
messageId: "notCamelCase",
@@ -798,7 +798,7 @@ ruleTester.run("camelcase", rule, {
},
{
code: "var camelCased = snake_cased",
- globals: { snake_cased: "readonly" }, // eslint-disable-line camelcase
+ globals: { snake_cased: "readonly" }, // eslint-disable-line camelcase -- Testing non-CamelCase
errors: [
{
messageId: "notCamelCase",
@@ -810,7 +810,7 @@ ruleTester.run("camelcase", rule, {
{
code: "var camelCased = snake_cased",
options: [{}],
- globals: { snake_cased: "readonly" }, // eslint-disable-line camelcase
+ globals: { snake_cased: "readonly" }, // eslint-disable-line camelcase -- Testing non-CamelCase
errors: [
{
messageId: "notCamelCase",
@@ -822,7 +822,7 @@ ruleTester.run("camelcase", rule, {
{
code: "foo.a_global_variable = bar",
options: [{ ignoreGlobals: true }],
- globals: { a_global_variable: "writable" }, // eslint-disable-line camelcase
+ globals: { a_global_variable: "writable" }, // eslint-disable-line camelcase -- Testing non-CamelCase
errors: [
{
messageId: "notCamelCase",
@@ -834,7 +834,7 @@ ruleTester.run("camelcase", rule, {
{
code: "var foo = { a_global_variable: bar }",
options: [{ ignoreGlobals: true }],
- globals: { a_global_variable: "writable" }, // eslint-disable-line camelcase
+ globals: { a_global_variable: "writable" }, // eslint-disable-line camelcase -- Testing non-CamelCase
errors: [
{
messageId: "notCamelCase",
@@ -846,7 +846,7 @@ ruleTester.run("camelcase", rule, {
{
code: "var foo = { a_global_variable: a_global_variable }",
options: [{ ignoreGlobals: true }],
- globals: { a_global_variable: "writable" }, // eslint-disable-line camelcase
+ globals: { a_global_variable: "writable" }, // eslint-disable-line camelcase -- Testing non-CamelCase
errors: [
{
messageId: "notCamelCase",
@@ -860,7 +860,7 @@ ruleTester.run("camelcase", rule, {
code: "var foo = { a_global_variable() {} }",
options: [{ ignoreGlobals: true }],
parserOptions: { ecmaVersion: 6 },
- globals: { a_global_variable: "writable" }, // eslint-disable-line camelcase
+ globals: { a_global_variable: "writable" }, // eslint-disable-line camelcase -- Testing non-CamelCase
errors: [
{
messageId: "notCamelCase",
@@ -873,7 +873,7 @@ ruleTester.run("camelcase", rule, {
code: "class Foo { a_global_variable() {} }",
options: [{ ignoreGlobals: true }],
parserOptions: { ecmaVersion: 6 },
- globals: { a_global_variable: "writable" }, // eslint-disable-line camelcase
+ globals: { a_global_variable: "writable" }, // eslint-disable-line camelcase -- Testing non-CamelCase
errors: [
{
messageId: "notCamelCase",
@@ -885,7 +885,7 @@ ruleTester.run("camelcase", rule, {
{
code: "a_global_variable: for (;;);",
options: [{ ignoreGlobals: true }],
- globals: { a_global_variable: "writable" }, // eslint-disable-line camelcase
+ globals: { a_global_variable: "writable" }, // eslint-disable-line camelcase -- Testing non-CamelCase
errors: [
{
messageId: "notCamelCase",
@@ -898,7 +898,7 @@ ruleTester.run("camelcase", rule, {
code: "if (foo) { let a_global_variable; a_global_variable = bar; }",
options: [{ ignoreGlobals: true }],
parserOptions: { ecmaVersion: 6 },
- globals: { a_global_variable: "writable" }, // eslint-disable-line camelcase
+ globals: { a_global_variable: "writable" }, // eslint-disable-line camelcase -- Testing non-CamelCase
errors: [
{
messageId: "notCamelCase",
@@ -918,7 +918,7 @@ ruleTester.run("camelcase", rule, {
code: "function foo(a_global_variable) { foo = a_global_variable; }",
options: [{ ignoreGlobals: true }],
parserOptions: { ecmaVersion: 6 },
- globals: { a_global_variable: "writable" }, // eslint-disable-line camelcase
+ globals: { a_global_variable: "writable" }, // eslint-disable-line camelcase -- Testing non-CamelCase
errors: [
{
messageId: "notCamelCase",
@@ -962,7 +962,7 @@ ruleTester.run("camelcase", rule, {
code: "const a_global_variable = foo; bar = a_global_variable",
options: [{ ignoreGlobals: true }],
parserOptions: { ecmaVersion: 6 },
- globals: { a_global_variable: "writable" }, // eslint-disable-line camelcase
+ globals: { a_global_variable: "writable" }, // eslint-disable-line camelcase -- Testing non-CamelCase
errors: [
{
messageId: "notCamelCase",
@@ -982,7 +982,7 @@ ruleTester.run("camelcase", rule, {
code: "bar = a_global_variable; var a_global_variable;",
options: [{ ignoreGlobals: true }],
parserOptions: { ecmaVersion: 6 },
- globals: { a_global_variable: "writable" }, // eslint-disable-line camelcase
+ globals: { a_global_variable: "writable" }, // eslint-disable-line camelcase -- Testing non-CamelCase
errors: [
{
messageId: "notCamelCase",
@@ -1002,7 +1002,7 @@ ruleTester.run("camelcase", rule, {
code: "var foo = { a_global_variable }",
options: [{ ignoreGlobals: true }],
parserOptions: { ecmaVersion: 6 },
- globals: { a_global_variable: "readonly" }, // eslint-disable-line camelcase
+ globals: { a_global_variable: "readonly" }, // eslint-disable-line camelcase -- Testing non-CamelCase
errors: [
{
messageId: "notCamelCase",
diff --git a/tests/lib/rules/utils/ast-utils.js b/tests/lib/rules/utils/ast-utils.js
index 9ebcace8ec7..a6197c77af0 100644
--- a/tests/lib/rules/utils/ast-utils.js
+++ b/tests/lib/rules/utils/ast-utils.js
@@ -415,7 +415,7 @@ describe("ast-utils", () => {
describe("getStaticStringValue", () => {
- /* eslint-disable quote-props */
+ /* eslint-disable quote-props -- Make consistent here for readability */
const expectedResults = {
// string literals
@@ -479,7 +479,7 @@ describe("ast-utils", () => {
"this": null,
"(function () {})": null
};
- /* eslint-enable quote-props */
+ /* eslint-enable quote-props -- Make consistent here for readability */
Object.keys(expectedResults).forEach(key => {
it(`should return ${expectedResults[key]} for ${key}`, () => {
@@ -1030,7 +1030,7 @@ describe("ast-utils", () => {
describe("getNextLocation", () => {
- /* eslint-disable quote-props */
+ /* eslint-disable quote-props -- Make consistent here for readability */
const expectedResults = {
"": [[1, 0], null],
"\n": [[1, 0], [2, 0], null],
@@ -1052,7 +1052,7 @@ describe("ast-utils", () => {
"a\t": [[1, 0], [1, 1], [1, 2], null],
"a \n": [[1, 0], [1, 1], [1, 2], [2, 0], null]
};
- /* eslint-enable quote-props */
+ /* eslint-enable quote-props -- Make consistent here for readability */
Object.keys(expectedResults).forEach(code => {
it(`should return expected locations for "${code}".`, () => {
@@ -1581,7 +1581,7 @@ describe("ast-utils", () => {
},
nodeB: {
type: "Literal",
- value: /(?:)/, // eslint-disable-line require-unicode-regexp
+ value: /(?:)/, // eslint-disable-line require-unicode-regexp -- Checking non-Unicode regex
regex: { pattern: "(?:)", flags: "" }
},
expected: false
@@ -1674,7 +1674,7 @@ describe("ast-utils", () => {
describe("hasOctalOrNonOctalDecimalEscapeSequence", () => {
- /* eslint-disable quote-props */
+ /* eslint-disable quote-props -- Make consistent here for readability */
const expectedResults = {
"\\1": true,
"\\2": true,
@@ -1746,7 +1746,7 @@ describe("ast-utils", () => {
"foo\\\nbar": false,
"128\\\n349": false
};
- /* eslint-enable quote-props */
+ /* eslint-enable quote-props -- Make consistent here for readability */
Object.keys(expectedResults).forEach(key => {
it(`should return ${expectedResults[key]} for ${key}`, () => {
diff --git a/tests/tools/eslint-fuzzer.js b/tests/tools/eslint-fuzzer.js
index 5527c25cd99..c4bf8c2c47b 100644
--- a/tests/tools/eslint-fuzzer.js
+++ b/tests/tools/eslint-fuzzer.js
@@ -13,7 +13,7 @@ describe("eslint-fuzzer", function() {
* These tests take awhile because isolating which rule caused an error requires running eslint up to hundreds of
* times, one rule at a time.
*/
- this.timeout(15000); // eslint-disable-line no-invalid-this
+ this.timeout(15000); // eslint-disable-line no-invalid-this -- Mocha timeout
const linter = new eslint.Linter();
const coreRules = linter.getRules();
diff --git a/tools/internal-rules/multiline-comment-style.js b/tools/internal-rules/multiline-comment-style.js
index b0a0c9d854f..4492b989d10 100644
--- a/tools/internal-rules/multiline-comment-style.js
+++ b/tools/internal-rules/multiline-comment-style.js
@@ -13,7 +13,7 @@ const multilineCommentStyle = require("../../lib/rules/multiline-comment-style")
//------------------------------------------------------------------------------
// The `no-invalid-meta` internal rule has a false positive here.
-// eslint-disable-next-line internal-rules/no-invalid-meta
+// eslint-disable-next-line internal-rules/no-invalid-meta -- Using rule composer
module.exports = ruleComposer.filterReports(
multilineCommentStyle,
(problem, metadata) => {
diff --git a/tools/internal-testers/event-generator-tester.js b/tools/internal-testers/event-generator-tester.js
index a5ec8e192bf..ce4449a6b6a 100644
--- a/tools/internal-testers/event-generator-tester.js
+++ b/tools/internal-testers/event-generator-tester.js
@@ -4,7 +4,7 @@
*/
"use strict";
-/* global describe, it */
+/* eslint-env mocha -- Mocha */
//------------------------------------------------------------------------------
// Requirements
diff --git a/tools/update-readme.js b/tools/update-readme.js
index 24fe3c01d2b..55efb6f2c52 100644
--- a/tools/update-readme.js
+++ b/tools/update-readme.js
@@ -48,7 +48,7 @@ delete allSponsors.backers;
* @returns {string} The HTML for the members list.
*/
function formatTeamMembers(members) {
- /* eslint-disable indent*/
+ /* eslint-disable indent -- Allow deeper template substitution indent */
return stripIndents`
${
members.map((member, index) => `
@@ -58,7 +58,7 @@ function formatTeamMembers(members) {
| ${(index + 1) % 9 === 0 ? "
" : ""}`).join("")
}
`;
- /* eslint-enable indent*/
+ /* eslint-enable indent -- Allow deeper template substitution indent */
}
/**
@@ -69,7 +69,7 @@ function formatTeamMembers(members) {
function formatSponsors(sponsors) {
const nonEmptySponsors = Object.keys(sponsors).filter(tier => sponsors[tier].length > 0);
- /* eslint-disable indent*/
+ /* eslint-disable indent -- Allow deeper template substitution indent */
return stripIndents`
${
nonEmptySponsors.map(tier => `${tier[0].toUpperCase()}${tier.slice(1)} Sponsors
@@ -78,7 +78,7 @@ function formatSponsors(sponsors) {
}
`).join("")
}
`;
- /* eslint-enable indent*/
+ /* eslint-enable indent -- Allow deeper template substitution indent */
}
//-----------------------------------------------------------------------------
From b290b9db412ed14b5c9942fa05aee4ebadc890e0 Mon Sep 17 00:00:00 2001
From: Brett Zamir
Date: Fri, 20 Aug 2021 10:20:01 +0800
Subject: [PATCH 2/3] Update Makefile.js
Co-authored-by: Bryan Mishkin <698306+bmish@users.noreply.github.com>
---
Makefile.js | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/Makefile.js b/Makefile.js
index 35d0df87165..8c2be3f69c5 100644
--- a/Makefile.js
+++ b/Makefile.js
@@ -3,7 +3,7 @@
* @author nzakas
*/
-/* global target -- How is this being set? */
+/* 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";
From 74aaea5c276cb1d98923b60043ac2a43c2cc7db2 Mon Sep 17 00:00:00 2001
From: Brett Zamir
Date: Sat, 21 Aug 2021 12:41:23 +0800
Subject: [PATCH 3/3] Fix: Avoid eslintrc for tests to avoid requiring comment
description
---
tests/lib/cli-engine/cli-engine.js | 2 ++
tests/lib/eslint/eslint.js | 2 ++
2 files changed, 4 insertions(+)
diff --git a/tests/lib/cli-engine/cli-engine.js b/tests/lib/cli-engine/cli-engine.js
index b3e6ae8faa4..864bd7dda3d 100644
--- a/tests/lib/cli-engine/cli-engine.js
+++ b/tests/lib/cli-engine/cli-engine.js
@@ -5039,6 +5039,7 @@ describe("CLIEngine", () => {
const config = {
envs: ["browser"],
ignore: true,
+ useEslintrc: false,
allowInlineConfig: false,
rules: {
"eol-last": 0,
@@ -5065,6 +5066,7 @@ describe("CLIEngine", () => {
const config = {
envs: ["browser"],
ignore: true,
+ useEslintrc: false,
// allowInlineConfig: true is the default
rules: {
diff --git a/tests/lib/eslint/eslint.js b/tests/lib/eslint/eslint.js
index 28155dd7fdf..1a51a65d841 100644
--- a/tests/lib/eslint/eslint.js
+++ b/tests/lib/eslint/eslint.js
@@ -4952,6 +4952,7 @@ describe("ESLint", () => {
].join("\n");
const config = {
ignore: true,
+ useEslintrc: false,
allowInlineConfig: false,
overrideConfig: {
env: { browser: true },
@@ -4978,6 +4979,7 @@ describe("ESLint", () => {
].join("\n");
const config = {
ignore: true,
+ useEslintrc: false,
allowInlineConfig: true,
overrideConfig: {
env: { browser: true },