Skip to content

Commit

Permalink
Update tests to pass parserOptions globally
Browse files Browse the repository at this point in the history
  • Loading branch information
yannickcr committed May 8, 2017
1 parent 0a2c510 commit 1b5743f
Show file tree
Hide file tree
Showing 59 changed files with 1,240 additions and 2,310 deletions.
43 changes: 14 additions & 29 deletions tests/lib/rules/display-name.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ var RuleTester = require('eslint').RuleTester;
require('babel-eslint');

var parserOptions = {
ecmaVersion: 6,
ecmaVersion: 8,
sourceType: 'module',
ecmaFeatures: {
experimentalObjectRestSpread: true,
jsx: true
Expand All @@ -25,7 +26,7 @@ var parserOptions = {
// Tests
// ------------------------------------------------------------------------------

var ruleTester = new RuleTester();
var ruleTester = new RuleTester({parserOptions});
ruleTester.run('display-name', rule, {

valid: [{
Expand All @@ -39,8 +40,7 @@ ruleTester.run('display-name', rule, {
].join('\n'),
options: [{
ignoreTranspilerName: true
}],
parserOptions: parserOptions
}]
}, {
code: [
'var Hello = React.createClass({',
Expand All @@ -57,8 +57,7 @@ ruleTester.run('display-name', rule, {
react: {
createClass: 'createClass'
}
},
parserOptions: parserOptions
}
}, {
code: [
'class Hello extends React.Component {',
Expand All @@ -70,17 +69,15 @@ ruleTester.run('display-name', rule, {
].join('\n'),
options: [{
ignoreTranspilerName: true
}],
parserOptions: parserOptions
}]
}, {
code: [
'class Hello {',
' render() {',
' return \'Hello World\';',
' }',
'}'
].join('\n'),
parserOptions: parserOptions
].join('\n')
}, {
code: [
'class Hello extends Greetings {',
Expand All @@ -97,8 +94,7 @@ ruleTester.run('display-name', rule, {
' method;',
'}'
].join('\n'),
parser: 'babel-eslint',
parserOptions: parserOptions
parser: 'babel-eslint'
}, {
code: [
'class Hello extends React.Component {',
Expand All @@ -112,8 +108,7 @@ ruleTester.run('display-name', rule, {
].join('\n'),
options: [{
ignoreTranspilerName: true
}],
parserOptions: parserOptions
}]
}, {
code: [
'class Hello extends React.Component {',
Expand All @@ -126,17 +121,15 @@ ruleTester.run('display-name', rule, {
options: [{
ignoreTranspilerName: true
}],
parser: 'babel-eslint',
parserOptions: parserOptions
parser: 'babel-eslint'
}, {
code: [
'var Hello = createReactClass({',
' render: function() {',
' return <div>Hello {this.props.name}</div>;',
' }',
'});'
].join('\n'),
parserOptions: parserOptions
].join('\n')
}, {
code: [
'class Hello extends React.Component {',
Expand All @@ -163,8 +156,7 @@ ruleTester.run('display-name', rule, {
' return <div>Hello {this.props.name}</div>;',
' }',
'});'
].join('\n'),
parserOptions: parserOptions
].join('\n')
}, {
code: [
'module.exports = createReactClass({',
Expand All @@ -173,8 +165,7 @@ ruleTester.run('display-name', rule, {
' return <div>Hello {this.props.name}</div>;',
' }',
'});'
].join('\n'),
parserOptions: parserOptions
].join('\n')
}, {
code: [
'var Hello = createReactClass({',
Expand All @@ -188,8 +179,7 @@ ruleTester.run('display-name', rule, {
].join('\n'),
options: [{
ignoreTranspilerName: true
}],
parserOptions: parserOptions
}]
}, {
code: [
'export default class {',
Expand Down Expand Up @@ -421,7 +411,6 @@ ruleTester.run('display-name', rule, {
options: [{
ignoreTranspilerName: true
}],
parserOptions: parserOptions,
errors: [{
message: 'Component definition is missing display name'
}]
Expand All @@ -441,7 +430,6 @@ ruleTester.run('display-name', rule, {
createClass: 'createClass'
}
},
parserOptions: parserOptions,
errors: [{
message: 'Component definition is missing display name'
}]
Expand All @@ -456,7 +444,6 @@ ruleTester.run('display-name', rule, {
options: [{
ignoreTranspilerName: true
}],
parserOptions: parserOptions,
errors: [{
message: 'Component definition is missing display name'
}]
Expand All @@ -471,7 +458,6 @@ ruleTester.run('display-name', rule, {
options: [{
ignoreTranspilerName: true
}],
parserOptions: parserOptions,
errors: [{
message: 'Component definition is missing display name'
}]
Expand All @@ -489,7 +475,6 @@ ruleTester.run('display-name', rule, {
options: [{
ignoreTranspilerName: true
}],
parserOptions: parserOptions,
errors: [{
message: 'Component definition is missing display name'
}]
Expand Down
33 changes: 11 additions & 22 deletions tests/lib/rules/forbid-component-props.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ var rule = require('../../../lib/rules/forbid-component-props');
var RuleTester = require('eslint').RuleTester;

var parserOptions = {
ecmaVersion: 6,
ecmaVersion: 8,
sourceType: 'module',
ecmaFeatures: {
experimentalObjectRestSpread: true,
jsx: true
Expand All @@ -27,7 +28,7 @@ require('babel-eslint');
var CLASSNAME_ERROR_MESSAGE = 'Prop `className` is forbidden on Components';
var STYLE_ERROR_MESSAGE = 'Prop `style` is forbidden on Components';

var ruleTester = new RuleTester();
var ruleTester = new RuleTester({parserOptions});
ruleTester.run('forbid-component-props', rule, {

valid: [{
Expand All @@ -37,8 +38,7 @@ ruleTester.run('forbid-component-props', rule, {
' return <div className="foo" />;',
' }',
'});'
].join('\n'),
parserOptions: parserOptions
].join('\n')
}, {
code: [
'var First = createReactClass({',
Expand All @@ -47,8 +47,7 @@ ruleTester.run('forbid-component-props', rule, {
' }',
'});'
].join('\n'),
options: [{forbid: ['style']}],
parserOptions: parserOptions
options: [{forbid: ['style']}]
}, {
code: [
'var First = createReactClass({',
Expand All @@ -57,8 +56,7 @@ ruleTester.run('forbid-component-props', rule, {
' return <Foo bar="baz" />;',
' }',
'});'
].join('\n'),
parserOptions: parserOptions
].join('\n')
}, {
code: [
'var First = createReactClass({',
Expand All @@ -68,8 +66,7 @@ ruleTester.run('forbid-component-props', rule, {
' }',
'});'
].join('\n'),
options: [{forbid: ['style']}],
parserOptions: parserOptions
options: [{forbid: ['style']}]
}, {
code: [
'var First = createReactClass({',
Expand All @@ -79,8 +76,7 @@ ruleTester.run('forbid-component-props', rule, {
' }',
'});'
].join('\n'),
options: [{forbid: ['style', 'foo']}],
parserOptions: parserOptions
options: [{forbid: ['style', 'foo']}]
}, {
code: [
'var First = createReactClass({',
Expand All @@ -89,8 +85,7 @@ ruleTester.run('forbid-component-props', rule, {
' return <this.Foo bar="baz" />;',
' }',
'});'
].join('\n'),
parserOptions: parserOptions
].join('\n')
}, {
code: [
'class First extends createReactClass {',
Expand All @@ -99,15 +94,13 @@ ruleTester.run('forbid-component-props', rule, {
' }',
'}'
].join('\n'),
options: [{forbid: ['style']}],
parserOptions: parserOptions
options: [{forbid: ['style']}]
}, {
code: [
'const First = (props) => (',
' <this.Foo {...props} />',
');'
].join('\n'),
parserOptions: parserOptions
].join('\n')
}],

invalid: [{
Expand All @@ -119,7 +112,6 @@ ruleTester.run('forbid-component-props', rule, {
' }',
'});'
].join('\n'),
parserOptions: parserOptions,
errors: [{
message: CLASSNAME_ERROR_MESSAGE,
line: 4,
Expand All @@ -135,7 +127,6 @@ ruleTester.run('forbid-component-props', rule, {
' }',
'});'
].join('\n'),
parserOptions: parserOptions,
errors: [{
message: STYLE_ERROR_MESSAGE,
line: 4,
Expand All @@ -151,7 +142,6 @@ ruleTester.run('forbid-component-props', rule, {
' }',
'});'
].join('\n'),
parserOptions: parserOptions,
options: [{forbid: ['className', 'style']}],
errors: [{
message: CLASSNAME_ERROR_MESSAGE,
Expand All @@ -168,7 +158,6 @@ ruleTester.run('forbid-component-props', rule, {
' }',
'});'
].join('\n'),
parserOptions: parserOptions,
options: [{forbid: ['className', 'style']}],
errors: [{
message: STYLE_ERROR_MESSAGE,
Expand Down
Loading

0 comments on commit 1b5743f

Please sign in to comment.