Skip to content

Commit

Permalink
fix(generic-spacing): improve cases
Browse files Browse the repository at this point in the history
  • Loading branch information
antfu committed Nov 7, 2022
1 parent 54b234f commit 95e28e4
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
Expand Up @@ -20,6 +20,9 @@ type Foo<
`interface Log {
<T>(name: T): void
}`,
`interface Foo {
foo?: <T>(name: T) => void
}`,
]
const invalids = [
['type Foo<T=true> = T', 'type Foo<T = true> = T'],
Expand Down
2 changes: 1 addition & 1 deletion packages/eslint-plugin-antfu/src/rules/generic-spacing.ts
Expand Up @@ -23,7 +23,7 @@ export default createEslintRule<Options, MessageIds>({
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 <T>
Expand Down

0 comments on commit 95e28e4

Please sign in to comment.