diff --git a/tests/lib/rules/function-component-definition.js b/tests/lib/rules/function-component-definition.js index 99f07da99d..c137565050 100644 --- a/tests/lib/rules/function-component-definition.js +++ b/tests/lib/rules/function-component-definition.js @@ -166,8 +166,76 @@ ruleTester.run('function-component-definition', rule, { code: 'function Hello(props): ReactNode { return

}', options: [{namedComponents: 'function-declaration'}], parser: parsers.TYPESCRIPT_ESLINT + }, + // https://github.com/yannickcr/eslint-plugin-react/issues/2765 + { + code: [ + 'const obj = {', + ' serialize: (el) => {', + ' return

', + ' }', + '}' + ].join('\n'), + options: [{namedComponents: 'function-declaration'}] + }, { + code: [ + 'const obj = {', + ' serialize: (el) => {', + ' return

', + ' }', + '}' + ].join('\n'), + options: [{namedComponents: 'function-expression'}] + }, + { + code: [ + 'const obj = {', + ' serialize: function (el) {', + ' return

', + ' }', + '}' + ].join('\n'), + options: [{namedComponents: 'function-declaration'}] }, { - // https://github.com/yannickcr/eslint-plugin-react/issues/2765 + code: [ + 'const obj = {', + ' serialize: function (el) {', + ' return

', + ' }', + '}' + ].join('\n'), + options: [{namedComponents: 'arrow-function'}] + }, + { + code: [ + 'const obj = {', + ' serialize(el) {', + ' return

', + ' }', + '}' + ].join('\n'), + options: [{namedComponents: 'function-expression'}] + }, { + code: [ + 'const obj = {', + ' serialize(el) {', + ' return

', + ' }', + '}' + ].join('\n'), + options: [{namedComponents: 'arrow-function'}] + }, + { + code: [ + 'const obj = {', + ' serialize: (el) => {', + ' return

', + ' }', + '}' + ].join('\n'), + options: [{unnamedComponents: 'function-expression'}] + }, + { code: [ 'const obj = {', ' serialize(el) {',