diff --git a/README.md b/README.md index 5ce062133..4a4a7909c 100644 --- a/README.md +++ b/README.md @@ -5293,6 +5293,17 @@ function quux (foo) { */ function quux () { +} +// Message: Types are not permitted on @returns. + +/** + * Beep + * Boop + * + * @returns {number} + */ +function quux () { + } // Message: Types are not permitted on @returns. ```` diff --git a/package.json b/package.json index 0977bf5a5..cd02e8f26 100644 --- a/package.json +++ b/package.json @@ -5,7 +5,7 @@ "url": "http://gajus.com" }, "dependencies": { - "comment-parser": "^0.7.2", + "comment-parser": "^0.7.4", "debug": "^4.1.1", "jsdoctypeparser": "^6.1.0", "lodash": "^4.17.15", @@ -16,12 +16,12 @@ "description": "JSDoc linting rules for ESLint.", "devDependencies": { "@babel/cli": "^7.8.4", - "@babel/core": "^7.9.0", + "@babel/core": "^7.9.6", "@babel/node": "^7.8.7", "@babel/plugin-transform-flow-strip-types": "^7.9.0", - "@babel/preset-env": "^7.9.5", + "@babel/preset-env": "^7.9.6", "@babel/register": "^7.9.0", - "@typescript-eslint/parser": "^2.28.0", + "@typescript-eslint/parser": "^2.31.0", "babel-eslint": "^10.1.0", "babel-plugin-add-module-exports": "^1.0.2", "babel-plugin-istanbul": "^6.0.0", @@ -32,10 +32,10 @@ "gitdown": "^3.1.3", "glob": "^7.1.6", "husky": "^4.2.5", - "mocha": "^7.1.1", + "mocha": "^7.1.2", "nyc": "^15.0.1", "rimraf": "^3.0.2", - "semantic-release": "^17.0.6", + "semantic-release": "^17.0.7", "typescript": "^3.8.3" }, "engines": { diff --git a/src/bin/generateReadme.js b/src/bin/generateReadme.js index 372f7ffb0..96b10d7ab 100644 --- a/src/bin/generateReadme.js +++ b/src/bin/generateReadme.js @@ -8,7 +8,9 @@ import glob from 'glob'; import Gitdown from 'gitdown'; const trimCode = (code) => { - let lines = code.replace(/^\n/u, '').trimEnd().split('\n'); + // todo[engine:node@>10]: Change to `trimEnd` + // eslint-disable-next-line unicorn/prefer-trim-start-end + let lines = code.replace(/^\n/u, '').trimRight().split('\n'); const firsLineIndentation = lines[0].match(/^\s+/u); const lastLineIndentation = lines[lines.length - 1].match(/^\s+/u); diff --git a/src/iterateJsdoc.js b/src/iterateJsdoc.js index e5b896bd1..9bee1688e 100644 --- a/src/iterateJsdoc.js +++ b/src/iterateJsdoc.js @@ -154,6 +154,10 @@ const getUtils = ( utils.stringify = (tagBlock) => { const indent = jsdocUtils.getIndent(sourceCode); + if (ruleConfig.noTrim) { + const lastTag = tagBlock.tags[tagBlock.tags.length - 1]; + lastTag.description = lastTag.description.replace(/\n$/, ''); + } return commentStringify([tagBlock], {indent}).slice(indent.length - 1); }; diff --git a/src/rules/noTypes.js b/src/rules/noTypes.js index e5b75963c..2e908bc12 100644 --- a/src/rules/noTypes.js +++ b/src/rules/noTypes.js @@ -36,4 +36,5 @@ export default iterateJsdoc(({ ], type: 'suggestion', }, + noTrim: true, }); diff --git a/test/rules/assertions/noTypes.js b/test/rules/assertions/noTypes.js index cf9431839..78a973276 100644 --- a/test/rules/assertions/noTypes.js +++ b/test/rules/assertions/noTypes.js @@ -124,6 +124,35 @@ export default { */ function quux () { + } + `, + }, + { + code: ` + /** + * Beep + * Boop + * + * @returns {number} + */ + function quux () { + + } + `, + errors: [ + { + message: 'Types are not permitted on @returns.', + }, + ], + output: ` + /** + * Beep + * Boop + * + * @returns + */ + function quux () { + } `, }, diff --git a/test/rules/assertions/requireParam.js b/test/rules/assertions/requireParam.js index 534f10ab8..cca872c83 100644 --- a/test/rules/assertions/requireParam.js +++ b/test/rules/assertions/requireParam.js @@ -605,7 +605,6 @@ export default { interface ITest { /** * Test description. - * * @param id */ TestMethod(id: number): void; @@ -645,7 +644,6 @@ export default { { /** * A test method. - * * @param id */ abstract TestFunction(id); @@ -712,7 +710,6 @@ export default { output: ` /** * A test function. - * * @param id */ declare let TestFunction: (id) => void; @@ -740,7 +737,6 @@ export default { output: ` /** * A test function. - * * @param id */ let TestFunction: (id) => void; @@ -772,7 +768,6 @@ export default { output: ` /** * A test function. - * * @param id */ function test( @@ -807,7 +802,6 @@ export default { output: ` /** * A test function. - * * @param id */ let test = (processor: (id: number) => string) => @@ -841,7 +835,6 @@ export default { class TestClass { /** * A class property. - * * @param id */ public Test: (id: number) => string; @@ -875,7 +868,6 @@ export default { class TestClass { /** * A class method. - * * @param id */ public TestMethod(): (id: number) => string @@ -909,7 +901,6 @@ export default { interface TestInterface { /** * An interface property. - * * @param id */ public Test: (id: number) => string; @@ -941,7 +932,6 @@ export default { interface TestInterface { /** * An interface method. - * * @param id */ public TestMethod(): (id: number) => string; @@ -970,7 +960,6 @@ export default { output: ` /** * A function with return type - * * @param id */ function test(): (id: number) => string; @@ -1001,7 +990,6 @@ export default { output: ` /** * A function with return type - * * @param id */ let test = (): (id: number) => string =>