Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Chore: enable jsdoc/require-description #12365

Merged
merged 1 commit into from Oct 10, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions lib/cli-engine/cascading-config-array-factory.js
Expand Up @@ -152,6 +152,7 @@ function createCLIConfigArray({
*/
class ConfigurationNotFoundError extends Error {

// eslint-disable-next-line jsdoc/require-description
/**
* @param {string} directoryPath The directory path.
*/
Expand Down
2 changes: 2 additions & 0 deletions lib/cli-engine/config-array/config-dependency.js
Expand Up @@ -81,6 +81,7 @@ class ConfigDependency {
this.importerPath = importerPath;
}

// eslint-disable-next-line jsdoc/require-description
/**
* @returns {Object} a JSON compatible object.
*/
Expand All @@ -95,6 +96,7 @@ class ConfigDependency {
return obj;
}

// eslint-disable-next-line jsdoc/require-description
/**
* @returns {Object} an object to display by `console.log()`.
*/
Expand Down
2 changes: 2 additions & 0 deletions lib/cli-engine/config-array/override-tester.js
Expand Up @@ -166,6 +166,7 @@ class OverrideTester {
));
}

// eslint-disable-next-line jsdoc/require-description
/**
* @returns {Object} a JSON compatible object.
*/
Expand All @@ -182,6 +183,7 @@ class OverrideTester {
};
}

// eslint-disable-next-line jsdoc/require-description
/**
* @returns {Object} an object to display by `console.log()`.
*/
Expand Down
2 changes: 2 additions & 0 deletions lib/cli-engine/file-enumerator.js
Expand Up @@ -149,6 +149,7 @@ function readdirSafeSync(directoryPath) {
*/
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 @@ -165,6 +166,7 @@ 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
1 change: 1 addition & 0 deletions lib/cli-engine/formatters/html.js
Expand Up @@ -96,6 +96,7 @@ function renderMessages(messages, parentIndex, rulesMeta) {
}).join("\n");
}

// eslint-disable-next-line jsdoc/require-description
/**
* @param {Array} results Test results.
* @param {Object} rulesMeta Dictionary containing metadata for each rule executed by the analysis.
Expand Down
1 change: 1 addition & 0 deletions lib/cli-engine/ignored-paths.js
Expand Up @@ -121,6 +121,7 @@ function relativize(globPattern, relativePathToOldBaseDir) {
*/
class IgnoredPaths {

// eslint-disable-next-line jsdoc/require-description
/**
* @param {Object} providedOptions object containing 'ignore', 'ignorePath' and 'patterns' properties
*/
Expand Down
1 change: 1 addition & 0 deletions lib/init/autoconfig.js
Expand Up @@ -69,6 +69,7 @@ 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
1 change: 1 addition & 0 deletions lib/init/config-rule.js
Expand Up @@ -174,6 +174,7 @@ function combinePropertyObjects(objArr1, objArr2) {
*/
class RuleConfigSet {

// eslint-disable-next-line jsdoc/require-description
/**
* @param {ruleConfig[]} configs Valid rule configurations
*/
Expand Down
1 change: 1 addition & 0 deletions lib/linter/code-path-analysis/code-path-analyzer.js
Expand Up @@ -597,6 +597,7 @@ 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: 1 addition & 0 deletions lib/linter/code-path-analysis/code-path-segment.js
Expand Up @@ -33,6 +33,7 @@ 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: 1 addition & 0 deletions lib/linter/code-path-analysis/code-path-state.js
Expand Up @@ -218,6 +218,7 @@ 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: 1 addition & 0 deletions lib/linter/code-path-analysis/code-path.js
Expand Up @@ -21,6 +21,7 @@ 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
1 change: 1 addition & 0 deletions lib/linter/code-path-analysis/fork-context.js
Expand Up @@ -97,6 +97,7 @@ 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: 1 addition & 0 deletions lib/linter/code-path-analysis/id-generator.js
Expand Up @@ -18,6 +18,7 @@
*/
class IdGenerator {

// eslint-disable-next-line jsdoc/require-description
/**
* @param {string} prefix Optional. A prefix of generated ids.
*/
Expand Down
1 change: 1 addition & 0 deletions lib/linter/node-event-generator.js
Expand Up @@ -202,6 +202,7 @@ const parseSelector = lodash.memoize(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
1 change: 1 addition & 0 deletions lib/rules/default-param-last.js
Expand Up @@ -25,6 +25,7 @@ module.exports = {

create(context) {

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

// eslint-disable-next-line jsdoc/require-description
/**
* @param {SourceCode} sourceCode A SourceCode object
*/
Expand Down Expand Up @@ -236,6 +237,7 @@ 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
1 change: 1 addition & 0 deletions lib/rules/no-dupe-keys.js
Expand Up @@ -23,6 +23,7 @@ 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
4 changes: 4 additions & 0 deletions lib/rules/no-unused-expressions.js
Expand Up @@ -47,6 +47,7 @@ module.exports = {
allowTernary = config.allowTernary || false,
allowTaggedTemplates = config.allowTaggedTemplates || false;

// eslint-disable-next-line jsdoc/require-description
/**
* @param {ASTNode} node any node
* @returns {boolean} whether the given node structurally represents a directive
Expand All @@ -56,6 +57,7 @@ module.exports = {
node.expression.type === "Literal" && typeof node.expression.value === "string";
}

// eslint-disable-next-line jsdoc/require-description
/**
* @param {Function} predicate ([a] -> Boolean) the function used to make the determination
* @param {a[]} list the input list
Expand All @@ -70,6 +72,7 @@ module.exports = {
return list.slice();
}

// eslint-disable-next-line jsdoc/require-description
/**
* @param {ASTNode} node a Program or BlockStatement node
* @returns {ASTNode[]} the leading sequence of directive nodes in the given node's body
Expand All @@ -78,6 +81,7 @@ module.exports = {
return takeWhile(looksLikeDirective, node.body);
}

// eslint-disable-next-line jsdoc/require-description
/**
* @param {ASTNode} node any node
* @param {ASTNode[]} ancestors the given node's ancestors
Expand Down
1 change: 1 addition & 0 deletions lib/rules/prefer-destructuring.js
Expand Up @@ -103,6 +103,7 @@ module.exports = {
// Helpers
//--------------------------------------------------------------------------

// eslint-disable-next-line jsdoc/require-description
/**
* @param {string} nodeType "AssignmentExpression" or "VariableDeclarator"
* @param {string} destructuringType "array" or "object"
Expand Down
1 change: 1 addition & 0 deletions lib/rules/vars-on-top.js
Expand Up @@ -32,6 +32,7 @@ module.exports = {
// Helpers
//--------------------------------------------------------------------------

// eslint-disable-next-line jsdoc/require-description
/**
* @param {ASTNode} node any node
* @returns {boolean} whether the given node structurally represents a directive
Expand Down
2 changes: 2 additions & 0 deletions lib/shared/traverser.js
Expand Up @@ -65,13 +65,15 @@ class Traverser {
this._leave = null;
}

// eslint-disable-next-line jsdoc/require-description
/**
* @returns {ASTNode} The current node.
*/
current() {
return this._current;
}

// eslint-disable-next-line jsdoc/require-description
/**
* @returns {ASTNode[]} The ancestor nodes.
*/
Expand Down
1 change: 1 addition & 0 deletions packages/eslint-config-eslint/default.yml
Expand Up @@ -48,6 +48,7 @@ rules:
jsdoc/check-types: "error"
jsdoc/implements-on-classes: "error"
jsdoc/newline-after-description: ["error", "never"]
jsdoc/require-description: "error"
jsdoc/require-hyphen-before-param-description: ["error", "never"]
jsdoc/require-jsdoc: "error"
jsdoc/require-param: "error"
Expand Down
2 changes: 1 addition & 1 deletion tests/lib/rule-tester/rule-tester.js
Expand Up @@ -67,7 +67,7 @@ describe("RuleTester", () => {
let ruleTester;

/**
* @description A helper function to verify Node.js core error messages.
* A helper function to verify Node.js core error messages.
Copy link
Member Author

@kaicataldo kaicataldo Oct 3, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The default configuration doesn't check for @description tags. We can use descriptionStyle: "any" to allow both styles, but since this is the only instance in our codebase, it seemed like a good idea to just go with the default behavior. Happy to change it if others disagree, though.

* @param {string} actual The actual input
* @param {string} expected The expected input
* @returns {Function} Error callback to verify that the message is correct
Expand Down