Skip to content

Commit

Permalink
[Tests] clean up some test cases
Browse files Browse the repository at this point in the history
  • Loading branch information
ljharb committed Dec 28, 2020
1 parent 9e4bbd0 commit a137a04
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 16 deletions.
16 changes: 16 additions & 0 deletions tests/lib/rules/jsx-uses-react.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,27 @@ ruleTester.run('no-unused-vars', rule, {
}, parsers.TS([{
code: '/*eslint jsx-uses-react:1*/ var Frag; <></>;',
errors: [{message: '\'Frag\' is defined but never used.'}],
parser: parsers.TYPESCRIPT_ESLINT,
settings: {react: {fragment: 'Fragment'}}
}, {
code: '/*eslint jsx-uses-react:1*/ var Frag; <></>;',
errors: [{message: '\'Frag\' is defined but never used.'}],
parser: parsers['@TYPESCRIPT_ESLINT'],
settings: {react: {fragment: 'Fragment'}}
}, {
code: '/*eslint jsx-uses-react:1*/ var React; <></>;',
parser: parsers.BABEL_ESLINT,
errors: [{message: '\'React\' is defined but never used.'}],
settings
}, {
code: '/*eslint jsx-uses-react:1*/ var React; <></>;',
parser: parsers.TYPESCRIPT_ESLINT,
errors: [{message: '\'React\' is defined but never used.'}],
settings
}, {
code: '/*eslint jsx-uses-react:1*/ var React; <></>;',
parser: parsers['@TYPESCRIPT_ESLINT'],
errors: [{message: '\'React\' is defined but never used.'}],
settings
}]))
});
35 changes: 19 additions & 16 deletions tests/lib/rules/prop-types.js
Original file line number Diff line number Diff line change
Expand Up @@ -2596,7 +2596,8 @@ ruleTester.run('prop-types', rule, {
},
// shouldn't trigger this rule for 'render' since functions stating with a lowercase
// letter are not considered components
`
{
code: `
const MyComponent = (props) => {
const render = () => {
return <test>{props.hello}</test>;
Expand All @@ -2606,7 +2607,9 @@ ruleTester.run('prop-types', rule, {
MyComponent.propTypes = {
hello: PropTypes.string.isRequired,
};
`,
`,
parser: parsers['@TYPESCRIPT_ESLINT']
},
{
code: `
interface Props {
Expand Down Expand Up @@ -3108,19 +3111,6 @@ ruleTester.run('prop-types', rule, {
code: `
import React from 'react'
class Factory {
getRenderFunction() {
return function renderFunction({ name }) {
return <div>Hello {name}</div>
}
}
}
`
},
{
code: `
import React from 'react'
type ComponentProps = {
name: string
}
Expand All @@ -3135,7 +3125,20 @@ ruleTester.run('prop-types', rule, {
`,
parser: parsers['@TYPESCRIPT_ESLINT']
}
])
]),
{
code: `
import React from 'react'
class Factory {
getRenderFunction() {
return function renderFunction({ name }) {
return <div>Hello {name}</div>
}
}
}
`
}
),

invalid: [].concat(
Expand Down

0 comments on commit a137a04

Please sign in to comment.