Skip to content

test(no-types): check that the fix for no-types preserves asterisks #447

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

Merged
merged 2 commits into from
May 6, 2020
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
````
Expand Down
12 changes: 6 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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",
Expand All @@ -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": {
Expand Down
4 changes: 3 additions & 1 deletion src/bin/generateReadme.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
4 changes: 4 additions & 0 deletions src/iterateJsdoc.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
};
Expand Down
1 change: 1 addition & 0 deletions src/rules/noTypes.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,5 @@ export default iterateJsdoc(({
],
type: 'suggestion',
},
noTrim: true,
});
29 changes: 29 additions & 0 deletions test/rules/assertions/noTypes.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 () {

}
`,
},
Expand Down
12 changes: 0 additions & 12 deletions test/rules/assertions/requireParam.js
Original file line number Diff line number Diff line change
Expand Up @@ -605,7 +605,6 @@ export default {
interface ITest {
/**
* Test description.
*
* @param id
*/
TestMethod(id: number): void;
Expand Down Expand Up @@ -645,7 +644,6 @@ export default {
{
/**
* A test method.
*
* @param id
*/
abstract TestFunction(id);
Expand Down Expand Up @@ -712,7 +710,6 @@ export default {
output: `
/**
* A test function.
*
* @param id
*/
declare let TestFunction: (id) => void;
Expand Down Expand Up @@ -740,7 +737,6 @@ export default {
output: `
/**
* A test function.
*
* @param id
*/
let TestFunction: (id) => void;
Expand Down Expand Up @@ -772,7 +768,6 @@ export default {
output: `
/**
* A test function.
*
* @param id
*/
function test(
Expand Down Expand Up @@ -807,7 +802,6 @@ export default {
output: `
/**
* A test function.
*
* @param id
*/
let test = (processor: (id: number) => string) =>
Expand Down Expand Up @@ -841,7 +835,6 @@ export default {
class TestClass {
/**
* A class property.
*
* @param id
*/
public Test: (id: number) => string;
Expand Down Expand Up @@ -875,7 +868,6 @@ export default {
class TestClass {
/**
* A class method.
*
* @param id
*/
public TestMethod(): (id: number) => string
Expand Down Expand Up @@ -909,7 +901,6 @@ export default {
interface TestInterface {
/**
* An interface property.
*
* @param id
*/
public Test: (id: number) => string;
Expand Down Expand Up @@ -941,7 +932,6 @@ export default {
interface TestInterface {
/**
* An interface method.
*
* @param id
*/
public TestMethod(): (id: number) => string;
Expand Down Expand Up @@ -970,7 +960,6 @@ export default {
output: `
/**
* A function with return type
*
* @param id
*/
function test(): (id: number) => string;
Expand Down Expand Up @@ -1001,7 +990,6 @@ export default {
output: `
/**
* A function with return type
*
* @param id
*/
let test = (): (id: number) => string =>
Expand Down