Skip to content

Commit

Permalink
add test cases
Browse files Browse the repository at this point in the history
  • Loading branch information
TildaDares committed Aug 11, 2022
1 parent 8e4d17a commit 79e2d0e
Showing 1 changed file with 39 additions and 0 deletions.
39 changes: 39 additions & 0 deletions tests/lib/rules/function-component-definition.js
Original file line number Diff line number Diff line change
Expand Up @@ -406,6 +406,45 @@ ruleTester.run('function-component-definition', rule, {
`,
options: [{ unnamedComponents: ['arrow-function', 'function-expression'] }],
},
{
// should not report non-jsx components
code: `
export default (key, subTree = {}) => {
return (state) => {
const dataInStore = getFromDataModel(key)(state);
const fullPaths = dataInStore.map((item, index) => {
return [key, index];
});
return {
key,
paths: fullPaths.map((p) => [p[1]]),
fullPaths,
subTree: Object.keys(subTree).length ? subTree : null,
}
};
}
`,
},
{
// should not report non-jsx components
code: `
function mapStateToProps() {
const internItems = makeInternArray();
const internClassList = makeInternArray();
return (state, props) => {
const { store, bucket, singleCharacter } = props;
return {
store: null,
destinyVersion: store.destinyVersion,
storeId: store.id,
}
}
}
`,
},
]),

invalid: parsers.all([
Expand Down

0 comments on commit 79e2d0e

Please sign in to comment.