diff --git a/.eslintrc b/.eslintrc index b6f0d450fb..80071df298 100644 --- a/.eslintrc +++ b/.eslintrc @@ -61,7 +61,7 @@ "no-lone-blocks": 2, "no-loop-func": 2, "no-multi-spaces": 2, - "no-multi-str": 0, + "no-multi-str": 2, "no-native-reassign": 2, "no-new": 2, "no-new-func": 2, diff --git a/tests/lib/rules/jsx-uses-vars.js b/tests/lib/rules/jsx-uses-vars.js index dd3dd225cc..57e1bee67c 100644 --- a/tests/lib/rules/jsx-uses-vars.js +++ b/tests/lib/rules/jsx-uses-vars.js @@ -32,170 +32,188 @@ eslint.defineRule('jsx-uses-vars', require('../../../lib/rules/jsx-uses-vars')); ruleTester.run('no-unused-vars', ruleNoUnusedVars, { valid: [ { - code: '\ - /*eslint jsx-uses-vars:1*/\ - function foo() {\ - var App;\ - var bar = React.render();\ - return bar;\ - };\ - foo()', - parserOptions: parserOptions - }, { - code: '\ - /*eslint jsx-uses-vars:1*/\ - var App;\ - React.render();', - parserOptions: parserOptions - }, { - code: '\ - /*eslint jsx-uses-vars:1*/\ - var App;\ - React.render();', + code: ` + /* eslint jsx-uses-vars: 1 */ + function foo() { + var App; + var bar = React.render(); + return bar; + }; + foo() + `, + parserOptions: parserOptions + }, { + code: ` + /* eslint jsx-uses-vars: 1 */ + var App; + React.render(); + `, + parserOptions: parserOptions + }, { + code: ` + /* eslint jsx-uses-vars: 1 */ + var App; + React.render(); + `, parser: 'babel-eslint', parserOptions: parserOptions }, { - code: '\ - /*eslint jsx-uses-vars:1*/\ - var a=1;\ - React.render();', - parserOptions: parserOptions - }, { - code: '\ - /*eslint jsx-uses-vars:1*/\ - var App;\ - function f() {\ - return ;\ - }\ - f();', - parserOptions: parserOptions - }, { - code: '\ - /*eslint jsx-uses-vars:1*/\ - var App;\ - ', - parserOptions: parserOptions - }, { - code: '\ - /*eslint jsx-uses-vars:1*/\ - var App;\ - ', - parserOptions: parserOptions - }, { - code: '\ - /*eslint jsx-uses-vars:1*/\ - class HelloMessage {}\ - ', - parserOptions: parserOptions - }, { - code: '\ - /*eslint jsx-uses-vars:1*/\ - class HelloMessage {\ - render() {\ - var HelloMessage =
Hello
;\ - return HelloMessage;\ - }\ - }\ - ', - parserOptions: parserOptions - }, { - code: '\ - /*eslint jsx-uses-vars:1*/\ - function foo() {\ - var App = { Foo: { Bar: {}}};\ - var bar = React.render();\ - return bar;\ - };\ - foo()', - parserOptions: parserOptions - }, { - code: '\ - /*eslint jsx-uses-vars:1*/\ - function foo() {\ - var App = { Foo: { Bar: { Baz: {}}}};\ - var bar = React.render();\ - return bar;\ - };\ - foo()', + code: ` + /* eslint jsx-uses-vars: 1 */ + var a = 1; + React.render(); + `, + parserOptions: parserOptions + }, { + code: ` + /* eslint jsx-uses-vars: 1 */ + var App; + function f() { + return ; + } + f(); + `, + parserOptions: parserOptions + }, { + code: ` + /* eslint jsx-uses-vars: 1 */ + var App; + + `, + parserOptions: parserOptions + }, { + code: ` + /* eslint jsx-uses-vars: 1 */ + var App; + + `, + parserOptions: parserOptions + }, { + code: ` + /* eslint jsx-uses-vars: 1 */ + class HelloMessage {} + + `, + parserOptions: parserOptions + }, { + code: ` + /* eslint jsx-uses-vars: 1 */ + class HelloMessage { + render() { + var HelloMessage =
Hello
; + return HelloMessage; + } + } + + `, + parserOptions: parserOptions + }, { + code: ` + /* eslint jsx-uses-vars: 1 */ + function foo() { + var App = { Foo: { Bar: {} } }; + var bar = React.render(); + return bar; + }; + foo() + `, + parserOptions: parserOptions + }, { + code: ` + /* eslint jsx-uses-vars: 1 */ + function foo() { + var App = { Foo: { Bar: { Baz: {} } } }; + var bar = React.render(); + return bar; + }; + foo() + `, parserOptions: parserOptions } ], invalid: [ { - code: '/*eslint jsx-uses-vars:1*/ var App;', + code: '/* eslint jsx-uses-vars: 1 */ var App;', errors: [{message: '\'App\' is defined but never used.'}], parserOptions: parserOptions }, { - code: '\ - /*eslint jsx-uses-vars:1*/\ - var App;\ - var unused;\ - React.render();', + code: ` + /* eslint jsx-uses-vars: 1 */ + var App; + var unused; + React.render(); + `, errors: [{message: '\'unused\' is defined but never used.'}], parserOptions: parserOptions }, { - code: '\ - /*eslint jsx-uses-vars:1*/\ - var App;\ - var Hello;\ - React.render();', + code: ` + /* eslint jsx-uses-vars: 1 */ + var App; + var Hello; + React.render(); + `, errors: [{message: '\'Hello\' is defined but never used.'}], parserOptions: parserOptions }, { - code: '\ - /*eslint jsx-uses-vars:1*/\ - var Button;\ - var Input;\ - React.render();', + code: ` + /* eslint jsx-uses-vars: 1 */ + var Button; + var Input; + React.render(); + `, errors: [{message: '\'Input\' is defined but never used.'}], parserOptions: parserOptions }, { - code: '\ - /*eslint jsx-uses-vars:1*/\ - class unused {}', + code: ` + /* eslint jsx-uses-vars: 1 */ + class unused {} + `, errors: [{message: '\'unused\' is defined but never used.'}], parserOptions: parserOptions }, { - code: '\ - /*eslint jsx-uses-vars:1*/\ - class HelloMessage {\ - render() {\ - var HelloMessage =
Hello
;\ - return HelloMessage;\ - }\ - }', + code: ` + /* eslint jsx-uses-vars: 1 */ + class HelloMessage { + render() { + var HelloMessage =
Hello
; + return HelloMessage; + } + } + `, errors: [{ message: '\'HelloMessage\' is defined but never used.', - line: 1 + line: 3 }], parserOptions: parserOptions }, { - code: '\ - /*eslint jsx-uses-vars:1*/\ - class HelloMessage {\ - render() {\ - var HelloMessage =
Hello
;\ - return HelloMessage;\ - }\ - }', + code: ` + /* eslint jsx-uses-vars: 1 */ + class HelloMessage { + render() { + var HelloMessage =
Hello
; + return HelloMessage; + } + } + `, errors: [{ message: '\'HelloMessage\' is defined but never used.', - line: 1 + line: 3 }], parser: 'babel-eslint', parserOptions: parserOptions }, { - code: '\ - /*eslint jsx-uses-vars:1*/\ - import {Hello} from \'Hello\';\ - function Greetings() {\ - const Hello = require(\'Hello\').default;\ - return ;\ - }\ - Greetings();', + code: ` + /* eslint jsx-uses-vars: 1 */ + import {Hello} from 'Hello'; + function Greetings() { + const Hello = require('Hello').default; + return ; + } + Greetings(); + `, errors: [{ message: '\'Hello\' is defined but never used.', - line: 1 + line: 3 }], parser: 'babel-eslint', parserOptions: parserOptions diff --git a/tests/lib/rules/jsx-wrap-multilines.js b/tests/lib/rules/jsx-wrap-multilines.js index f6d50454d9..54ae243f10 100644 --- a/tests/lib/rules/jsx-wrap-multilines.js +++ b/tests/lib/rules/jsx-wrap-multilines.js @@ -22,90 +22,101 @@ var parserOptions = { // Code Snippets // ------------------------------------------------------------------------------ -var RETURN_SINGLE_LINE = '\ - var Hello = React.createClass({\ - render: function() {\ - return

Hello {this.props.name}

;\ - }\ - });'; - -var RETURN_PAREN = '\ - var Hello = React.createClass({\ - render: function() {\ - return (
\n\ -

Hello {this.props.name}

\n\ -
);\ - }\ - });'; - -var RETURN_NO_PAREN = '\ - var Hello = React.createClass({\ - render: function() {\ - return
\n\ -

Hello {this.props.name}

\n\ -
;\ - }\ - });'; +var RETURN_SINGLE_LINE = ` + var Hello = React.createClass({ + render: function() { + return

Hello {this.props.name}

; + } + }); +`; + +var RETURN_PAREN = ` + var Hello = React.createClass({ + render: function() { + return (
+

Hello {this.props.name}

+
); + } + }); +`; + +var RETURN_NO_PAREN = ` + var Hello = React.createClass({ + render: function() { + return
+

Hello {this.props.name}

+
; + } + }); +`; var DECLARATION_TERNARY_SINGLE_LINE = 'var hello = foo ?

Hello

:

Hi

;'; -var DECLARATION_TERNARY_PAREN = '\ - var hello = foo ? (
\n\ -

Hello

\n\ -
) : (
\n\ -

Hi

\n\ -
);'; - -var DECLARATION_TERNARY_NO_PAREN = '\ - var hello = foo ?
\n\ -

Hello

\n\ -
:
\n\ -

Hi

\n\ -
;'; +var DECLARATION_TERNARY_PAREN = ` + var hello = foo ? (
+

Hello

+
) : (
+

Hi

+
); +`; + +var DECLARATION_TERNARY_NO_PAREN = ` + var hello = foo ?
+

Hello

+
:
+

Hi

+
; +`; var ASSIGNMENT_TERNARY_SINGLE_LINE = 'var hello; hello = foo ?

Hello

:

Hi

;'; -var ASSIGNMENT_TERNARY_PAREN = '\ - var hello;\n\ - hello = foo ? (
\n\ -

Hello

\n\ -
) : (
\n\ -

Hi

\n\ -
);'; - -var ASSIGNMENT_TERNARY_NO_PAREN = '\ - var hello;\n\ - hello = foo ?
\n\ -

Hello

\n\ -
:
\n\ -

Hi

\n\ -
;'; +var ASSIGNMENT_TERNARY_PAREN = ` + var hello; + hello = foo ? (
+

Hello

+
) : (
+

Hi

+
); +`; + +var ASSIGNMENT_TERNARY_NO_PAREN = ` + var hello; + hello = foo ?
+

Hello

+
:
+

Hi

+
; +`; var DECLARATION_SINGLE_LINE = 'var hello =

Hello

;'; -var DECLARATION_PAREN = '\ - var hello = (
\n\ -

Hello

\n\ -
);'; +var DECLARATION_PAREN = ` + var hello = (
+

Hello

+
); +`; -var DECLARATION_NO_PAREN = '\ - var hello =
\n\ -

Hello

\n\ -
;'; +var DECLARATION_NO_PAREN = ` + var hello =
+

Hello

+
; +`; var ASSIGNMENT_SINGLE_LINE = 'var hello; hello =

Hello

;'; -var ASSIGNMENT_PAREN = '\ - var hello;\ - hello = (
\n\ -

Hello

\n\ -
);'; - -var ASSIGNMENT_NO_PAREN = '\ - var hello;\ - hello =
\n\ -

Hello

\n\ -
;'; +var ASSIGNMENT_PAREN = ` + var hello; + hello = (
+

Hello

+
); +`; + +var ASSIGNMENT_NO_PAREN = ` + var hello; + hello =
+

Hello

+
; +`; // ------------------------------------------------------------------------------ // Tests diff --git a/tests/lib/rules/no-children-prop.js b/tests/lib/rules/no-children-prop.js index dbcb684d34..8232452a4d 100644 --- a/tests/lib/rules/no-children-prop.js +++ b/tests/lib/rules/no-children-prop.js @@ -20,10 +20,8 @@ var parserOptions = { } }; -var JSX_ERROR = 'Do not pass children as props. Instead, nest children between \ -the opening and closing tags.'; -var CREATE_ELEMENT_ERROR = 'Do not pass children as props. Instead, pass them \ -as additional arguments to React.createElement.'; +var JSX_ERROR = 'Do not pass children as props. Instead, nest children between the opening and closing tags.'; +var CREATE_ELEMENT_ERROR = 'Do not pass children as props. Instead, pass them as additional arguments to React.createElement.'; // ----------------------------------------------------------------------------- // Tests diff --git a/tests/lib/rules/self-closing-comp.js b/tests/lib/rules/self-closing-comp.js index 5cb9202e58..13a091ce85 100644 --- a/tests/lib/rules/self-closing-comp.js +++ b/tests/lib/rules/self-closing-comp.js @@ -33,10 +33,11 @@ ruleTester.run('self-closing-comp', rule, { code: 'var Profile = ;', parserOptions: parserOptions }, { - code: '\ - \ - \ - ', + code: ` + + + + `, parserOptions: parserOptions }, { code: 'var HelloJohn =
 
;', @@ -56,10 +57,11 @@ ruleTester.run('self-closing-comp', rule, { options: [], parserOptions: parserOptions }, { - code: '\ - \ - \ - ', + code: ` + + + + `, options: [], parserOptions: parserOptions }, { @@ -95,10 +97,11 @@ ruleTester.run('self-closing-comp', rule, { options: [{html: true}], parserOptions: parserOptions }, { - code: '\ -
\ -
\ -
', + code: ` +
+
+
+ `, options: [{html: true}], parserOptions: parserOptions } diff --git a/tests/lib/rules/wrap-multilines.js b/tests/lib/rules/wrap-multilines.js index e169ff736d..155db92433 100644 --- a/tests/lib/rules/wrap-multilines.js +++ b/tests/lib/rules/wrap-multilines.js @@ -22,56 +22,63 @@ var parserOptions = { // Code Snippets // ------------------------------------------------------------------------------ -var RETURN_SINGLE_LINE = '\ - var Hello = React.createClass({\ - render: function() {\ - return

Hello {this.props.name}

;\ - }\ - });'; - -var RETURN_PAREN = '\ - var Hello = React.createClass({\ - render: function() {\ - return (
\n\ -

Hello {this.props.name}

\n\ -
);\ - }\ - });'; - -var RETURN_NO_PAREN = '\ - var Hello = React.createClass({\ - render: function() {\ - return
\n\ -

Hello {this.props.name}

\n\ -
;\ - }\ - });'; +var RETURN_SINGLE_LINE = ` + var Hello = React.createClass({ + render: function() { + return

Hello {this.props.name}

; + } + }); +`; + +var RETURN_PAREN = ` + var Hello = React.createClass({ + render: function() { + return (
+

Hello {this.props.name}

+
); + } + }); +`; + +var RETURN_NO_PAREN = ` + var Hello = React.createClass({ + render: function() { + return
+

Hello {this.props.name}

+
; + } + }); +`; var DECLARATION_SINGLE_LINE = 'var hello =

Hello

;'; -var DECLARATION_PAREN = '\ - var hello = (
\n\ -

Hello

\n\ -
);'; +var DECLARATION_PAREN = ` + var hello = (
+

Hello

+
); +`; -var DECLARATION_NO_PAREN = '\ - var hello =
\n\ -

Hello

\n\ -
;'; +var DECLARATION_NO_PAREN = ` + var hello =
+

Hello

+
; +`; var ASSIGNMENT_SINGLE_LINE = 'var hello; hello =

Hello

;'; -var ASSIGNMENT_PAREN = '\ - var hello;\ - hello = (
\n\ -

Hello

\n\ -
);'; - -var ASSIGNMENT_NO_PAREN = '\ - var hello;\ - hello =
\n\ -

Hello

\n\ -
;'; +var ASSIGNMENT_PAREN = ` + var hello; + hello = (
+

Hello

+
); +`; + +var ASSIGNMENT_NO_PAREN = ` + var hello; + hello =
+

Hello

+
; +`; // ------------------------------------------------------------------------------ // Tests