Permalink
Jump to Line
Branch:
master
Switch branches/tags
dollar-ignores
feature/new-rule-require-new-lines-in-array
gh-pages
issues/1242
issues/1271-related
master
mdevils/cst
Nothing to show
Nothing to show
Fetching contributors…
![]()
Cannot retrieve contributors at this time
| /** | |
| * Disallows multiple blank lines in a row. | |
| * | |
| * Type: `Boolean` | |
| * | |
| * Value: `true` | |
| * | |
| * #### Example | |
| * | |
| * ```js | |
| * "disallowMultipleLineBreaks": true | |
| * ``` | |
| * | |
| * ##### Valid | |
| * ```js | |
| * var x = 1; | |
| * | |
| * x++; | |
| * ``` | |
| * | |
| * ##### Invalid | |
| * ```js | |
| * var x = 1; | |
| * | |
| * | |
| * x++; | |
| * ``` | |
| */ | |
| var assert = require('assert'); | |
| module.exports = function() {}; | |
| module.exports.prototype = { | |
| configure: function(options) { | |
| assert( | |
| options === true, | |
| this.getOptionName() + ' option requires a true value or should be removed' | |
| ); | |
| }, | |
| getOptionName: function() { | |
| return 'disallowMultipleLineBreaks'; | |
| }, | |
| check: function(file, errors) { | |
| // Iterate over all tokens (including comments) | |
| file.getTokens().forEach(function(token, index, tokens) { | |
| // If there are no trailing tokens, exit early | |
| var nextToken = tokens[index + 1]; | |
| if (!nextToken) { | |
| return; | |
| } | |
| errors.assert.linesBetween({ | |
| token: token, | |
| nextToken: nextToken, | |
| atMost: 2 | |
| }); | |
| }); | |
| } | |
| }; |