📅 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.0

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

name: "eslint-plugin-svelte";
version: "3.2.2";
version: "3.3.0";
};

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

export declare const name = "eslint-plugin-svelte";
export declare const version = "3.2.2";
export declare const version = "3.3.0";

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

export const name = 'eslint-plugin-svelte';
export const version = '3.2.2';
export const version = '3.3.0';

@@ -548,3 +548,4 @@ import type { Linter } from 'eslint';

checkImportedTypes?: boolean;
ignorePatterns?: string[];
ignoreTypePatterns?: string[];
ignorePropertyPatterns?: string[];
}

@@ -551,0 +552,0 @@ ];

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

import { getFilename } from '../utils/compat.js';
let isRemovedWarningShown = false;
export default createRule('no-unused-props', {

@@ -22,3 +23,3 @@ meta: {

},
ignorePatterns: {
ignoreTypePatterns: {
type: 'array',

@@ -29,2 +30,9 @@ items: {

default: []
},
ignorePropertyPatterns: {
type: 'array',
items: {
type: 'string'
},
default: []
}

@@ -59,4 +67,11 @@ },

const options = context.options[0] ?? {};
// TODO: Remove in v4
// MEMO: `ignorePatterns` was a property that only existed from v3.2.0 to v3.2.2.
// From v3.3.0, it was replaced with `ignorePropertyPatterns` and `ignoreTypePatterns`.
if (options.ignorePatterns != null && !isRemovedWarningShown) {
console.warn('eslint-plugin-svelte: The `ignorePatterns` option in the `no-unused-props` rule has been removed. Please use `ignorePropertyPatterns` or/and `ignoreTypePatterns` instead.');
isRemovedWarningShown = true;
}
const checkImportedTypes = options.checkImportedTypes ?? false;
const ignorePatterns = (options.ignorePatterns ?? []).map((p) => {
const ignoreTypePatterns = (options.ignoreTypePatterns ?? []).map((p) => {
if (typeof p === 'string') {

@@ -67,10 +82,19 @@ return toRegExp(p);

});
function shouldIgnore(name) {
return ignorePatterns.some((pattern) => pattern.test(name));
const ignorePropertyPatterns = (options.ignorePropertyPatterns ?? []).map((p) => {
if (typeof p === 'string') {
return toRegExp(p);
}
return p;
});
function shouldIgnoreProperty(name) {
return ignorePropertyPatterns.some((pattern) => pattern.test(name));
}
function shouldIgnoreType(type) {
function isMatched(name) {
return ignoreTypePatterns.some((pattern) => pattern.test(name));
}
const typeStr = typeChecker.typeToString(type);
const symbol = type.getSymbol();
const symbolName = symbol?.getName();
return shouldIgnore(typeStr) || (symbolName ? shouldIgnore(symbolName) : false);
return isMatched(typeStr) || (symbolName ? isMatched(symbolName) : false);
}

@@ -199,2 +223,4 @@ function isInternalProperty(symbol) {

const propName = prop.getName();
if (shouldIgnoreProperty(propName))
continue;
const currentPath = [...parentPath, propName];

@@ -201,0 +227,0 @@ const currentPathStr = [...parentPath, propName].join('.');

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

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