Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/dev/rc' into rc
Browse files Browse the repository at this point in the history
  • Loading branch information
1aron committed May 7, 2024
2 parents 659f112 + d557f0e commit 4cbb700
Showing 1 changed file with 17 additions and 15 deletions.
32 changes: 17 additions & 15 deletions packages/eslint-plugin/src/utils/find-loc.ts
Expand Up @@ -8,26 +8,28 @@ export default function findLoc(text, lines, startLine, endLine) {

for (let i = startLine; i <= endLine; i++) {
const sourceCodeLine = lines[i - 1]

const index = sourceCodeLine.indexOf(targetLines[checkingTargetLine].replace(/\r\n|\n/, ''))
const content = targetLines[checkingTargetLine].replace(/\r\n|\n/, '')
const index = sourceCodeLine.indexOf(content)
if (index !== -1) {
if (checkingTargetLine === 0) {
resultStart = {
line: i,
column: index
}
}
if (checkingTargetLine === targetLines.length - 1) {
return {
start: resultStart,
end: {
if (index === 0 || sourceCodeLine[index - 1].match(/^|[\s"'']/)) {
if (checkingTargetLine === 0) {
resultStart = {
line: i,
column: index + text.length
column: index
}
}
if (checkingTargetLine === targetLines.length - 1 && (sourceCodeLine[index + content.length - 1].match(/$|[\s"'']/) || sourceCodeLine[index + content.length].match(/[\s"'']/))) {
return {
start: resultStart,
end: {
line: i,
column: index + text.length
}
}
}
checking = true
checkingTargetLine++
}
checking = true
checkingTargetLine++
} else {
if (checking) {
checking = false
Expand Down

0 comments on commit 4cbb700

Please sign in to comment.