File tree Expand file tree Collapse file tree 1 file changed +31
-2
lines changed
packages/eslint-plugin-lit-a11y/template-analyzer Expand file tree Collapse file tree 1 file changed +31
-2
lines changed Original file line number Diff line number Diff line change @@ -153,9 +153,38 @@ class TemplateAnalyzer {
153153 * @return {import("estree").SourceLocation }
154154 */
155155 resolveLocation ( loc ) {
156+ let offset = 0 ;
157+ let expression ;
158+ let height = 0 ;
159+
160+ for ( const quasi of this . _node . quasi . quasis ) {
161+ const placeholder = util_1 . getExpressionPlaceholder ( this . _node , quasi ) ;
162+ offset += quasi . value . raw . length + placeholder . length ;
163+
164+ const i = this . _node . quasi . quasis . indexOf ( quasi ) ;
165+ if ( i !== 0 ) {
166+ expression = this . _node . quasi . expressions [ i - 1 ] ;
167+ height += expression . loc . end . line - expression . loc . start . line ;
168+ }
169+
170+ if ( loc . startOffset < offset ) {
171+ break ;
172+ }
173+ }
174+
175+ let startOffset ;
176+ let endOffset ;
177+ if ( loc . startLine === 1 ) {
178+ startOffset = loc . startCol + this . _node . quasi . loc . start . column ;
179+ endOffset = loc . endCol + this . _node . quasi . loc . start . column ;
180+ } else {
181+ startOffset = loc . startCol - 1 ;
182+ endOffset = loc . endCol ;
183+ }
184+
156185 return {
157- start : { line : loc . startLine - 1 + this . _node . loc . start . line , column : loc . startCol - 1 } ,
158- end : { line : loc . endLine - 1 + this . _node . loc . start . line , column : loc . endCol - 1 } ,
186+ start : { line : loc . startLine - 1 + this . _node . loc . start . line + height , column : startOffset } ,
187+ end : { line : loc . endLine - 1 + this . _node . loc . start . line + height , column : endOffset } ,
159188 } ;
160189 }
161190
You can’t perform that action at this time.
0 commit comments