Skip to content

Commit

Permalink
[Tests] function-component-definition: add passing test cases
Browse files Browse the repository at this point in the history
Closes #3057
  • Loading branch information
TildaDares authored and ljharb committed Aug 11, 2022
1 parent d000f8c commit 23121e0
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 0 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Expand Up @@ -34,7 +34,9 @@ This change log adheres to standards from [Keep a CHANGELOG](https://keepachange
* [readme] remove dead codeclimate badge, add actions badge (@ljharb)
* [readme] Remove dead david-dm badge ([#3262][] @ddzz)
* [Refactor] [`jsx-closing-bracket-location`], [`jsx-no-bind`]: fix eslint issues ([#3351][] @caroline223)
* [Tests] [`function-component-definition`]: add passing test cases ([#3355][] @TildaDares)

[#3355]: https://github.com/jsx-eslint/eslint-plugin-react/pull/3355
[#3353]: https://github.com/jsx-eslint/eslint-plugin-react/pull/3353
[#3351]: https://github.com/jsx-eslint/eslint-plugin-react/pull/3351
[#3350]: https://github.com/jsx-eslint/eslint-plugin-react/pull/3350
Expand Down
39 changes: 39 additions & 0 deletions tests/lib/rules/function-component-definition.js
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 23121e0

Please sign in to comment.