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 strings that span multiple lines without using concatenation. | |
| * | |
| * Type: `Boolean` | |
| * | |
| * Value: `true` | |
| * | |
| * JSHint: [`multistr`](http://www.jshint.com/docs/options/#multistr) | |
| * | |
| * #### Example | |
| * | |
| * ```js | |
| * "disallowMultipleLineStrings": true | |
| * ``` | |
| * | |
| * ##### Valid | |
| * ```js | |
| * var x = "multi" + | |
| * "line"; | |
| * var y = "single line"; | |
| * ``` | |
| * | |
| * ##### Invalid | |
| * ```js | |
| * var x = "multi \ | |
| * line"; | |
| * ``` | |
| */ | |
| 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 'disallowMultipleLineStrings'; | |
| }, | |
| check: function(file, errors) { | |
| file.iterateTokensByType('String', function(token) { | |
| if (token.loc.start.line !== token.loc.end.line) { | |
| errors.add( | |
| 'Multiline strings are disallowed.', | |
| token.loc.start.line, | |
| token.loc.start.column | |
| ); | |
| } | |
| }); | |
| } | |
| }; |