From 79e2d0e71578cd8326e8155b10413154d71e89c8 Mon Sep 17 00:00:00 2001 From: TildaDares Date: Thu, 11 Aug 2022 22:17:48 +0100 Subject: [PATCH] add test cases --- .../rules/function-component-definition.js | 39 +++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/tests/lib/rules/function-component-definition.js b/tests/lib/rules/function-component-definition.js index 5040d03f5a..ea2acb541d 100644 --- a/tests/lib/rules/function-component-definition.js +++ b/tests/lib/rules/function-component-definition.js @@ -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([