Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Tests] function-component-definition: add passing test cases #3355

Merged
merged 1 commit into from Aug 13, 2022
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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