eslint-plugin-svelte 2.19.1 → 2.19.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -354,10 +354,23 @@ function processIgnore(warnings, kind, stripStyleElements, ignoreComments, conte
|
|
|
354
354
|
unusedIgnores: [...unusedIgnores],
|
|
355
355
|
};
|
|
356
356
|
function getWarningNode(warning) {
|
|
357
|
-
const
|
|
358
|
-
if (
|
|
359
|
-
|
|
357
|
+
const indexes = getWarningIndexes(warning);
|
|
358
|
+
if (indexes.start != null) {
|
|
359
|
+
const node = getWarningTargetNodeFromIndex(indexes.start);
|
|
360
|
+
if (node) {
|
|
361
|
+
return node;
|
|
362
|
+
}
|
|
363
|
+
if (indexes.end != null) {
|
|
364
|
+
const center = Math.floor(indexes.start + (indexes.end - indexes.start) / 2);
|
|
365
|
+
return getWarningTargetNodeFromIndex(center);
|
|
366
|
+
}
|
|
367
|
+
}
|
|
368
|
+
if (indexes.end != null) {
|
|
369
|
+
return getWarningTargetNodeFromIndex(indexes.end);
|
|
360
370
|
}
|
|
371
|
+
return null;
|
|
372
|
+
}
|
|
373
|
+
function getWarningTargetNodeFromIndex(index) {
|
|
361
374
|
let targetNode = sourceCode.getNodeByRangeIndex(index);
|
|
362
375
|
while (targetNode) {
|
|
363
376
|
if (targetNode.type === "SvelteElement" ||
|
|
@@ -377,13 +390,10 @@ function processIgnore(warnings, kind, stripStyleElements, ignoreComments, conte
|
|
|
377
390
|
}
|
|
378
391
|
return null;
|
|
379
392
|
}
|
|
380
|
-
function
|
|
393
|
+
function getWarningIndexes(warning) {
|
|
381
394
|
const start = warning.start && sourceCode.getIndexFromLoc(warning.start);
|
|
382
395
|
const end = warning.end && sourceCode.getIndexFromLoc(warning.end);
|
|
383
|
-
|
|
384
|
-
return Math.floor(start + (end - start) / 2);
|
|
385
|
-
}
|
|
386
|
-
return start ?? end;
|
|
396
|
+
return { start, end };
|
|
387
397
|
}
|
|
388
398
|
}
|
|
389
399
|
function isUseTypeScript(context) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "eslint-plugin-svelte",
|
|
3
|
-
"version": "2.19.
|
|
3
|
+
"version": "2.19.2",
|
|
4
4
|
"description": "ESLint plugin for Svelte using AST",
|
|
5
5
|
"repository": "git+https://github.com/ota-meshi/eslint-plugin-svelte.git",
|
|
6
6
|
"homepage": "https://ota-meshi.github.io/eslint-plugin-svelte",
|