diff --git a/tests/lib/rules/function-component-definition.js b/tests/lib/rules/function-component-definition.js index 6fd8269a1f..f75338592f 100644 --- a/tests/lib/rules/function-component-definition.js +++ b/tests/lib/rules/function-component-definition.js @@ -68,6 +68,32 @@ ruleTester.run('function-component-definition', rule, { }, { code: 'var Foo = React.memo(function Foo() { return

})', options: [{namedComponents: 'function-declaration'}] + }, { + // shouldn't trigger this rule since functions stating with a lowercase + // letter are not considered components + code: ` + const selectAvatarByUserId = (state, id) => { + const user = selectUserById(state, id) + return null + } + `, + options: [{namedComponents: 'function-declaration'}] + }, { + // shouldn't trigger this rule since functions stating with a lowercase + // letter are not considered components + code: ` + function ensureValidSourceType(sourceType: string) { + switch (sourceType) { + case 'ALBUM': + case 'PLAYLIST': + return sourceType; + default: + return null; + } + } + `, + options: [{namedComponents: 'arrow-function'}], + parser: parsers.TYPESCRIPT_ESLINT }, { code: 'function Hello(props: Test) { return

}', options: [{namedComponents: 'function-declaration'}], diff --git a/tests/lib/rules/prop-types.js b/tests/lib/rules/prop-types.js index bf9926c382..3ae7c0bd86 100755 --- a/tests/lib/rules/prop-types.js +++ b/tests/lib/rules/prop-types.js @@ -2504,7 +2504,27 @@ ruleTester.run('prop-types', rule, { } `, parser: parsers.TYPESCRIPT_ESLINT - } + }, + // shouldn't trigger this rule since functions stating with a lowercase + // letter are not considered components + ` + function noAComponent(props) { + return

{props.text}
+ } + `, + // shouldn't trigger this rule for 'render' since functions stating with a lowercase + // letter are not considered components + ` + const MyComponent = (props) => { + const render = () => { + return {props.hello}; + } + return render(); + }; + MyComponent.propTypes = { + hello: PropTypes.string.isRequired, + }; + ` ], invalid: [