📅 You're Invited: Meet the Socket team at RSAC (April 28 – May 1).RSVP

eslint-plugin-svelte

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.3.2

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

name: "eslint-plugin-svelte";
version: "3.3.1";
version: "3.3.2";
};

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

export declare const name = "eslint-plugin-svelte";
export declare const version = "3.3.1";
export declare const version = "3.3.2";

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

export const name = 'eslint-plugin-svelte';
export const version = '3.3.1';
export const version = '3.3.2';

@@ -136,3 +136,6 @@ import { createRule } from '../utils/index.js';

for (const reference of variable.references) {
if ('identifier' in reference && reference.identifier.type === 'Identifier') {
if ('identifier' in reference &&
reference.identifier.type === 'Identifier' &&
(reference.identifier.range[0] !== node.range[0] ||
reference.identifier.range[1] !== node.range[1])) {
const referencePath = getPropertyPath(reference.identifier);

@@ -226,6 +229,10 @@ paths.push(referencePath);

const propType = typeChecker.getTypeOfSymbol(prop);
const isUsedInPath = usedPaths.some((path) => {
const usedPath = path.join('.');
return usedPath === currentPathStr || usedPath.startsWith(`${currentPathStr}.`);
const joinedUsedPaths = usedPaths.map((path) => path.join('.'));
const isUsedThisInPath = joinedUsedPaths.includes(currentPathStr);
const isUsedInPath = joinedUsedPaths.some((path) => {
return path.startsWith(`${currentPathStr}.`);
});
if (isUsedThisInPath && !isUsedInPath) {
continue;
}
const isUsedInProps = usedProps.has(propName);

@@ -242,5 +249,6 @@ if (!isUsedInPath && !isUsedInProps) {

});
continue;
}
const isUsedNested = usedPaths.some((path) => {
return path.join('.').startsWith(`${currentPathStr}.`);
const isUsedNested = joinedUsedPaths.some((path) => {
return path.startsWith(`${currentPathStr}.`);
});

@@ -271,2 +279,14 @@ if (isUsedNested || isUsedInProps) {

}
function normalizeUsedPaths(paths) {
const normalized = [];
for (const path of paths.sort((a, b) => a.length - b.length)) {
if (path.length === 0)
continue;
if (normalized.some((p) => p.every((part, idx) => part === path[idx]))) {
continue;
}
normalized.push(path);
}
return normalized;
}
return {

@@ -302,3 +322,3 @@ 'VariableDeclaration > VariableDeclarator': (node) => {

}
checkUnusedProperties(propType, usedPaths, usedProps, node.id, [], new Set(), new Set());
checkUnusedProperties(propType, normalizeUsedPaths(usedPaths), usedProps, node.id, [], new Set(), new Set());
}

@@ -305,0 +325,0 @@ };

{
"name": "eslint-plugin-svelte",
"version": "3.3.1",
"version": "3.3.2",
"description": "ESLint plugin for Svelte using AST",

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