From 5c8ef9fda97af4077a65d1734da70e4260486066 Mon Sep 17 00:00:00 2001 From: Brett Zamir Date: Mon, 20 Apr 2020 16:42:59 +0800 Subject: [PATCH] Revert "feat: add a global option for checking constructors, getters or setters and remove `avoidExampleOnConstructors` option." This reverts commit 49f106c1b43331be63e1886f8a50e0b5079a0247. --- .README/rules/require-description.md | 17 +- .README/rules/require-example.md | 18 +- .README/rules/require-param.md | 26 +- .README/rules/require-returns.md | 16 +- README.md | 341 ++------------------ package.json | 12 +- src/iterateJsdoc.js | 28 -- src/rules/requireDescription.js | 12 - src/rules/requireExample.js | 22 +- src/rules/requireParam.js | 12 - src/rules/requireReturns.js | 12 +- test/rules/assertions/requireDescription.js | 186 ----------- test/rules/assertions/requireExample.js | 171 +--------- test/rules/assertions/requireReturns.js | 122 ------- 14 files changed, 86 insertions(+), 909 deletions(-) diff --git a/.README/rules/require-description.md b/.README/rules/require-description.md index 87d6cfc0b..304166552 100644 --- a/.README/rules/require-description.md +++ b/.README/rules/require-description.md @@ -24,16 +24,13 @@ An options object may have any of the following properties: - `descriptionStyle` - Whether to accept implicit descriptions (`"body"`) or `@description` tags (`"tag"`) as satisfying the rule. Set to `"any"` to accept either style. Defaults to `"body"`. -- `checkConstructors` - A value indicating whether `constructor`s should be checked. Defaults to `true`. -- `checkGetters` - A value indicating whether getters should be checked. Defaults to `true`. -- `checkSetters` - A value indicating whether getters should be checked. Defaults to `true`. -| | | -| -------- | ------------------------------------------------------------------------------------------------------------- | -| Context | `ArrowFunctionExpression`, `FunctionDeclaration`, `FunctionExpression`; others when `contexts` option enabled | -| Tags | `description` or jsdoc block | -| Aliases | `desc` | -| Options | `contexts`, `exemptedBy`, `descriptionStyle`, `checkConstructors`, `checkGetters`, `checkSetters` | -| Settings | `overrideReplacesDocs`, `augmentsExtendsReplacesDocs`, `implementsReplacesDocs` | +||| +|---|---| +|Context|`ArrowFunctionExpression`, `FunctionDeclaration`, `FunctionExpression`; others when `contexts` option enabled| +|Tags|`description` or jsdoc block| +|Aliases|`desc`| +|Options|`contexts`, `exemptedBy`, `descriptionStyle`| +|Settings|`overrideReplacesDocs`, `augmentsExtendsReplacesDocs`, `implementsReplacesDocs`| diff --git a/.README/rules/require-example.md b/.README/rules/require-example.md index 9ab47f44b..3afa1e9d6 100644 --- a/.README/rules/require-example.md +++ b/.README/rules/require-example.md @@ -17,6 +17,12 @@ block avoids the need for an `@example`. Defaults to an array with so be sure to add back `inheritdoc` if you wish its presence to cause exemption of the rule. +##### `avoidExampleOnConstructors` + +Set to `true` to avoid the need for an example on a constructor (whether +indicated as such by a jsdoc tag or by being within an ES6 `class`). +Defaults to `false`. + ##### `contexts` Set this to an array of strings representing the AST context @@ -24,18 +30,6 @@ where you wish the rule to be applied (e.g., `ClassDeclaration` for ES6 classes) Overrides the default contexts (see below). Set to `"any"` if you want the rule to apply to any jsdoc block throughout your files. -##### `checkConstructors` - -A value indicating whether `constructor`s should be checked. Defaults to `true`. - -##### `checkGetters` - -A value indicating whether getters should be checked. Defaults to `false`. - -##### `checkSetters` - -A value indicating whether getters should be checked. Defaults to `false`. - #### Fixer The fixer for `require-example` will add an empty `@example`, but it will still diff --git a/.README/rules/require-param.md b/.README/rules/require-param.md index 7d7040c5c..b69fe7dc5 100644 --- a/.README/rules/require-param.md +++ b/.README/rules/require-param.md @@ -22,24 +22,12 @@ contexts (see below). May be useful for adding such as `TSMethodSignature` in TypeScript or restricting the contexts which are checked. -##### `checkConstructors` - -A value indicating whether `constructor`s should be checked. Defaults to `true`. - -##### `checkGetters` - -A value indicating whether getters should be checked. Defaults to `false`. - -##### `checkSetters` - -A value indicating whether getters should be checked. Defaults to `false`. - -| | | -| -------- | ------------------------------------------------------------------------------------------------------------- | -| Context | `ArrowFunctionExpression`, `FunctionDeclaration`, `FunctionExpression`; others when `contexts` option enabled | -| Tags | `param` | -| Aliases | `arg`, `argument` | -| Options | `contexts`, `exemptedBy`, `checkConstructors`, `checkGetters`, `checkSetters` | -| Settings | `overrideReplacesDocs`, `augmentsExtendsReplacesDocs`, `implementsReplacesDocs` | +||| +|---|---| +|Context|`ArrowFunctionExpression`, `FunctionDeclaration`, `FunctionExpression`; others when `contexts` option enabled| +|Tags|`param`| +|Aliases|`arg`, `argument`| +|Options|`contexts`, `exemptedBy`| +|Settings|`overrideReplacesDocs`, `augmentsExtendsReplacesDocs`, `implementsReplacesDocs`| diff --git a/.README/rules/require-returns.md b/.README/rules/require-returns.md index d97b84ce3..f0f822bbb 100644 --- a/.README/rules/require-returns.md +++ b/.README/rules/require-returns.md @@ -6,8 +6,6 @@ Will also report if multiple `@returns` tags are present. #### Options -- `checkConstructors` - A value indicating whether `constructor`s should - be checked for `@returns` tags. Defaults to `false`. - `checkGetters` - Boolean to determine whether getter methods should be checked for `@returns` tags. Defaults to `true`. - `exemptedBy` - Array of tags (e.g., `['type']`) whose presence on the document @@ -42,12 +40,12 @@ Will also report if multiple `@returns` tags are present. 'jsdoc/require-returns': ['error', {forceReturnsWithAsync: true}] ``` -| | | -| -------- | ------------------------------------------------------------------------------------------------------------- | -| Context | `ArrowFunctionExpression`, `FunctionDeclaration`, `FunctionExpression`; others when `contexts` option enabled | -| Tags | `returns` | -| Aliases | `return` | -| Options | `checkConstructors`, `checkGetters`, `contexts`, `exemptedBy`, `forceRequireReturn`, `forceReturnsWithAsync` | -| Settings | `overrideReplacesDocs`, `augmentsExtendsReplacesDocs`, `implementsReplacesDocs` | +||| +|---|---| +|Context|`ArrowFunctionExpression`, `FunctionDeclaration`, `FunctionExpression`; others when `contexts` option enabled| +|Tags|`returns`| +|Aliases|`return`| +|Options|`checkGetters`, `contexts`, `exemptedBy`, `forceRequireReturn`, `forceReturnsWithAsync`| +|Settings|`overrideReplacesDocs`, `augmentsExtendsReplacesDocs`, `implementsReplacesDocs`| diff --git a/README.md b/README.md index e2c3732b5..6253a3b3a 100644 --- a/README.md +++ b/README.md @@ -6431,17 +6431,14 @@ An options object may have any of the following properties: - `descriptionStyle` - Whether to accept implicit descriptions (`"body"`) or `@description` tags (`"tag"`) as satisfying the rule. Set to `"any"` to accept either style. Defaults to `"body"`. -- `checkConstructors` - A value indicating whether `constructor`s should be checked. Defaults to `true`. -- `checkGetters` - A value indicating whether getters should be checked. Defaults to `true`. -- `checkSetters` - A value indicating whether getters should be checked. Defaults to `true`. - -| | | -| -------- | ------------------------------------------------------------------------------------------------------------- | -| Context | `ArrowFunctionExpression`, `FunctionDeclaration`, `FunctionExpression`; others when `contexts` option enabled | -| Tags | `description` or jsdoc block | -| Aliases | `desc` | -| Options | `contexts`, `exemptedBy`, `descriptionStyle`, `checkConstructors`, `checkGetters`, `checkSetters` | -| Settings | `overrideReplacesDocs`, `augmentsExtendsReplacesDocs`, `implementsReplacesDocs` | + +||| +|---|---| +|Context|`ArrowFunctionExpression`, `FunctionDeclaration`, `FunctionExpression`; others when `contexts` option enabled| +|Tags|`description` or jsdoc block| +|Aliases|`desc`| +|Options|`contexts`, `exemptedBy`, `descriptionStyle`| +|Settings|`overrideReplacesDocs`, `augmentsExtendsReplacesDocs`, `implementsReplacesDocs`| The following patterns are considered problems: @@ -6579,57 +6576,6 @@ function quux () { } // Options: [{"exemptedBy":["notPresent"]}] // Message: Missing JSDoc block description. - -class TestClass { - /** - * - */ - constructor() { } -} -// Message: Missing JSDoc block description. - -class TestClass { - /** - * - */ - constructor() { } -} -// Options: [{"checkConstructors":true}] -// Message: Missing JSDoc block description. - -class TestClass { - /** - * - */ - get Test() { } -} -// Message: Missing JSDoc block description. - -class TestClass { - /** - * - */ - get Test() { } -} -// Options: [{"checkGetters":true}] -// Message: Missing JSDoc block description. - -class TestClass { - /** - * - */ - set Test(value) { } -} -// Message: Missing JSDoc block description. - -class TestClass { - /** - * - */ - set Test(value) { } -} -// Options: [{"checkSetters":true}] -// Message: Missing JSDoc block description. ```` The following patterns are not considered problems: @@ -6755,51 +6701,6 @@ function quux () { } // Settings: {"jsdoc":{"tagNamePreference":{"description":false}}} - -class TestClass { - /** - * Test. - */ - constructor() { } -} - -class TestClass { - /** - * - */ - constructor() { } -} -// Options: [{"checkConstructors":false}] - -class TestClass { - /** - * Test. - */ - get Test() { } -} - -class TestClass { - /** - * - */ - get Test() { } -} -// Options: [{"checkGetters":false}] - -class TestClass { - /** - * Test. - */ - set Test(value) { } -} - -class TestClass { - /** - * - */ - set Test(value) { } -} -// Options: [{"checkSetters":false}] ```` @@ -6825,6 +6726,13 @@ block avoids the need for an `@example`. Defaults to an array with so be sure to add back `inheritdoc` if you wish its presence to cause exemption of the rule. + +##### avoidExampleOnConstructors + +Set to `true` to avoid the need for an example on a constructor (whether +indicated as such by a jsdoc tag or by being within an ES6 `class`). +Defaults to `false`. + ##### contexts @@ -6833,21 +6741,6 @@ where you wish the rule to be applied (e.g., `ClassDeclaration` for ES6 classes) Overrides the default contexts (see below). Set to `"any"` if you want the rule to apply to any jsdoc block throughout your files. - -##### checkConstructors - -A value indicating whether `constructor`s should be checked. Defaults to `true`. - - -##### checkGetters - -A value indicating whether getters should be checked. Defaults to `false`. - - -##### checkSetters - -A value indicating whether getters should be checked. Defaults to `false`. - #### Fixer @@ -6928,42 +6821,6 @@ function quux () { } // Options: [{"exemptedBy":["notPresent"]}] // Message: Missing JSDoc @example declaration. - -class TestClass { - /** - * - */ - get Test() { } -} -// Options: [{"checkGetters":true}] -// Message: Missing JSDoc @example declaration. - -class TestClass { - /** - * @example - */ - get Test() { } -} -// Options: [{"checkGetters":true}] -// Message: Missing JSDoc @example description. - -class TestClass { - /** - * - */ - set Test(value) { } -} -// Options: [{"checkSetters":true}] -// Message: Missing JSDoc @example declaration. - -class TestClass { - /** - * @example - */ - set Test(value) { } -} -// Options: [{"checkSetters":true}] -// Message: Missing JSDoc @example description. ```` The following patterns are not considered problems: @@ -7006,7 +6863,7 @@ function quux () { function quux () { } -// Options: [{"checkConstructors":false}] +// Options: [{"avoidExampleOnConstructors":true}] /** * @constructor @@ -7015,7 +6872,7 @@ function quux () { function quux () { } -// Options: [{"checkConstructors":false}] +// Options: [{"avoidExampleOnConstructors":true}] class Foo { /** @@ -7025,7 +6882,7 @@ class Foo { } } -// Options: [{"checkConstructors":false}] +// Options: [{"avoidExampleOnConstructors":true}] /** * @inheritdoc @@ -7057,51 +6914,6 @@ function quux () { } // Options: [{"contexts":["ClassDeclaration"]}] - -class TestClass { - /** - * - */ - get Test() { } -} - -class TestClass { - /** - * @example - */ - get Test() { } -} - -class TestClass { - /** - * @example Test - */ - get Test() { } -} -// Options: [{"checkGetters":true}] - -class TestClass { - /** - * - */ - set Test(value) { } -} - -class TestClass { - /** - * @example - */ - set Test(value) { } -} -// Options: [{"checkSetters":false}] - -class TestClass { - /** - * @example Test - */ - set Test(value) { } -} -// Options: [{"checkSetters":true}] ```` @@ -9006,28 +8818,13 @@ contexts (see below). May be useful for adding such as `TSMethodSignature` in TypeScript or restricting the contexts which are checked. - -##### checkConstructors - -A value indicating whether `constructor`s should be checked. Defaults to `true`. - - -##### checkGetters - -A value indicating whether getters should be checked. Defaults to `false`. - - -##### checkSetters - -A value indicating whether getters should be checked. Defaults to `false`. - -| | | -| -------- | ------------------------------------------------------------------------------------------------------------- | -| Context | `ArrowFunctionExpression`, `FunctionDeclaration`, `FunctionExpression`; others when `contexts` option enabled | -| Tags | `param` | -| Aliases | `arg`, `argument` | -| Options | `contexts`, `exemptedBy`, `checkConstructors`, `checkGetters`, `checkSetters` | -| Settings | `overrideReplacesDocs`, `augmentsExtendsReplacesDocs`, `implementsReplacesDocs` | +||| +|---|---| +|Context|`ArrowFunctionExpression`, `FunctionDeclaration`, `FunctionExpression`; others when `contexts` option enabled| +|Tags|`param`| +|Aliases|`arg`, `argument`| +|Options|`contexts`, `exemptedBy`| +|Settings|`overrideReplacesDocs`, `augmentsExtendsReplacesDocs`, `implementsReplacesDocs`| The following patterns are considered problems: @@ -10733,8 +10530,6 @@ Will also report if multiple `@returns` tags are present. #### Options -- `checkConstructors` - A value indicating whether `constructor`s should - be checked for `@returns` tags. Defaults to `false`. - `checkGetters` - Boolean to determine whether getter methods should be checked for `@returns` tags. Defaults to `true`. - `exemptedBy` - Array of tags (e.g., `['type']`) whose presence on the document @@ -10769,13 +10564,13 @@ Will also report if multiple `@returns` tags are present. 'jsdoc/require-returns': ['error', {forceReturnsWithAsync: true}] ``` -| | | -| -------- | ------------------------------------------------------------------------------------------------------------- | -| Context | `ArrowFunctionExpression`, `FunctionDeclaration`, `FunctionExpression`; others when `contexts` option enabled | -| Tags | `returns` | -| Aliases | `return` | -| Options | `checkConstructors`, `checkGetters`, `contexts`, `exemptedBy`, `forceRequireReturn`, `forceReturnsWithAsync` | -| Settings | `overrideReplacesDocs`, `augmentsExtendsReplacesDocs`, `implementsReplacesDocs` | +||| +|---|---| +|Context|`ArrowFunctionExpression`, `FunctionDeclaration`, `FunctionExpression`; others when `contexts` option enabled| +|Tags|`returns`| +|Aliases|`return`| +|Options|`checkGetters`, `contexts`, `exemptedBy`, `forceRequireReturn`, `forceReturnsWithAsync`| +|Settings|`overrideReplacesDocs`, `augmentsExtendsReplacesDocs`, `implementsReplacesDocs`| The following patterns are considered problems: @@ -10974,28 +10769,6 @@ class foo { } // Options: [{"checkGetters":true}] // Message: Missing JSDoc @returns declaration. - -class TestClass { - /** - * - */ - constructor() { - return new Map(); - } -} -// Options: [{"checkConstructors":true}] -// Message: Missing JSDoc @returns declaration. - -class TestClass { - /** - * - */ - get Test() { - return 0; - } -} -// Options: [{"checkGetters":true}] -// Message: Missing JSDoc @returns declaration. ```` The following patterns are not considered problems: @@ -11352,56 +11125,6 @@ class foo { } } // Options: [{"checkGetters":false}] - -class TestClass { - /** - * - */ - constructor() { } -} - -class TestClass { - /** - * @returns A map. - */ - constructor() { - return new Map(); - } -} - -class TestClass { - /** - * - */ - constructor() { } -} -// Options: [{"checkConstructors":false}] - -class TestClass { - /** - * - */ - get Test() { } -} - -class TestClass { - /** - * @returns A number. - */ - get Test() { - return 0; - } -} - -class TestClass { - /** - * - */ - get Test() { - return 0; - } -} -// Options: [{"checkGetters":false}] ```` diff --git a/package.json b/package.json index 0977bf5a5..3f6b7d886 100644 --- a/package.json +++ b/package.json @@ -26,7 +26,6 @@ "babel-plugin-add-module-exports": "^1.0.2", "babel-plugin-istanbul": "^6.0.0", "chai": "^4.2.0", - "cross-env": "^7.0.2", "eslint": "6.8.0", "eslint-config-canonical": "^19.0.4", "gitdown": "^3.1.3", @@ -34,7 +33,6 @@ "husky": "^4.2.5", "mocha": "^7.1.1", "nyc": "^15.0.1", - "rimraf": "^3.0.2", "semantic-release": "^17.0.6", "typescript": "^3.8.3" }, @@ -62,15 +60,15 @@ "url": "https://github.com/gajus/eslint-plugin-jsdoc" }, "scripts": { - "build": "rimraf ./dist && cross-env NODE_ENV=production babel ./src --out-dir ./dist --copy-files --source-maps --ignore ./src/bin/*.js --no-copy-ignored", + "build": "rm -fr ./dist && NODE_ENV=production babel ./src --out-dir ./dist --copy-files --source-maps --ignore ./src/bin/*.js --no-copy-ignored", "check-readme": "babel-node ./src/bin/generateReadme.js --check", "create-readme": "babel-node ./src/bin/generateReadme.js", "lint-fix": "eslint --report-unused-disable-directives --fix ./src ./test", "lint": "eslint --report-unused-disable-directives ./src ./test", - "test-cov": "cross-env BABEL_ENV=test nyc mocha --recursive --require @babel/register --reporter progress --timeout 9000", - "test-no-cov": "cross-env BABEL_ENV=test mocha --recursive --require @babel/register --reporter progress --timeout 9000", - "test-index": "cross-env BABEL_ENV=test mocha --recursive --require @babel/register --reporter progress --timeout 9000 test/rules/index.js", - "test": "cross-env BABEL_ENV=test nyc --reporter text-summary mocha --recursive --require @babel/register --reporter progress --timeout 9000" + "test-cov": "BABEL_ENV=test nyc mocha --recursive --require @babel/register --reporter progress --timeout 9000", + "test-no-cov": "BABEL_ENV=test mocha --recursive --require @babel/register --reporter progress --timeout 9000", + "test-index": "BABEL_ENV=test mocha --recursive --require @babel/register --reporter progress --timeout 9000 test/rules/index.js", + "test": "BABEL_ENV=test nyc --reporter text-summary mocha --recursive --require @babel/register --reporter progress --timeout 9000" }, "nyc": { "require": [ diff --git a/src/iterateJsdoc.js b/src/iterateJsdoc.js index 00229c9d0..f05820d45 100644 --- a/src/iterateJsdoc.js +++ b/src/iterateJsdoc.js @@ -123,7 +123,6 @@ const getUtils = ( report, context, iteratingAll, - ruleConfig, ) => { const ancestors = context.getAncestors(); const sourceCode = context.getSourceCode(); @@ -232,17 +231,6 @@ const getUtils = ( return jsdocUtils.hasTag(jsdoc, name); }; - const hasSchemaOption = (prop) => { - const schemaProperties = ruleConfig.meta.schema[0].properties; - - return _.get( - context, - `options[0].${prop}`, - schemaProperties[prop] && schemaProperties[prop].default, - ); - }; - - // eslint-disable-next-line complexity utils.avoidDocs = () => { if ( overrideReplacesDocs !== false && @@ -257,21 +245,6 @@ const getUtils = ( return true; } - if ( - !hasSchemaOption('checkConstructors') && - ( - utils.isConstructor() || - utils.hasATag([ - 'class', - 'constructor', - ])) || - !hasSchemaOption('checkGetters') && - utils.isGetter() || - !hasSchemaOption('checkSetters') && - utils.isSetter()) { - return true; - } - const exemptedBy = _.get( context, 'options[0].exemptedBy', [ 'inheritDoc', @@ -505,7 +478,6 @@ const iterate = ( report, context, iteratingAll, - ruleConfig, ); if ( diff --git a/src/rules/requireDescription.js b/src/rules/requireDescription.js index 078276e07..a00e2544f 100644 --- a/src/rules/requireDescription.js +++ b/src/rules/requireDescription.js @@ -74,18 +74,6 @@ export default iterateJsdoc(({ { additionalProperties: false, properties: { - checkConstructors: { - default: true, - type: 'boolean', - }, - checkGetters: { - default: true, - type: 'boolean', - }, - checkSetters: { - default: true, - type: 'boolean', - }, contexts: { items: { type: 'string', diff --git a/src/rules/requireExample.js b/src/rules/requireExample.js index f96106d7d..84a5c64ed 100644 --- a/src/rules/requireExample.js +++ b/src/rules/requireExample.js @@ -14,12 +14,24 @@ export default iterateJsdoc(({ return; } + const {avoidExampleOnConstructors = false} = context.options[0] || {}; + const targetTagName = 'example'; const functionExamples = _.filter(jsdoc.tags, { tag: targetTagName, }); + if (avoidExampleOnConstructors && ( + utils.hasATag([ + 'class', + 'constructor', + ]) || + utils.isConstructor() + )) { + return; + } + if (!functionExamples.length) { utils.reportJSDoc(`Missing JSDoc @${targetTagName} declaration.`, null, () => { if (!jsdoc.tags) { @@ -54,15 +66,7 @@ export default iterateJsdoc(({ { additionalProperties: false, properties: { - checkConstructors: { - default: true, - type: 'boolean', - }, - checkGetters: { - default: false, - type: 'boolean', - }, - checkSetters: { + avoidExampleOnConstructors: { default: false, type: 'boolean', }, diff --git a/src/rules/requireParam.js b/src/rules/requireParam.js index 3a056742f..0893bc8af 100644 --- a/src/rules/requireParam.js +++ b/src/rules/requireParam.js @@ -84,18 +84,6 @@ export default iterateJsdoc(({ { additionalProperties: false, properties: { - checkConstructors: { - default: true, - type: 'boolean', - }, - checkGetters: { - default: false, - type: 'boolean', - }, - checkSetters: { - default: false, - type: 'boolean', - }, contexts: { items: { type: 'string', diff --git a/src/rules/requireReturns.js b/src/rules/requireReturns.js index 355f452fb..f45711316 100644 --- a/src/rules/requireReturns.js +++ b/src/rules/requireReturns.js @@ -12,7 +12,7 @@ import warnRemovedSettings from '../warnRemovedSettings'; * @returns {boolean} * true in case deep checking can be skipped; otherwise false. */ -const canSkip = (utils) => { +const canSkip = (utils, checkGetters) => { return utils.hasATag([ // inheritdoc implies that all documentation is inherited // see https://jsdoc.app/tags-inheritdoc.html @@ -33,6 +33,9 @@ const canSkip = (utils) => { // This seems to imply a class as well 'interface', ]) || + utils.isConstructor() || + !checkGetters && utils.isGetter() || + utils.isSetter() || utils.avoidDocs(); }; @@ -46,11 +49,12 @@ export default iterateJsdoc(({ const { forceRequireReturn = false, forceReturnsWithAsync = false, + checkGetters = true, } = context.options[0] || {}; // A preflight check. We do not need to run a deep check // in case the @returns comment is optional or undefined. - if (canSkip(utils)) { + if (canSkip(utils, checkGetters)) { return; } @@ -101,10 +105,6 @@ export default iterateJsdoc(({ { additionalProperties: false, properties: { - checkConstructors: { - default: false, - type: 'boolean', - }, checkGetters: { default: true, type: 'boolean', diff --git a/test/rules/assertions/requireDescription.js b/test/rules/assertions/requireDescription.js index b3936964d..34b59ec72 100644 --- a/test/rules/assertions/requireDescription.js +++ b/test/rules/assertions/requireDescription.js @@ -335,117 +335,6 @@ export default { }, ], }, - { - code: ` - class TestClass { - /** - * - */ - constructor() { } - } - `, - errors: [ - { - line: 3, - message: 'Missing JSDoc block description.', - }, - ], - }, - { - code: ` - class TestClass { - /** - * - */ - constructor() { } - } - `, - errors: [ - { - line: 3, - message: 'Missing JSDoc block description.', - }, - ], - options: [ - { - checkConstructors: true, - }, - ], - }, - { - code: ` - class TestClass { - /** - * - */ - get Test() { } - } - `, - errors: [ - { - line: 3, - message: 'Missing JSDoc block description.', - }, - ], - }, - { - code: ` - class TestClass { - /** - * - */ - get Test() { } - } - `, - errors: [ - { - line: 3, - message: 'Missing JSDoc block description.', - }, - ], - options: [ - { - checkGetters: true, - }, - ], - }, - { - code: ` - class TestClass { - /** - * - */ - set Test(value) { } - } - `, - errors: [ - { - line: 3, - message: 'Missing JSDoc block description.', - }, - ], - }, - { - code: ` - class TestClass { - /** - * - */ - set Test(value) { } - } - `, - errors: [ - { - line: 3, - message: 'Missing JSDoc block description.', - }, - ], - options: [ - { - checkSetters: true, - }, - ], - }, ], valid: [ { @@ -669,80 +558,5 @@ export default { }, }, }, - { - code: ` - class TestClass { - /** - * Test. - */ - constructor() { } - } - `, - }, - { - code: ` - class TestClass { - /** - * - */ - constructor() { } - } - `, - options: [ - { - checkConstructors: false, - }, - ], - }, - { - code: ` - class TestClass { - /** - * Test. - */ - get Test() { } - } - `, - }, - { - code: ` - class TestClass { - /** - * - */ - get Test() { } - } - `, - options: [ - { - checkGetters: false, - }, - ], - }, - { - code: ` - class TestClass { - /** - * Test. - */ - set Test(value) { } - } - `, - }, - { - code: ` - class TestClass { - /** - * - */ - set Test(value) { } - } - `, - options: [ - { - checkSetters: false, - }, - ], - }, ], }; diff --git a/test/rules/assertions/requireExample.js b/test/rules/assertions/requireExample.js index 2628dd49b..dddf59d12 100644 --- a/test/rules/assertions/requireExample.js +++ b/test/rules/assertions/requireExample.js @@ -149,90 +149,6 @@ export default { }, ], }, - { - code: ` - class TestClass { - /** - * - */ - get Test() { } - } - `, - errors: [ - { - line: 3, - message: 'Missing JSDoc @example declaration.', - }, - ], - options: [ - { - checkGetters: true, - }, - ], - }, - { - code: ` - class TestClass { - /** - * @example - */ - get Test() { } - } - `, - errors: [ - { - line: 3, - message: 'Missing JSDoc @example description.', - }, - ], - options: [ - { - checkGetters: true, - }, - ], - }, - { - code: ` - class TestClass { - /** - * - */ - set Test(value) { } - } - `, - errors: [ - { - line: 3, - message: 'Missing JSDoc @example declaration.', - }, - ], - options: [ - { - checkSetters: true, - }, - ], - }, - { - code: ` - class TestClass { - /** - * @example - */ - set Test(value) { } - } - `, - errors: [ - { - line: 3, - message: 'Missing JSDoc @example description.', - }, - ], - options: [ - { - checkSetters: true, - }, - ], - }, ], valid: [ { @@ -288,9 +204,7 @@ export default { } `, options: [ - { - checkConstructors: false, - }, + {avoidExampleOnConstructors: true}, ], }, { @@ -304,9 +218,7 @@ export default { } `, options: [ - { - checkConstructors: false, - }, + {avoidExampleOnConstructors: true}, ], }, { @@ -321,9 +233,7 @@ export default { } `, options: [ - { - checkConstructors: false, - }, + {avoidExampleOnConstructors: true}, ], }, { @@ -381,80 +291,5 @@ export default { }, ], }, - { - code: ` - class TestClass { - /** - * - */ - get Test() { } - } - `, - }, - { - code: ` - class TestClass { - /** - * @example - */ - get Test() { } - } - `, - }, - { - code: ` - class TestClass { - /** - * @example Test - */ - get Test() { } - } - `, - options: [ - { - checkGetters: true, - }, - ], - }, - { - code: ` - class TestClass { - /** - * - */ - set Test(value) { } - } - `, - }, - { - code: ` - class TestClass { - /** - * @example - */ - set Test(value) { } - } - `, - options: [ - { - checkSetters: false, - }, - ], - }, - { - code: ` - class TestClass { - /** - * @example Test - */ - set Test(value) { } - } - `, - options: [ - { - checkSetters: true, - }, - ], - }, ], }; diff --git a/test/rules/assertions/requireReturns.js b/test/rules/assertions/requireReturns.js index c349368c4..c8932d6df 100644 --- a/test/rules/assertions/requireReturns.js +++ b/test/rules/assertions/requireReturns.js @@ -462,52 +462,6 @@ export default { ecmaVersion: 8, }, }, - { - code: ` - class TestClass { - /** - * - */ - constructor() { - return new Map(); - } - } - `, - errors: [ - { - line: 3, - message: 'Missing JSDoc @returns declaration.', - }, - ], - options: [ - { - checkConstructors: true, - }, - ], - }, - { - code: ` - class TestClass { - /** - * - */ - get Test() { - return 0; - } - } - `, - errors: [ - { - line: 3, - message: 'Missing JSDoc @returns declaration.', - }, - ], - options: [ - { - checkGetters: true, - }, - ], - }, ], valid: [ { @@ -1103,81 +1057,5 @@ export default { ecmaVersion: 8, }, }, - { - code: ` - class TestClass { - /** - * - */ - constructor() { } - } - `, - }, - { - code: ` - class TestClass { - /** - * @returns A map. - */ - constructor() { - return new Map(); - } - } - `, - }, - { - code: ` - class TestClass { - /** - * - */ - constructor() { } - } - `, - options: [ - { - checkConstructors: false, - }, - ], - }, - { - code: ` - class TestClass { - /** - * - */ - get Test() { } - } - `, - }, - { - code: ` - class TestClass { - /** - * @returns A number. - */ - get Test() { - return 0; - } - } - `, - }, - { - code: ` - class TestClass { - /** - * - */ - get Test() { - return 0; - } - } - `, - options: [ - { - checkGetters: false, - }, - ], - }, ], };