Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Clone in Desktop Download ZIP
Fetching contributors…

Cannot retrieve contributors at this time

65 lines (56 sloc) 1.14 KB
/**
* 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
});
});
}
};
Jump to Line
Something went wrong with that request. Please try again.