Skip to content

Commit

Permalink
Fix ESLint 6 compat by providing parser as absolute path to RuleTester
Browse files Browse the repository at this point in the history
  • Loading branch information
yannickcr committed Apr 28, 2019
1 parent 8041075 commit 9fbd037
Show file tree
Hide file tree
Showing 51 changed files with 1,343 additions and 1,229 deletions.
10 changes: 10 additions & 0 deletions tests/helpers/parsers.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
'use strict';

const path = require('path');

const NODE_MODULES = '../../node_modules';

module.exports = {
BABEL_ESLINT: path.join(__dirname, NODE_MODULES, 'babel-eslint'),
TYPESCRIPT_ESLINT: path.join(__dirname, NODE_MODULES, 'typescript-eslint-parser')
};
52 changes: 27 additions & 25 deletions tests/lib/rules/boolean-prop-naming.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
const rule = require('../../../lib/rules/boolean-prop-naming');
const RuleTester = require('eslint').RuleTester;

const {BABEL_ESLINT} = require('../../helpers/parsers');

const parserOptions = {
ecmaVersion: 2018,
sourceType: 'module',
Expand Down Expand Up @@ -142,7 +144,7 @@ ruleTester.run('boolean-prop-naming', rule, {
options: [{
rule: '^is[A-Z]([A-Za-z0-9]?)+'
}],
parser: 'babel-eslint'
parser: BABEL_ESLINT
}, {
// ES6 components with static class properties and Object.spread syntax in PropTypes
code: `
Expand All @@ -155,7 +157,7 @@ ruleTester.run('boolean-prop-naming', rule, {
options: [{
rule: '^is[A-Z]([A-Za-z0-9]?)+'
}],
parser: 'babel-eslint'
parser: BABEL_ESLINT
}, {
// ES6 components as Component with boolean PropTypes and Object.spread syntax in PropTypes
code: `
Expand All @@ -179,7 +181,7 @@ ruleTester.run('boolean-prop-naming', rule, {
options: [{
rule: '^is[A-Z]([A-Za-z0-9]?)+'
}],
parser: 'babel-eslint'
parser: BABEL_ESLINT
}, {
// ES6 components with static class properties an non-booleans
code: `
Expand All @@ -191,7 +193,7 @@ ruleTester.run('boolean-prop-naming', rule, {
options: [{
rule: '^is[A-Z]([A-Za-z0-9]?)+'
}],
parser: 'babel-eslint'
parser: BABEL_ESLINT
}, {
// ES6 components and Flowtype booleans
code: `
Expand All @@ -203,7 +205,7 @@ ruleTester.run('boolean-prop-naming', rule, {
options: [{
rule: '^is[A-Z]([A-Za-z0-9]?)+'
}],
parser: 'babel-eslint'
parser: BABEL_ESLINT
}, {
// ES6 components and Flowtype non-booleans
code: `
Expand All @@ -215,7 +217,7 @@ ruleTester.run('boolean-prop-naming', rule, {
options: [{
rule: '^is[A-Z]([A-Za-z0-9]?)+'
}],
parser: 'babel-eslint'
parser: BABEL_ESLINT
}, {
// Stateless components
code: `
Expand All @@ -225,7 +227,7 @@ ruleTester.run('boolean-prop-naming', rule, {
options: [{
rule: '^is[A-Z]([A-Za-z0-9]?)+'
}],
parser: 'babel-eslint'
parser: BABEL_ESLINT
}, {
// Functional components and Flowtype booleans
code: `
Expand All @@ -237,7 +239,7 @@ ruleTester.run('boolean-prop-naming', rule, {
options: [{
rule: '^is[A-Z]([A-Za-z0-9]?)+'
}],
parser: 'babel-eslint'
parser: BABEL_ESLINT
}, {
// Custom `propTypeNames` option
code: `
Expand All @@ -253,7 +255,7 @@ ruleTester.run('boolean-prop-naming', rule, {
propTypeNames: ['mutuallyExclusiveTrueProps'],
rule: '^is[A-Z]([A-Za-z0-9]?)+'
}],
parser: 'babel-eslint'
parser: BABEL_ESLINT
}, {
// Custom PropTypes that are specified as variables
code: `
Expand All @@ -269,7 +271,7 @@ ruleTester.run('boolean-prop-naming', rule, {
propTypeNames: ['bool', 'mutuallyExclusiveTrueProps'],
rule: '^is[A-Z]([A-Za-z0-9]?)+'
}],
parser: 'babel-eslint'
parser: BABEL_ESLINT
}, {
// Ensure rule doesn't crash on destructured objects [Issue #1369]
code: `
Expand All @@ -279,7 +281,7 @@ ruleTester.run('boolean-prop-naming', rule, {
options: [{
rule: '^is[A-Z]([A-Za-z0-9]?)+'
}],
parser: 'babel-eslint'
parser: BABEL_ESLINT
}, {
// Ensure rule doesn't crash on on components reference old-style Flow props
code: `
Expand All @@ -291,7 +293,7 @@ ruleTester.run('boolean-prop-naming', rule, {
options: [{
rule: '^is[A-Z]([A-Za-z0-9]?)+'
}],
parser: 'babel-eslint'
parser: BABEL_ESLINT
}, {
// No propWrapperFunctions setting
code: `
Expand Down Expand Up @@ -328,7 +330,7 @@ ruleTester.run('boolean-prop-naming', rule, {
}
}
`,
parser: 'babel-eslint'
parser: BABEL_ESLINT
}, {
// Ensure the rule does not throw when a prop isRequired when ES6 without static properties.
code: `
Expand Down Expand Up @@ -372,7 +374,7 @@ ruleTester.run('boolean-prop-naming', rule, {
options: [{
rule: '^is[A-Z]([A-Za-z0-9]?)+'
}],
parser: 'babel-eslint'
parser: BABEL_ESLINT
}, {
code: `
class Hello extends React.Component {
Expand Down Expand Up @@ -501,7 +503,7 @@ ruleTester.run('boolean-prop-naming', rule, {
options: [{
rule: '^is[A-Z]([A-Za-z0-9]?)+'
}],
parser: 'babel-eslint',
parser: BABEL_ESLINT,
errors: [{
message: 'Prop name (something) doesn\'t match rule (^is[A-Z]([A-Za-z0-9]?)+)'
}]
Expand Down Expand Up @@ -532,7 +534,7 @@ ruleTester.run('boolean-prop-naming', rule, {
options: [{
rule: '^is[A-Z]([A-Za-z0-9]?)+'
}],
parser: 'babel-eslint',
parser: BABEL_ESLINT,
errors: [{
message: 'Prop name (something) doesn\'t match rule (^is[A-Z]([A-Za-z0-9]?)+)'
}]
Expand All @@ -547,7 +549,7 @@ ruleTester.run('boolean-prop-naming', rule, {
options: [{
rule: '^is[A-Z]([A-Za-z0-9]?)+'
}],
parser: 'babel-eslint',
parser: BABEL_ESLINT,
errors: [{
message: 'Prop name (something) doesn\'t match rule (^is[A-Z]([A-Za-z0-9]?)+)'
}]
Expand All @@ -559,7 +561,7 @@ ruleTester.run('boolean-prop-naming', rule, {
options: [{
rule: '^is[A-Z]([A-Za-z0-9]?)+'
}],
parser: 'babel-eslint',
parser: BABEL_ESLINT,
errors: [{
message: 'Prop name (something) doesn\'t match rule (^is[A-Z]([A-Za-z0-9]?)+)'
}]
Expand All @@ -573,7 +575,7 @@ ruleTester.run('boolean-prop-naming', rule, {
options: [{
rule: '^is[A-Z]([A-Za-z0-9]?)+'
}],
parser: 'babel-eslint',
parser: BABEL_ESLINT,
errors: [{
message: 'Prop name (something) doesn\'t match rule (^is[A-Z]([A-Za-z0-9]?)+)'
}]
Expand All @@ -589,7 +591,7 @@ ruleTester.run('boolean-prop-naming', rule, {
propTypeNames: ['bool', 'mutuallyExclusiveTrueProps'],
rule: '^is[A-Z]([A-Za-z0-9]?)+'
}],
parser: 'babel-eslint',
parser: BABEL_ESLINT,
errors: [{
message: 'Prop name (something) doesn\'t match rule (^is[A-Z]([A-Za-z0-9]?)+)'
}]
Expand All @@ -607,7 +609,7 @@ ruleTester.run('boolean-prop-naming', rule, {
propTypeNames: ['bool', 'mutuallyExclusiveTrueProps'],
rule: '^is[A-Z]([A-Za-z0-9]?)+'
}],
parser: 'babel-eslint',
parser: BABEL_ESLINT,
errors: [{
message: 'Prop name (something) doesn\'t match rule (^is[A-Z]([A-Za-z0-9]?)+)'
}, {
Expand All @@ -627,7 +629,7 @@ ruleTester.run('boolean-prop-naming', rule, {
propTypeNames: ['bool', 'mutuallyExclusiveTrueProps'],
rule: '^is[A-Z]([A-Za-z0-9]?)+'
}],
parser: 'babel-eslint',
parser: BABEL_ESLINT,
errors: [{
message: 'Prop name (something) doesn\'t match rule (^is[A-Z]([A-Za-z0-9]?)+)'
}, {
Expand Down Expand Up @@ -730,7 +732,7 @@ ruleTester.run('boolean-prop-naming', rule, {
return <div>{props.showScore ? 'yeh' : 'no'}</div>;
}
}`,
parser: 'babel-eslint',
parser: BABEL_ESLINT,
settings: {
propWrapperFunctions: ['forbidExtraProps']
},
Expand Down Expand Up @@ -802,7 +804,7 @@ ruleTester.run('boolean-prop-naming', rule, {
options: [{
rule: '^is[A-Z]([A-Za-z0-9]?)+'
}],
parser: 'babel-eslint',
parser: BABEL_ESLINT,
errors: [{
message: 'Prop name (something) doesn\'t match rule (^is[A-Z]([A-Za-z0-9]?)+)'
}]
Expand Down Expand Up @@ -843,7 +845,7 @@ ruleTester.run('boolean-prop-naming', rule, {
options: [{
rule: '^is[A-Z]([A-Za-z0-9]?)+'
}],
parser: 'babel-eslint',
parser: BABEL_ESLINT,
errors: [{
message: 'Prop name (something) doesn\'t match rule (^is[A-Z]([A-Za-z0-9]?)+)'
}]
Expand Down
Loading

0 comments on commit 9fbd037

Please sign in to comment.