🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
DemoInstallSign in
Socket

eslint-plugin-svelte

Package Overview
Dependencies
Maintainers
5
Versions
138
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

eslint-plugin-svelte - npm Package Compare versions

Comparing version

to
3.9.0

2

lib/main.d.ts

@@ -17,3 +17,3 @@ import './rule-types.js';

name: "eslint-plugin-svelte";
version: "3.8.2";
version: "3.9.0";
};

@@ -20,0 +20,0 @@ export declare const processors: {

export declare const name: "eslint-plugin-svelte";
export declare const version: "3.8.2";
export declare const version: "3.9.0";

@@ -5,2 +5,2 @@ // IMPORTANT!

export const name = 'eslint-plugin-svelte';
export const version = '3.8.2';
export const version = '3.9.0';

@@ -1,2 +0,2 @@

const SVELTE_IGNORE_PATTERN = /^\s*svelte-ignore/m;
const SVELTE_IGNORE_PATTERN = /^\s*svelte-ignore\s+/;
/**

@@ -22,7 +22,9 @@ * Map of legacy code -> new code

for (const comment of sourceCode.getAllComments()) {
const ignores = extractSvelteIgnore(comment.value, comment.range[0] + 2, comment);
if (ignores) {
ignoreComments.push(...ignores);
const match = SVELTE_IGNORE_PATTERN.exec(comment.value);
if (!match) {
continue;
}
else if (hasMissingCodeIgnore(comment.value)) {
const codeListStart = match.index + match[0].length;
const codeList = comment.value.slice(codeListStart);
if (hasMissingCodeIgnore(codeList)) {
ignoreComments.push({

@@ -34,2 +36,8 @@ range: comment.range,

}
else {
const ignores = extractSvelteIgnore(comment.range[0] + 2, comment, codeList, codeListStart);
if (ignores) {
ignoreComments.push(...ignores);
}
}
}

@@ -39,7 +47,9 @@ for (const token of sourceCode.ast.tokens) {

const text = token.value.slice(4, -3);
const ignores = extractSvelteIgnore(text, token.range[0] + 4, token);
if (ignores) {
ignoreComments.push(...ignores);
const match = SVELTE_IGNORE_PATTERN.exec(text);
if (!match) {
continue;
}
else if (hasMissingCodeIgnore(text)) {
const codeListStart = match.index + match[0].length;
const codeList = text.slice(codeListStart);
if (hasMissingCodeIgnore(codeList)) {
ignoreComments.push({

@@ -51,2 +61,8 @@ range: token.range,

}
else {
const ignores = extractSvelteIgnore(token.range[0] + 4, token, codeList, codeListStart);
if (ignores) {
ignoreComments.push(...ignores);
}
}
}

@@ -58,38 +74,34 @@ }

/** Extract svelte-ignore rule names */
function extractSvelteIgnore(text, startIndex, token) {
const m1 = SVELTE_IGNORE_PATTERN.exec(text);
if (!m1) {
return null;
}
const ignoreStart = m1.index + m1[0].length;
const beforeText = text.slice(ignoreStart);
if (!/^\s/.test(beforeText) || !beforeText.trim()) {
return null;
}
let start = startIndex + ignoreStart;
function extractSvelteIgnore(startIndex, token, codeList, ignoreStart) {
const start = startIndex + ignoreStart;
const results = [];
for (const code of beforeText.split(/\s/)) {
const end = start + code.length;
const trimmed = code.trim();
if (trimmed) {
const separatorPattern = /\s*[\s,]\s*/g;
const separators = codeList.matchAll(separatorPattern);
let lastSeparatorEnd = 0;
for (const separator of separators) {
const code = codeList.slice(lastSeparatorEnd, separator.index);
if (code) {
results.push({
code: trimmed,
codeForV5: V5_REPLACEMENTS[trimmed] || trimmed.replace(/-/gu, '_'),
range: [start, end],
code,
codeForV5: V5_REPLACEMENTS[code] || code.replace(/-/gu, '_'),
range: [start + lastSeparatorEnd, start + separator.index],
token
});
}
start = end + 1; /* space */
lastSeparatorEnd = separator.index + separator[0].length;
}
if (results.length === 0) {
const code = codeList;
results.push({
code,
codeForV5: V5_REPLACEMENTS[code] || code.replace(/-/gu, '_'),
range: [start, start + code.length],
token
});
}
return results;
}
/** Checks whether given comment has missing code svelte-ignore */
function hasMissingCodeIgnore(text) {
const m1 = SVELTE_IGNORE_PATTERN.exec(text);
if (!m1) {
return false;
}
const ignoreStart = m1.index + m1[0].length;
const beforeText = text.slice(ignoreStart);
return !beforeText.trim();
function hasMissingCodeIgnore(codeList) {
return !codeList.trim();
}
{
"name": "eslint-plugin-svelte",
"version": "3.8.2",
"version": "3.9.0",
"description": "ESLint plugin for Svelte using AST",

@@ -5,0 +5,0 @@ "repository": "git+https://github.com/sveltejs/eslint-plugin-svelte.git",