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

Add multiline workaround #744

Merged
merged 6 commits into from
May 19, 2021
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
17 changes: 8 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2320,15 +2320,6 @@ const fn = ( lorem, sit ) => {}
const fn = ( lorem, sit ) => {}
// "jsdoc/check-line-alignment": ["error"|"warn", "never",{"customSpacings":{"postName":3}}]
// Message: Expected JSDoc block lines to not be aligned.

/**
* @param {{
* ids: number[]
* }} params
*/
const myMethod = ({ids}) => {}
// "jsdoc/check-line-alignment": ["error"|"warn", "always"]
// Message: Expected JSDoc block lines to be aligned.
````

The following patterns are not considered problems:
Expand Down Expand Up @@ -2576,6 +2567,14 @@ const fn = ( lorem, sit ) => {}
*/
const fn = ( lorem, sit ) => {}
// "jsdoc/check-line-alignment": ["error"|"warn", "never",{"customSpacings":{"postDelimiter":2,"postTag":3,"postType":2}}]

/**
* @param {{
* ids: number[]
* }} params
*/
const fn = ({ids}) => {}
// "jsdoc/check-line-alignment": ["error"|"warn", "always"]
````


Expand Down
5 changes: 5 additions & 0 deletions src/alignTransform.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,11 @@ const alignTransform = ({
}
}

renatho marked this conversation as resolved.
Show resolved Hide resolved
// Todo: Avoid fixing alignment of blocks with multiline wrapping of type
if (tokens.tag === '' && tokens.type) {
return tokens;
}

const spacings = {
postDelimiter: customSpacings?.postDelimiter || 1,
postName: customSpacings?.postName || 1,
Expand Down
43 changes: 11 additions & 32 deletions test/rules/assertions/checkLineAlignment.js
Original file line number Diff line number Diff line change
Expand Up @@ -1057,38 +1057,6 @@ export default {
const fn = ( lorem, sit ) => {}
`,
},
{
/* eslint-disable no-tabs */
code: `
/**
* @param {{
* ids: number[]
* }} params
*/
const myMethod = ({ids}) => {}
`,
errors: [
{
line: 2,
message: 'Expected JSDoc block lines to be aligned.',
type: 'Block',
},
],
options: ['always'],
output: `
/**
* @param {{
* ids: number[]
* }} params
*/
const myMethod = ({ids}) => {}
`,
/* eslint-enable no-tabs */
parser: require.resolve('@babel/eslint-parser'),
parserOptions: {
ecmaVersion: 2_021,
},
},
],
valid: [
{
Expand Down Expand Up @@ -1467,5 +1435,16 @@ export default {
},
}],
},
{
code: `
/**
* @param {{
* ids: number[]
* }} params
*/
const fn = ({ids}) => {}
`,
options: ['always'],
},
],
};