1 | /**
|
2 | * Disallows strings that span multiple lines without using concatenation.
|
3 | *
|
4 | * Type: `Boolean`
|
5 | *
|
6 | * Value: `true`
|
7 | *
|
8 | * JSHint: [`multistr`](http://www.jshint.com/docs/options/#multistr)
|
9 | *
|
10 | * #### Example
|
11 | *
|
12 | * ```js
|
13 | * "disallowMultipleLineStrings": true
|
14 | * ```
|
15 | *
|
16 | * ##### Valid
|
17 | * ```js
|
18 | * var x = "multi" +
|
19 | * "line";
|
20 | * var y = "single line";
|
21 | * ```
|
22 | *
|
23 | * ##### Invalid
|
24 | * ```js
|
25 | * var x = "multi \
|
26 | * line";
|
27 | * ```
|
28 | */
|
29 |
|
30 | var assert = require('assert');
|
31 |
|
32 | module.exports = function() {};
|
33 |
|
34 | module.exports.prototype = {
|
35 |
|
36 | configure: function(options) {
|
37 | assert(
|
38 | options === true,
|
39 | this.getOptionName() + ' option requires a true value or should be removed'
|
40 | );
|
41 | },
|
42 |
|
43 | getOptionName: function() {
|
44 | return 'disallowMultipleLineStrings';
|
45 | },
|
46 |
|
47 | check: function(file, errors) {
|
48 | file.iterateTokensByType('String', function(token) {
|
49 | if (token.getNewlineCount() !== 0) {
|
50 | errors.add('Multiline strings are disallowed.', token);
|
51 | }
|
52 | });
|
53 | }
|
54 |
|
55 | };
|