Skip to content

Commit d9d2193

Browse files
golopotljharb
authored andcommitted
[eslint] enable eslint-plugin-eslint-plugin
1 parent 39e4396 commit d9d2193

17 files changed

+63
-150
lines changed

.eslintrc

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
{
22
"root": true,
3-
"extends": "airbnb-base",
3+
"extends": ["airbnb-base", "plugin:eslint-plugin/recommended"],
4+
"plugins": ["eslint-plugin"],
45
"env": {
56
"es6": true,
67
"node": true

lib/rules/jsx-child-element-spacing.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ module.exports = {
4545
recommended: false,
4646
url: docsUrl('jsx-child-element-spacing')
4747
},
48-
fixable: false,
48+
fixable: null,
4949
schema: [
5050
{
5151
type: 'object',

package.json

+1
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
"dependencies": {
2929
"array-includes": "^3.0.3",
3030
"doctrine": "^2.1.0",
31+
"eslint-plugin-eslint-plugin": "^2.1.0",
3132
"has": "^1.0.3",
3233
"jsx-ast-utils": "^2.2.1",
3334
"object.entries": "^1.1.0",

tests/lib/rules/default-props-match-prop-types.js

+24-21
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,8 @@ ruleTester.run('default-props-match-prop-types', rule, {
268268
'Greeting.defaultProps = {',
269269
' foo: "foo"',
270270
'};'
271-
].join('\n')
271+
].join('\n'),
272+
parser: parsers.BABEL_ESLINT
272273
},
273274
{
274275
code: [
@@ -530,7 +531,8 @@ ruleTester.run('default-props-match-prop-types', rule, {
530531
' ...defaults,',
531532
' bar: "bar"',
532533
'};'
533-
].join('\n')
534+
].join('\n'),
535+
parser: parsers.BABEL_ESLINT
534536
},
535537

536538
//
@@ -845,6 +847,26 @@ ruleTester.run('default-props-match-prop-types', rule, {
845847
column: 3
846848
}]
847849
},
850+
{
851+
code: [
852+
'function MyStatelessComponent({ foo, bar }) {',
853+
' return <div>{foo}{bar}</div>;',
854+
'}',
855+
'MyStatelessComponent.propTypes = {',
856+
' foo: React.PropTypes.string,',
857+
' bar: React.PropTypes.string.isRequired',
858+
'};',
859+
'MyStatelessComponent.defaultProps = {',
860+
' baz: "baz"',
861+
'};'
862+
].join('\n'),
863+
errors: [{
864+
message: 'defaultProp "baz" has no corresponding propTypes declaration.',
865+
line: 9,
866+
column: 3
867+
}],
868+
parser: parsers.BABEL_ESLINT
869+
},
848870
{
849871
code: [
850872
'function MyStatelessComponent({ foo, bar }) {',
@@ -1348,25 +1370,6 @@ ruleTester.run('default-props-match-prop-types', rule, {
13481370
column: 5
13491371
}]
13501372
},
1351-
{
1352-
code: [
1353-
'function MyStatelessComponent({ foo, bar }) {',
1354-
' return <div>{foo}{bar}</div>;',
1355-
'}',
1356-
'MyStatelessComponent.propTypes = {',
1357-
' foo: React.PropTypes.string,',
1358-
' bar: React.PropTypes.string.isRequired',
1359-
'};',
1360-
'MyStatelessComponent.defaultProps = {',
1361-
' baz: "baz"',
1362-
'};'
1363-
].join('\n'),
1364-
errors: [{
1365-
message: 'defaultProp "baz" has no corresponding propTypes declaration.',
1366-
line: 9,
1367-
column: 3
1368-
}]
1369-
},
13701373
{
13711374
code: [
13721375
'class Greeting extends React.Component {',

tests/lib/rules/destructuring-assignment.js

+5-13
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,6 @@ const parserOptions = {
2121
const ruleTester = new RuleTester({parserOptions});
2222
ruleTester.run('destructuring-assignment', rule, {
2323
valid: [{
24-
code: `const Foo = class extends React.PureComponent {
25-
render() {
26-
const { foo } = this.props;
27-
return <div>{foo}</div>;
28-
}
29-
};`,
30-
options: ['always'],
31-
parser: parsers.BABEL_ESLINT
32-
}, {
3324
code: `const MyComponent = ({ id, className }) => (
3425
<div id={id} className={className} />
3526
);`
@@ -102,15 +93,16 @@ ruleTester.run('destructuring-assignment', rule, {
10293
return <div>{foo}</div>;
10394
}
10495
};`,
105-
options: ['always'],
106-
parser: parsers.BABEL_ESLINT
96+
options: ['always']
10797
}, {
10898
code: `const Foo = class extends React.PureComponent {
10999
render() {
110100
const { foo } = this.props;
111101
return <div>{foo}</div>;
112102
}
113-
};`
103+
};`,
104+
options: ['always'],
105+
parser: parsers.BABEL_ESLINT
114106
}, {
115107
code: `const Foo = class extends React.PureComponent {
116108
render() {
@@ -119,7 +111,7 @@ ruleTester.run('destructuring-assignment', rule, {
119111
}
120112
};`,
121113
options: ['always'],
122-
parser: parsers.BABEL_ESLINT
114+
parser: parsers.TYPESCRIPT_ESLINT
123115
}, {
124116
code: `const MyComponent = (props) => {
125117
const { h, i } = hi;

tests/lib/rules/jsx-curly-brace-presence.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -508,7 +508,8 @@ ruleTester.run('jsx-curly-brace-presence', rule, {
508508
code: `<MyComponent prop="foo 'bar'">foo</MyComponent>`,
509509
output: `<MyComponent prop={"foo 'bar'"}>foo</MyComponent>`,
510510
options: [{props: 'always'}],
511-
errors: [{message: missingCurlyMessage}]
511+
errors: [{message: missingCurlyMessage}],
512+
parser: parsers.BABEL_ESLINT
512513
},
513514
{
514515
code: '<MyComponent>foo bar </MyComponent>',

tests/lib/rules/jsx-curly-spacing.js

+4-5
Original file line numberDiff line numberDiff line change
@@ -405,7 +405,8 @@ ruleTester.run('jsx-curly-spacing', rule, {
405405
'...bar',
406406
'} />;'
407407
].join('\n'),
408-
options: [{attributes: {when: 'never'}}]
408+
options: [{attributes: {when: 'never'}}],
409+
parser: parsers.BABEL_ESLINT
409410
}, {
410411
code: [
411412
'<App {',
@@ -486,9 +487,6 @@ ruleTester.run('jsx-curly-spacing', rule, {
486487
}, {
487488
code: '<App foo={ bar }>{bar}</App>',
488489
options: [{attributes: {when: 'always'}}]
489-
}, {
490-
code: '<App foo={ bar }>{bar}</App>',
491-
options: [{attributes: {when: 'always'}}]
492490
}, {
493491
code: [
494492
'<App foo={ 42 } { ...bar } baz={{ 4: 2 }}>',
@@ -630,7 +628,8 @@ ruleTester.run('jsx-curly-spacing', rule, {
630628
'...bar',
631629
'} />;'
632630
].join('\n'),
633-
options: ['always']
631+
options: ['always'],
632+
parser: parsers.BABEL_ESLINT
634633
}, {
635634
code: [
636635
'<App {',

tests/lib/rules/jsx-no-undef.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,8 @@ ruleTester.run('jsx-no-undef', rule, {
3535
valid: [{
3636
code: '/*eslint no-undef:1*/ var React, App; React.render(<App />);'
3737
}, {
38-
code: '/*eslint no-undef:1*/ var React, App; React.render(<App />);'
38+
code: '/*eslint no-undef:1*/ var React, App; React.render(<App />);',
39+
parser: parsers.BABEL_ESLINT
3940
}, {
4041
code: '/*eslint no-undef:1*/ var React; React.render(<img />);'
4142
}, {

tests/lib/rules/jsx-one-expression-per-line.js

+2-18
Original file line numberDiff line numberDiff line change
@@ -522,23 +522,6 @@ ruleTester.run('jsx-one-expression-per-line', rule, {
522522
].join('\n'),
523523
errors: [{message: '` bar` must be placed on a new line'}],
524524
parserOptions
525-
}, {
526-
code: [
527-
'<div>',
528-
' foo {"bar"}',
529-
'</div>'
530-
].join('\n'),
531-
output: [
532-
'<div>',
533-
' foo ',
534-
'{\' \'}',
535-
'{"bar"}',
536-
'</div>'
537-
].join('\n'),
538-
errors: [
539-
{message: '`{"bar"}` must be placed on a new line'}
540-
],
541-
parserOptions
542525
}, {
543526
code: [
544527
'<div>',
@@ -705,7 +688,8 @@ ruleTester.run('jsx-one-expression-per-line', rule, {
705688
'</App>'
706689
].join('\n'),
707690
errors: [{message: '`Foo` must be placed on a new line'}],
708-
parserOptions
691+
parserOptions,
692+
parser: parsers.BABEL_ESLINT
709693
}, {
710694
code: [
711695
'<App>',

tests/lib/rules/jsx-pascal-case.js

+5-2
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
const RuleTester = require('eslint').RuleTester;
1313
const rule = require('../../../lib/rules/jsx-pascal-case');
1414

15+
const parsers = require('../../helpers/parsers');
16+
1517
const parserOptions = {
1618
ecmaVersion: 2018,
1719
sourceType: 'module',
@@ -46,6 +48,9 @@ ruleTester.run('jsx-pascal-case', rule, {
4648
code: '<T3stComp0nent />'
4749
}, {
4850
code: '<T />'
51+
}, {
52+
code: '<T />',
53+
parser: parsers.BABEL_ESLINT
4954
}, {
5055
code: '<YMCA />',
5156
options: [{allowAllCaps: true}]
@@ -59,8 +64,6 @@ ruleTester.run('jsx-pascal-case', rule, {
5964
}, {
6065
code: '<IGNORED />',
6166
options: [{ignore: ['IGNORED']}]
62-
}, {
63-
code: '<T />'
6467
}, {
6568
code: '<$ />'
6669
}, {

tests/lib/rules/jsx-wrap-multilines.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1083,7 +1083,7 @@ ruleTester.run('jsx-wrap-multilines', rule, {
10831083
]
10841084
}, {
10851085
code: DECLARATION_TERNARY_PAREN_FRAGMENT,
1086-
parser: parsers.BABEL_ESLINT,
1086+
parser: parsers.TYPESCRIPT_ESLINT,
10871087
output: addNewLineSymbols(DECLARATION_TERNARY_PAREN_FRAGMENT),
10881088
options: [{declaration: 'parens-new-line'}],
10891089
errors: [

tests/lib/rules/no-redundant-should-component-update.js

+5-4
Original file line numberDiff line numberDiff line change
@@ -44,22 +44,23 @@ ruleTester.run('no-redundant-should-component-update', rule, {
4444
{
4545
code: `
4646
class Foo extends React.Component {
47-
shouldComponentUpdate = () => {
47+
shouldComponentUpdate() {
4848
return true;
4949
}
5050
}
5151
`,
52-
parser: parsers.BABEL_ESLINT,
53-
parserOptions
52+
parserOptions,
53+
parser: parsers.BABEL_ESLINT
5454
},
5555
{
5656
code: `
5757
class Foo extends React.Component {
58-
shouldComponentUpdate() {
58+
shouldComponentUpdate = () => {
5959
return true;
6060
}
6161
}
6262
`,
63+
parser: parsers.BABEL_ESLINT,
6364
parserOptions
6465
},
6566
{

tests/lib/rules/no-typos.js

+1-28
Original file line numberDiff line numberDiff line change
@@ -333,19 +333,6 @@ ruleTester.run('no-typos', rule, {
333333
`,
334334
parser: parsers.BABEL_ESLINT,
335335
parserOptions
336-
}, {
337-
code: `
338-
import PropTypes from "prop-types";
339-
class Component extends React.Component {};
340-
Component.propTypes = {
341-
a: PropTypes.oneOf([
342-
'hello',
343-
'hi'
344-
])
345-
}
346-
`,
347-
parser: parsers.BABEL_ESLINT,
348-
parserOptions
349336
}, {
350337
code: `
351338
import PropTypes from "prop-types";
@@ -406,21 +393,6 @@ ruleTester.run('no-typos', rule, {
406393
}
407394
`,
408395
parserOptions
409-
}, {
410-
code: `
411-
import PropTypes from "prop-types";
412-
class Component extends React.Component {};
413-
Component.childContextTypes = {
414-
a: PropTypes.string,
415-
b: PropTypes.string.isRequired,
416-
c: PropTypes.shape({
417-
d: PropTypes.string,
418-
e: PropTypes.number.isRequired,
419-
}).isRequired
420-
}
421-
`,
422-
parser: parsers.BABEL_ESLINT,
423-
parserOptions
424396
}, {
425397
code: `
426398
import PropTypes from "prop-types";
@@ -1366,6 +1338,7 @@ ruleTester.run('no-typos', rule, {
13661338
}).isrequired
13671339
}
13681340
`,
1341+
parser: parsers.BABEL_ESLINT,
13691342
parserOptions,
13701343
errors: [{
13711344
message: 'Typo in prop type chain qualifier: isrequired'

tests/lib/rules/no-unused-prop-types.js

-34
Original file line numberDiff line numberDiff line change
@@ -5025,40 +5025,6 @@ ruleTester.run('no-unused-prop-types', rule, {
50255025
errors: [{
50265026
message: '\'lastname\' PropType is defined but prop is never used'
50275027
}]
5028-
}, {
5029-
code: [
5030-
'type Person = {',
5031-
' ...data,',
5032-
' lastname: string',
5033-
'};',
5034-
'class Hello extends React.Component {',
5035-
' props: Person;',
5036-
' render () {',
5037-
' return <div>Hello {this.props.firstname}</div>;',
5038-
' }',
5039-
'}'
5040-
].join('\n'),
5041-
parser: parsers.BABEL_ESLINT,
5042-
errors: [{
5043-
message: '\'lastname\' PropType is defined but prop is never used'
5044-
}]
5045-
}, {
5046-
code: [
5047-
'type Person = {|',
5048-
' ...data,',
5049-
' lastname: string',
5050-
'|};',
5051-
'class Hello extends React.Component {',
5052-
' props: Person;',
5053-
' render () {',
5054-
' return <div>Hello {this.props.firstname}</div>;',
5055-
' }',
5056-
'}'
5057-
].join('\n'),
5058-
parser: parsers.BABEL_ESLINT,
5059-
errors: [{
5060-
message: '\'lastname\' PropType is defined but prop is never used'
5061-
}]
50625028
}, {
50635029
code: [
50645030
'class Hello extends React.Component {',

tests/lib/rules/prop-types.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -1448,7 +1448,8 @@ ruleTester.run('prop-types', rule, {
14481448
' }',
14491449
'});'
14501450
].join('\n'),
1451-
options: [{skipUndeclared: true}]
1451+
options: [{skipUndeclared: true}],
1452+
parser: parsers.BABEL_ESLINT
14521453
}, {
14531454
code: [
14541455
'class Hello extends React.Component {',

0 commit comments

Comments
 (0)