Skip to content

Refactor a bunch of tests to use template literal syntax instead of [].join( #1423

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 32 commits into from
Oct 3, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
4d62834
Rewrite no-typos tests with template literals
jseminck Sep 10, 2017
d5d5e34
Rewrite require-render-return tests with template literals
jseminck Sep 10, 2017
8681c92
Rewrite require-optimization tests with template literals
jseminck Sep 10, 2017
feb068a
Rewrite react-in-jsx-scope tests with template literals
jseminck Sep 10, 2017
0a2a0ab
Rewrite prefer-stateless-function tests with template literals
jseminck Sep 10, 2017
f3c41cb
Rewrite prefer-es6-class tests with template literals
jseminck Sep 10, 2017
ed24d08
Rewrite no-will-update-set-state tests with template literals
jseminck Sep 10, 2017
31faa79
Rewrite no-escaped-entities tests with template literals
jseminck Sep 10, 2017
f18b857
Rewrite no-string-refs tests with template literals
jseminck Sep 10, 2017
a0056b3
Rewrite no-set-state tests with template literals
jseminck Sep 10, 2017
04c0d5f
Rewrite no-render-return-value tests with template literals
jseminck Sep 10, 2017
f6a91f3
Rewrite no-redundant-scu tests with template literals
jseminck Sep 10, 2017
a1de7fa
Rewrite no-is-mounted tests with template literals
jseminck Sep 10, 2017
f0051bd
Rewrite no-find-dom-node tests with template literals
jseminck Sep 10, 2017
c8e883e
Rewrite no-did-update-set-state tests with template literals
jseminck Sep 10, 2017
e0545ff
Rewrite no-did-mount-set-state tests with template literals
jseminck Sep 10, 2017
79a4aab
Rewrite no-deprecated tests with template literals
jseminck Sep 10, 2017
3749ddd
Rewrite no-danger-with-children tests with template literals
jseminck Sep 10, 2017
06f87b7
Rewrite no-array-index-key tests with template literals
jseminck Sep 10, 2017
54cb857
Rewrite jsx-uses-var tests with template literals
jseminck Sep 10, 2017
3847a2c
Rewrite jsx-space-before-closing tests with template literals
jseminck Sep 10, 2017
eb8e3cb
Rewrite jsx-sort-props tests with template literals
jseminck Sep 10, 2017
a0d2227
Rewrite jsx-no-undef tests with template literals
jseminck Sep 10, 2017
09cc65a
Rewrite jsx-no-literals tests with template literals
jseminck Sep 10, 2017
2ad18b0
Rewrite jsx-no-comment-textnodes tests with template literals
jseminck Sep 10, 2017
016f2be
Rewrite jsx-no-bind tests with template literals
jseminck Sep 10, 2017
330368b
Rewrite jsx-handler-names tests with template literals
jseminck Sep 10, 2017
9e6e75b
Rewrite jsx-curly-brace-presence tests with template literals
jseminck Sep 10, 2017
0131276
Rewrite forbid-foreign-prop-types tests with template literals
jseminck Sep 10, 2017
baf8e5b
Rewrite display-name tests with template literals
jseminck Sep 10, 2017
55dc6c8
Rewrite boolean-prop-naming tests with template literals
jseminck Sep 10, 2017
fa4e2a8
Re-add comments
jseminck Sep 11, 2017
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
406 changes: 201 additions & 205 deletions tests/lib/rules/boolean-prop-naming.js

Large diffs are not rendered by default.

756 changes: 378 additions & 378 deletions tests/lib/rules/display-name.js

Large diffs are not rendered by default.

100 changes: 50 additions & 50 deletions tests/lib/rules/forbid-foreign-prop-types.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,88 +53,88 @@ ruleTester.run('forbid-foreign-prop-types', rule, {
}],

invalid: [{
code: [
'var Foo = createReactClass({',
' propTypes: Bar.propTypes,',
' render: function() {',
' return <Foo className="bar" />;',
' }',
'});'
].join('\n'),
code: `
var Foo = createReactClass({
propTypes: Bar.propTypes,
render: function() {
return <Foo className="bar" />;
}
});
`,
errors: [{
message: ERROR_MESSAGE,
type: 'Identifier'
}]
},
{
code: [
'var Foo = createReactClass({',
' propTypes: Bar["propTypes"],',
' render: function() {',
' return <Foo className="bar" />;',
' }',
'});'
].join('\n'),
code: `
var Foo = createReactClass({
propTypes: Bar["propTypes"],
render: function() {
return <Foo className="bar" />;
}
});
`,
errors: [{
message: ERROR_MESSAGE,
type: 'Literal'
}]
},
{
code: [
'var { propTypes } = SomeComponent',
'var Foo = createReactClass({',
' propTypes,',
' render: function() {',
' return <Foo className="bar" />;',
' }',
'});'
].join('\n'),
code: `
var { propTypes } = SomeComponent
var Foo = createReactClass({
propTypes,
render: function() {
return <Foo className="bar" />;
}
});
`,
errors: [{
message: ERROR_MESSAGE,
type: 'Property'
}]
},
{
code: [
'var { propTypes: things, ...foo } = SomeComponent',
'var Foo = createReactClass({',
' propTypes,',
' render: function() {',
' return <Foo className="bar" />;',
' }',
'});'
].join('\n'),
code: `
var { propTypes: things, ...foo } = SomeComponent
var Foo = createReactClass({
propTypes,
render: function() {
return <Foo className="bar" />;
}
});
`,
parser: 'babel-eslint',
errors: [{
message: ERROR_MESSAGE,
type: 'Property'
}]
},
{
code: [
'class MyComponent extends React.Component {',
' static fooBar = {',
' baz: Qux.propTypes.baz',
' };',
'}'
].join('\n'),
code: `
class MyComponent extends React.Component {
static fooBar = {
baz: Qux.propTypes.baz
};
}
`,
parser: 'babel-eslint',
errors: [{
message: ERROR_MESSAGE,
type: 'Identifier'
}]
},
{
code: [
'var { propTypes: typesOfProps } = SomeComponent',
'var Foo = createReactClass({',
' propTypes: typesOfProps,',
' render: function() {',
' return <Foo className="bar" />;',
' }',
'});'
].join('\n'),
code: `
var { propTypes: typesOfProps } = SomeComponent
var Foo = createReactClass({
propTypes: typesOfProps,
render: function() {
return <Foo className="bar" />;
}
});
`,
errors: [{
message: ERROR_MESSAGE,
type: 'Property'
Expand Down
54 changes: 27 additions & 27 deletions tests/lib/rules/jsx-closing-tag-location.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,39 +27,39 @@ const MESSAGE_OWN_LINE = [{message: 'Closing tag of a multiline JSX expression m
const ruleTester = new RuleTester({parserOptions});
ruleTester.run('jsx-closing-tag-location', rule, {
valid: [{
code: [
'<App>',
' foo',
'</App>'
].join('\n')
code: `
<App>
foo
</App>
`
}, {
code: [
'<App>foo</App>'
].join('\n')
code: `
<App>foo</App>
`
}],

invalid: [{
code: [
'<App>',
' foo',
' </App>'
].join('\n'),
output: [
'<App>',
' foo',
'</App>'
].join('\n'),
code: `
<App>
foo
</App>
`,
output: `
<App>
foo
</App>
`,
errors: MESSAGE_MATCH_INDENTATION
}, {
code: [
'<App>',
' foo</App>'
].join('\n'),
output: [
'<App>',
' foo',
'</App>'
].join('\n'),
code: `
<App>
foo</App>
`,
output: `
<App>
foo
</App>
`,
errors: MESSAGE_OWN_LINE
}]
});
84 changes: 21 additions & 63 deletions tests/lib/rules/jsx-handler-names.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,105 +27,63 @@ const parserOptions = {
const ruleTester = new RuleTester({parserOptions});
ruleTester.run('jsx-handler-names', rule, {
valid: [{
code: [
'<TestComponent onChange={this.handleChange} />'
].join('\n')
code: '<TestComponent onChange={this.handleChange} />'
}, {
code: [
'<TestComponent onChange={this.props.onChange} />'
].join('\n')
code: '<TestComponent onChange={this.props.onChange} />'
}, {
code: [
'<TestComponent onChange={this.props.onFoo} />'
].join('\n')
code: '<TestComponent onChange={this.props.onFoo} />'
}, {
code: [
'<TestComponent isSelected={this.props.isSelected} />'
].join('\n')
code: '<TestComponent isSelected={this.props.isSelected} />'
}, {
code: [
'<TestComponent shouldDisplay={this.state.shouldDisplay} />'
].join('\n')
code: '<TestComponent shouldDisplay={this.state.shouldDisplay} />'
}, {
code: [
'<TestComponent shouldDisplay={arr[0].prop} />'
].join('\n')
code: '<TestComponent shouldDisplay={arr[0].prop} />'
}, {
code: [
'<TestComponent onChange={props.onChange} />'
].join('\n')
code: '<TestComponent onChange={props.onChange} />'
}, {
code: [
'<TestComponent ref={this.handleRef} />'
].join('\n')
code: '<TestComponent ref={this.handleRef} />'
}, {
code: [
'<TestComponent ref={this.somethingRef} />'
].join('\n')
code: '<TestComponent ref={this.somethingRef} />'
}, {
code: [
'<TestComponent test={this.props.content} />'
].join('\n'),
code: '<TestComponent test={this.props.content} />',
options: [{
eventHandlerPrefix: 'on',
eventHandlerPropPrefix: 'on'
}]
}, {
code: [
'<TestComponent onChange={props::handleChange} />'
].join('\n'),
code: '<TestComponent onChange={props::handleChange} />',
parser: 'babel-eslint'
}, {
code: [
'<TestComponent onChange={::props.onChange} />'
].join('\n'),
code: '<TestComponent onChange={::props.onChange} />',
parser: 'babel-eslint'
}, {
code: [
'<TestComponent onChange={props.foo::handleChange} />'
].join('\n'),
code: '<TestComponent onChange={props.foo::handleChange} />',
parser: 'babel-eslint'
}, {
code: [
'<TestComponent only={this.only} />'
].join('\n')
code: '<TestComponent only={this.only} />'
}],

invalid: [{
code: [
'<TestComponent onChange={this.doSomethingOnChange} />'
].join('\n'),
code: '<TestComponent onChange={this.doSomethingOnChange} />',
errors: [{message: 'Handler function for onChange prop key must begin with \'handle\''}]
}, {
code: [
'<TestComponent onChange={this.handlerChange} />'
].join('\n'),
code: '<TestComponent onChange={this.handlerChange} />',
errors: [{message: 'Handler function for onChange prop key must begin with \'handle\''}]
}, {
code: [
'<TestComponent only={this.handleChange} />'
].join('\n'),
code: '<TestComponent only={this.handleChange} />',
errors: [{message: 'Prop key for handleChange must begin with \'on\''}]
}, {
code: [
'<TestComponent handleChange={this.handleChange} />'
].join('\n'),
code: '<TestComponent handleChange={this.handleChange} />',
errors: [{message: 'Prop key for handleChange must begin with \'on\''}]
}, {
code: [
'<TestComponent onChange={this.onChange} />'
].join('\n'),
code: '<TestComponent onChange={this.onChange} />',
errors: [{message: 'Handler function for onChange prop key must begin with \'handle\''}]
}, {
code: [
'<TestComponent onChange={props::onChange} />'
].join('\n'),
code: '<TestComponent onChange={props::onChange} />',
parser: 'babel-eslint',
errors: [{message: 'Handler function for onChange prop key must begin with \'handle\''}]
}, {
code: [
'<TestComponent onChange={props.foo::onChange} />'
].join('\n'),
code: '<TestComponent onChange={props.foo::onChange} />',
parser: 'babel-eslint',
errors: [{message: 'Handler function for onChange prop key must begin with \'handle\''}]
}]
Expand Down
Loading