fix(generic-spacing): avoid overriding extends
This commit is contained in:
parent
4b51ef2eba
commit
4119f52750
@ -9,6 +9,7 @@ type Foo<
|
||||
T = true,
|
||||
K = false
|
||||
> = T`,
|
||||
'type Foo<T extends true = true> = T',
|
||||
]
|
||||
const invalids = [
|
||||
['type Foo<T=true> = T', 'type Foo<T = true> = T'],
|
||||
|
@ -48,7 +48,8 @@ export default createEslintRule<Options, MessageIds>({
|
||||
TSTypeParameter: (node) => {
|
||||
if (!node.default)
|
||||
return
|
||||
const from = node.name.range[1]
|
||||
const endNode = node.constraint || node.name
|
||||
const from = endNode.range[1]
|
||||
const to = node.default.range[0]
|
||||
if (sourceCode.text.slice(from, to) !== ' = ') {
|
||||
context.report({
|
||||
@ -56,7 +57,7 @@ export default createEslintRule<Options, MessageIds>({
|
||||
yield fixer.replaceTextRange([from, to], ' = ')
|
||||
},
|
||||
loc: {
|
||||
start: node.name.loc.end,
|
||||
start: endNode.loc.end,
|
||||
end: node.default.loc.start,
|
||||
},
|
||||
messageId: 'genericSpacingMismatch',
|
||||
|
Loading…
Reference in New Issue
Block a user