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

66 lines (56 sloc) 1.34 KB
/**
* Disallow a blank line after `'use strict';` statements
*
* Values: `true`
*
* #### Example
*
* ```js
* "disallowPaddingNewLinesAfterUseStrict": true
* ```
*
* ##### Valid
*
* ```js
* 'use strict';
* // code
* ```
*
* ##### Invalid
*
* ```js
* 'use strict';
*
* // code
* ```
*/
var assert = require('assert');
module.exports = function() {};
module.exports.prototype = {
configure: function(disallowPaddingNewLinesAfterUseStrict) {
assert(
disallowPaddingNewLinesAfterUseStrict === true,
this.getOptionName() + ' option requires a true value or should be removed'
);
},
getOptionName: function() {
return 'disallowPaddingNewLinesAfterUseStrict';
},
check: function(file, errors) {
file.iterateNodesByType('ExpressionStatement', function(node) {
var expression = node.expression;
if (expression.type !== 'Literal' || expression.value !== 'use strict') {
return;
}
var endOfNode = file.getLastNodeToken(node);
var nextToken = file.getNextToken(endOfNode, {
includeComments: true
});
errors.assert.linesBetween({
atMost: 1,
token: endOfNode,
nextToken: nextToken
});
});
}
};
Jump to Line
Something went wrong with that request. Please try again.