diff --git a/packages/eslint-plugin-antfu/src/rules/generic-spacing.test.ts b/packages/eslint-plugin-antfu/src/rules/generic-spacing.test.ts index dc98507fa6..c3aa2d3c41 100644 --- a/packages/eslint-plugin-antfu/src/rules/generic-spacing.test.ts +++ b/packages/eslint-plugin-antfu/src/rules/generic-spacing.test.ts @@ -20,6 +20,9 @@ type Foo< `interface Log { (name: T): void }`, +`interface Foo { + foo?: (name: T) => void +}`, ] const invalids = [ ['type Foo = T', 'type Foo = T'], diff --git a/packages/eslint-plugin-antfu/src/rules/generic-spacing.ts b/packages/eslint-plugin-antfu/src/rules/generic-spacing.ts index 280d3e7181..6df03f9d73 100644 --- a/packages/eslint-plugin-antfu/src/rules/generic-spacing.ts +++ b/packages/eslint-plugin-antfu/src/rules/generic-spacing.ts @@ -23,7 +23,7 @@ export default createEslintRule({ const sourceCode = context.getSourceCode() return { TSTypeParameterDeclaration: (node) => { - if (!['TSCallSignatureDeclaration', 'ArrowFunctionExpression'].includes(node.parent.type)) { + if (!['TSCallSignatureDeclaration', 'ArrowFunctionExpression', 'TSFunctionType'].includes(node.parent.type)) { const pre = sourceCode.text.slice(0, node.range[0]) const preSpace = pre.match(/(\s+)$/)?.[0] // strip space before