Skip to content

Commit e2517a7

Browse files
committed
fix: spacing before colon
1 parent 8e1522d commit e2517a7

File tree

2 files changed

+10
-7
lines changed

2 files changed

+10
-7
lines changed

deno.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@loat-dev/lint-plugins",
3-
"version": "0.3.10",
3+
"version": "0.3.11",
44
"license": "./LICENSE",
55
"exports": {
66
"./colon_spacing": "./src/plugins/colon_spacing.ts",

src/plugins/colon_spacing.ts

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -124,15 +124,18 @@ const colonSpacing : Deno.lint.Plugin = {
124124
}
125125
},
126126
Identifier(node) : void {
127-
if (node.typeAnnotation && node.parent.type !== 'TSIndexSignature') {
128-
// Text _ from "<name>___?__:<type>"
129-
const section : Deno.lint.Range = [node.range[1], node.typeAnnotation.range[0]]
127+
if (node.typeAnnotation) {
128+
// Text _ from "_<name>___?__:<type>"
129+
const section : Deno.lint.Range = [node.range[0], node.typeAnnotation.range[0]]
130130

131-
// Text _ from "<name>___?__:<type>"
131+
// Text _ from "_<name>___?__:<type>"
132132
const text = context.sourceCode.getText(node.parent).substring(
133-
node.range[1] - node.parent.range[0],
134-
node.typeAnnotation.range[0] - node.parent.range[0]
133+
node.range[0] - node.parent.range[0],
134+
node.typeAnnotation.range[0] - node.parent.range[0] + 1
135135
)
136+
137+
// Section | from "<name>| |:<type>"
138+
section[0] += text.search(/ *:/);
136139

137140
if (node.optional) {
138141
// Index of ? from "<name>?__:<type>"

0 commit comments

Comments
 (0)