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 spaces before commas | |
| * | |
| * Types: `Boolean` | |
| * | |
| * Values: `true` to disallow any spaces before any comma | |
| * | |
| * #### Example | |
| * | |
| * ```js | |
| * "disallowSpaceBeforeComma": true | |
| * ``` | |
| * | |
| * ##### Valid | |
| * | |
| * ```js | |
| * var a, b; | |
| * ``` | |
| * | |
| * ##### Invalid | |
| * | |
| * ```js | |
| * var a ,b; | |
| * ``` | |
| */ | |
| var assert = require('assert'); | |
| module.exports = function() { | |
| }; | |
| module.exports.prototype = { | |
| configure: function(option) { | |
| assert( | |
| option === true, | |
| this.getOptionName() + ' option requires true value' | |
| ); | |
| }, | |
| getOptionName: function() { | |
| return 'disallowSpaceBeforeComma'; | |
| }, | |
| check: function(file, errors) { | |
| file.iterateTokensByTypeAndValue('Punctuator', ',', function(token) { | |
| var prevToken = file.getPrevToken(token); | |
| errors.assert.noWhitespaceBetween({ | |
| token: prevToken, | |
| nextToken: token, | |
| message: 'Illegal space before comma' | |
| }); | |
| }); | |
| } | |
| }; |