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

61 lines (53 sloc) 1.3 KB
/**
* Ensure there are no spaces after argument separators in call expressions.
*
* Type: `Boolean`
*
* Value: `true`
*
* #### Example
*
* ```js
* "disallowSpaceBetweenArguments": true
* ```
*
* ##### Valid
*
* ```js
* a(b,c);
* ```
*
* ##### Invalid
*
* ```js
* a(b, c);
* ```
*/
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 'disallowSpaceBetweenArguments';
},
check: function(file, errors) {
file.iterateNodesByType(['CallExpression'], function(node) {
node.arguments.forEach(function(param) {
var token = file.getFirstNodeToken(param);
var punctuatorToken = file.getPrevToken(token);
if (punctuatorToken.value === ',') {
errors.assert.noWhitespaceBetween({
token: punctuatorToken,
nextToken: file.getNextToken(punctuatorToken),
message: 'Illegal space between arguments'
});
}
});
});
}
};
Jump to Line
Something went wrong with that request. Please try again.