-
-
Notifications
You must be signed in to change notification settings - Fork 159
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
480 additions
and
188 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
### `no-blank-blocks` | ||
|
||
Reports and optionally removes blocks with whitespace only. | ||
|
||
#### Options | ||
|
||
##### `enableFixer` | ||
|
||
Whether or not to auto-remove the blank block. Defaults to `false`. | ||
|
||
||| | ||
|---|---| | ||
|Context|everywhere| | ||
|Tags|N/A| | ||
|Recommended|false| | ||
|Settings|| | ||
|Options|`enableFixer`| | ||
|
||
<!-- assertions noBlankBlocks --> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
import iterateJsdoc from '../iterateJsdoc'; | ||
|
||
export default iterateJsdoc(({ | ||
context, | ||
jsdoc, | ||
utils, | ||
}) => { | ||
if (jsdoc.tags.length) { | ||
return; | ||
} | ||
|
||
const { | ||
description, | ||
lastDescriptionLine, | ||
} = utils.getDescription(); | ||
if (description.trim()) { | ||
return; | ||
} | ||
|
||
const { | ||
enableFixer, | ||
} = context.options[0] || {}; | ||
|
||
utils.reportJSDoc( | ||
'No empty blocks', | ||
{ | ||
line: lastDescriptionLine, | ||
}, | ||
enableFixer ? () => { | ||
jsdoc.source.splice(0, jsdoc.source.length); | ||
} : null, | ||
); | ||
}, { | ||
iterateAllJsdocs: true, | ||
meta: { | ||
docs: { | ||
description: 'Removes empty blocks with nothing but possibly line breaks', | ||
url: 'https://github.com/gajus/eslint-plugin-jsdoc#eslint-plugin-jsdoc-rules-no-blank-blocks', | ||
}, | ||
fixable: 'code', | ||
schema: [ | ||
{ | ||
additionalProperties: false, | ||
properties: { | ||
enableFixer: { | ||
type: 'boolean', | ||
}, | ||
}, | ||
}, | ||
], | ||
type: 'suggestion', | ||
}, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,136 @@ | ||
export default { | ||
invalid: [ | ||
{ | ||
code: ` | ||
/** */ | ||
`, | ||
errors: [ | ||
{ | ||
line: 2, | ||
message: 'No empty blocks', | ||
}, | ||
], | ||
options: [ | ||
{ | ||
enableFixer: true, | ||
}, | ||
], | ||
output: ` | ||
`, | ||
}, | ||
{ | ||
code: ` | ||
/** | ||
*/ | ||
`, | ||
errors: [ | ||
{ | ||
line: 2, | ||
message: 'No empty blocks', | ||
}, | ||
], | ||
options: [ | ||
{ | ||
enableFixer: true, | ||
}, | ||
], | ||
output: ` | ||
`, | ||
}, | ||
{ | ||
code: ` | ||
/** | ||
* | ||
*/ | ||
`, | ||
errors: [ | ||
{ | ||
line: 3, | ||
message: 'No empty blocks', | ||
}, | ||
], | ||
options: [ | ||
{ | ||
enableFixer: true, | ||
}, | ||
], | ||
output: ` | ||
`, | ||
}, | ||
{ | ||
code: ` | ||
/** | ||
* | ||
* | ||
*/ | ||
`, | ||
errors: [ | ||
{ | ||
line: 4, | ||
message: 'No empty blocks', | ||
}, | ||
], | ||
options: [ | ||
{ | ||
enableFixer: true, | ||
}, | ||
], | ||
output: ` | ||
`, | ||
}, | ||
{ | ||
code: ` | ||
/** | ||
* | ||
* | ||
*/ | ||
`, | ||
errors: [ | ||
{ | ||
line: 4, | ||
message: 'No empty blocks', | ||
}, | ||
], | ||
options: [ | ||
{ | ||
enableFixer: false, | ||
}, | ||
], | ||
}, | ||
{ | ||
code: ` | ||
/** | ||
* | ||
* | ||
*/ | ||
`, | ||
errors: [ | ||
{ | ||
line: 4, | ||
message: 'No empty blocks', | ||
}, | ||
], | ||
}, | ||
], | ||
valid: [ | ||
{ | ||
code: ` | ||
/** @tag */ | ||
`, | ||
}, | ||
{ | ||
code: ` | ||
/** | ||
* Text | ||
*/ | ||
`, | ||
}, | ||
{ | ||
code: ` | ||
/** | ||
* @tag | ||
*/ | ||
`, | ||
}, | ||
], | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters