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

64 lines (56 sloc) 1.14 KB
/**
* Requires commas as last token on a line in lists.
*
* Type: `Boolean`
*
* Value: `true`
*
* JSHint: [`laxcomma`](http://www.jshint.com/docs/options/#laxcomma)
*
* #### Example
*
* ```js
* "requireCommaBeforeLineBreak": true
* ```
*
* ##### Valid
*
* ```js
* var x = {
* one: 1,
* two: 2
* };
* var y = { three: 3, four: 4};
* ```
*
* ##### Invalid
*
* ```js
* var x = {
* one: 1
* , two: 2
* };
* ```
*/
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 'requireCommaBeforeLineBreak';
},
check: function(file, errors) {
file.iterateTokensByTypeAndValue('Punctuator', ',', function(token) {
errors.assert.sameLine({
token: file.getPrevToken(token),
nextToken: token,
message: 'Commas should not be placed on new line'
});
});
}
};
Jump to Line
Something went wrong with that request. Please try again.