File tree Expand file tree Collapse file tree 1 file changed +13
-13
lines changed Expand file tree Collapse file tree 1 file changed +13
-13
lines changed Original file line number Diff line number Diff line change @@ -101,6 +101,14 @@ export const rule = createRule<Options, MessageIds>({
101
101
102
102
const sqlTagIsPresent = tagName === sqlTag ;
103
103
104
+ if ( ignoreTagless && ! sqlTagIsPresent ) {
105
+ return ;
106
+ }
107
+
108
+ if ( ignoreExpressions && node . quasis . length !== 1 ) {
109
+ return ;
110
+ }
111
+
104
112
const templateElement = node . quasis . find ( ( quasi ) => {
105
113
return quasi . type === AST_NODE_TYPES . TemplateElement ;
106
114
} ) ;
@@ -118,23 +126,15 @@ export const rule = createRule<Options, MessageIds>({
118
126
119
127
const lastLine = lines [ lines . length - 1 ] ;
120
128
121
- if ( ! lastLine ) {
122
- throw new Error ( 'Unexpected' ) ;
123
- }
124
-
125
- indentAnchorOffset = lastLine . length ;
129
+ if ( lastLine ) {
130
+ indentAnchorOffset = lastLine . length ;
131
+ } else {
132
+ indentAnchorOffset = 0 ;
133
+ }
126
134
} else if ( templateElement . value . raw . search ( / \S / u) === 0 ) {
127
135
indentAnchorOffset = tabWidth ;
128
136
}
129
137
130
- if ( ignoreTagless && ! sqlTagIsPresent ) {
131
- return ;
132
- }
133
-
134
- if ( ignoreExpressions && node . quasis . length !== 1 ) {
135
- return ;
136
- }
137
-
138
138
const magic = '"gajus-eslint-plugin-sql"' ;
139
139
140
140
const literal = node . quasis
You can’t perform that action at this time.
0 commit comments