Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
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
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