Socket
Socket
Sign inDemoInstall

svelte-eslint-parser

Package Overview
Dependencies
Maintainers
0
Versions
111
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

svelte-eslint-parser - npm Package Compare versions

Comparing version 0.39.1 to 0.39.2

3

lib/context/fix-locations.js
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.fixLocations = void 0;
exports.fixLocations = fixLocations;
const traverse_1 = require("../traverse");

@@ -53,3 +53,2 @@ /** Fix locations */

}
exports.fixLocations = fixLocations;
/**

@@ -56,0 +55,0 @@ * applyLocs

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

/// <reference types="svelte" />
import type { Comment, Locations, SvelteElement, SvelteHTMLElement, SvelteScriptElement, SvelteSnippetBlock, SvelteStyleElement, Token } from "../ast";

@@ -3,0 +2,0 @@ import type ESTree from "estree";

@@ -26,2 +26,3 @@ import type { ScopeManager, Scope } from "eslint-scope";

};
type StatementNodeType = `${TSESTree.Statement["type"]}`;
type TypeGenHelper = {

@@ -63,6 +64,9 @@ generateUniqueId: (base: string) => string;

} | null, eachBlock: SvelteEachBlock, callback: (expr: ESTree.Expression, ctx: ESTree.Pattern, index: ESTree.Identifier | null) => void): void;
nestSnippetBlock(id: ESTree.Identifier, closeParentIndex: number, snippetBlock: SvelteSnippetBlock, kind: "snippet" | "render", callback: (id: ESTree.Identifier, params: ESTree.Pattern[]) => void): void;
nestSnippetBlock(id: ESTree.Identifier, closeParentIndex: number, snippetBlock: SvelteSnippetBlock, kind: "snippet" | null, callback: (id: ESTree.Identifier, params: ESTree.Pattern[]) => void): void;
nestBlock(block: SvelteNode, params?: ScriptLetBlockParam[] | ((helper: TypeGenHelper | null) => {
param: ScriptLetBlockParam;
preparationScript?: string[];
preparationScript?: {
script: string;
nodeType: StatementNodeType;
}[];
})): void;

@@ -69,0 +73,0 @@ closeScope(): void;

@@ -50,3 +50,3 @@ "use strict";

const isTS = typing && this.ctx.isTypeScript();
this.appendScript(`(${part})${isTS ? `as (${typing})` : ""};`, range[0] - 1, this.currentScriptScopeKind, (st, tokens, comments, result) => {
this.appendScript(`(${part})${isTS ? `as (${typing})` : ""};`, range[0] - 1, this.currentScriptScopeKind, "ExpressionStatement", (st, tokens, comments, result) => {
const exprSt = st;

@@ -85,3 +85,3 @@ const tsAs = isTS

const part = this.ctx.code.slice(...range);
this.appendScript(`({${part}});`, range[0] - 2, this.currentScriptScopeKind, (st, tokens, _comments, result) => {
this.appendScript(`({${part}});`, range[0] - 2, this.currentScriptScopeKind, "ExpressionStatement", (st, tokens, _comments, result) => {
const exprSt = st;

@@ -111,3 +111,3 @@ const objectExpression = exprSt.expression;

const part = this.ctx.code.slice(...range);
this.appendScript(`const ${part};`, range[0] - 6, this.currentScriptScopeKind, (st, tokens, _comments, result) => {
this.appendScript(`const ${part};`, range[0] - 6, this.currentScriptScopeKind, "VariableDeclaration", (st, tokens, _comments, result) => {
const decl = st;

@@ -146,3 +146,3 @@ const node = decl.declarations[0];

}
this.appendScript(scriptLet, ranges.idRange[0] - 5, "generics", (st, tokens, _comments, result) => {
this.appendScript(scriptLet, ranges.idRange[0] - 5, "generics", "TSTypeAliasDeclaration", (st, tokens, _comments, result) => {
const decl = st;

@@ -186,3 +186,3 @@ const id = decl.id;

const scriptLet = `type ${id}${eqDefaultType};`;
this.appendScript(scriptLet, ranges.defaultRange[0] - 5 - id.length - 1, "generics", (st, tokens, _comments, result) => {
this.appendScript(scriptLet, ranges.defaultRange[0] - 5 - id.length - 1, "generics", "TSTypeAliasDeclaration", (st, tokens, _comments, result) => {
const decl = st;

@@ -208,3 +208,3 @@ const typeAnnotation = decl.typeAnnotation;

const part = this.ctx.code.slice(...range);
const restore = this.appendScript(`if(${part}){`, range[0] - 3, this.currentScriptScopeKind, (st, tokens, _comments, result) => {
const restore = this.appendScript(`if(${part}){`, range[0] - 3, this.currentScriptScopeKind, "IfStatement", (st, tokens, _comments, result) => {
const ifSt = st;

@@ -244,3 +244,3 @@ const node = ifSt.test;

source += ")=>{";
const restore = this.appendScript(source, exprRange[0] - exprOffset, this.currentScriptScopeKind, (st, tokens, comments, result) => {
const restore = this.appendScript(source, exprRange[0] - exprOffset, this.currentScriptScopeKind, "ExpressionStatement", (st, tokens, comments, result) => {
var _a;

@@ -314,6 +314,9 @@ const expSt = st;

}
nestSnippetBlock(id, closeParentIndex, snippetBlock, kind, callback) {
nestSnippetBlock(id, closeParentIndex, snippetBlock,
// If set to null, `currentScriptScopeKind` will be used.
kind, callback) {
const scopeKind = kind || this.currentScriptScopeKind;
const idRange = getNodeRange(id);
const part = this.ctx.code.slice(idRange[0], closeParentIndex + 1);
const restore = this.appendScript(`function ${part}{`, idRange[0] - 9, kind, (st, tokens, _comments, result) => {
const restore = this.appendScript(`function ${part}{`, idRange[0] - 9, scopeKind, "FunctionDeclaration", (st, tokens, _comments, result) => {
const fnDecl = st;

@@ -338,3 +341,3 @@ const idNode = fnDecl.id;

});
this.pushScope(restore, "}", kind);
this.pushScope(restore, "}", scopeKind);
}

@@ -351,3 +354,3 @@ nestBlock(block, params) {

for (const preparationScript of generatedTypes.preparationScript) {
this.appendScriptWithoutOffset(preparationScript, this.currentScriptScopeKind, (node, tokens, comments, result) => {
this.appendScriptWithoutOffset(preparationScript.script, this.currentScriptScopeKind, preparationScript.nodeType, (node, tokens, comments, result) => {
tokens.length = 0;

@@ -369,3 +372,3 @@ comments.length = 0;

if (!resolvedParams || resolvedParams.length === 0) {
const restore = this.appendScript(`{`, block.range[0], this.currentScriptScopeKind, (st, tokens, _comments, result) => {
const restore = this.appendScript(`{`, block.range[0], this.currentScriptScopeKind, "BlockStatement", (st, tokens, _comments, result) => {
const blockSt = st;

@@ -410,3 +413,3 @@ // Process for scope

}
const restore = this.appendScript(`(${source})=>{`, maps[0].range[0] - 1, this.currentScriptScopeKind, (st, tokens, comments, result) => {
const restore = this.appendScript(`(${source})=>{`, maps[0].range[0] - 1, this.currentScriptScopeKind, "ExpressionStatement", (st, tokens, comments, result) => {
const exprSt = st;

@@ -465,4 +468,4 @@ const fn = exprSt.expression;

}
appendScript(text, offset, kind, callback) {
const resultCallback = this.appendScriptWithoutOffset(text, kind, (node, tokens, comments, result) => {
appendScript(text, offset, kind, nodeType, callback) {
const resultCallback = this.appendScriptWithoutOffset(text, kind, nodeType, (node, tokens, comments, result) => {
(0, fix_locations_1.fixLocations)(node, tokens, comments, offset - resultCallback.start, result.visitorKeys, this.ctx);

@@ -473,3 +476,3 @@ callback(node, tokens, comments, result);

}
appendScriptWithoutOffset(text, kind, callback) {
appendScriptWithoutOffset(text, kind, nodeType, callback) {
const { start: startOffset, end: endOffset } = this.script.addLet(text, kind);

@@ -479,2 +482,3 @@ const restoreCallback = {

end: endOffset,
nodeType,
callback,

@@ -593,3 +597,4 @@ };

}
if (orderedRestoreCallback.start <= node.range[0] &&
if (orderedRestoreCallback.nodeType === node.type &&
orderedRestoreCallback.start <= node.range[0] &&
node.range[1] <= orderedRestoreCallback.end) {

@@ -596,0 +601,0 @@ targetNodes.set(node, orderedRestoreCallback);

export declare const name = "svelte-eslint-parser";
export declare const version = "0.39.1";
export declare const version = "0.39.2";

@@ -8,2 +8,2 @@ "use strict";

exports.name = "svelte-eslint-parser";
exports.version = "0.39.1";
exports.version = "0.39.2";
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.analyzeSnippetsScope = exports.analyzePropsScope = exports.analyzeStoreScope = exports.analyzeReactiveScope = exports.analyzeScope = void 0;
exports.analyzeScope = analyzeScope;
exports.analyzeReactiveScope = analyzeReactiveScope;
exports.analyzeStoreScope = analyzeStoreScope;
exports.analyzePropsScope = analyzePropsScope;
exports.analyzeSnippetsScope = analyzeSnippetsScope;
const eslint_scope_1 = require("eslint-scope");

@@ -31,3 +35,2 @@ const traverse_1 = require("../traverse");

}
exports.analyzeScope = analyzeScope;
/** Analyze reactive scope */

@@ -75,3 +78,2 @@ function analyzeReactiveScope(scopeManager) {

}
exports.analyzeReactiveScope = analyzeReactiveScope;
/**

@@ -120,3 +122,2 @@ * Analyze store scope. e.g. $count

}
exports.analyzeStoreScope = analyzeStoreScope;
/** Transform props exports */

@@ -226,3 +227,2 @@ function analyzePropsScope(body, scopeManager, svelteParseContext) {

}
exports.analyzePropsScope = analyzePropsScope;
/** Analyze snippets in component scope */

@@ -250,3 +250,2 @@ function analyzeSnippetsScope(snippets, scopeManager) {

}
exports.analyzeSnippetsScope = analyzeSnippetsScope;
/** Remove reference from through */

@@ -253,0 +252,0 @@ function removeReferenceFromThrough(reference, baseScope) {

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

/// <reference types="svelte" />
/** Compatibility for Svelte v4 <-> v5 */

@@ -3,0 +2,0 @@ import type ESTree from "estree";

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.getDeclaratorFromConstTag = exports.getCatchFromAwaitBlock = exports.getThenFromAwaitBlock = exports.getPendingFromAwaitBlock = exports.getFallbackFromEachBlock = exports.getBodyFromEachBlock = exports.getAlternateFromIfBlock = exports.getConsequentFromIfBlock = exports.getTestFromIfBlock = exports.getModifiers = exports.getFragment = exports.trimChildren = exports.getChildren = exports.getOptionsFromRoot = exports.getModuleFromRoot = exports.getInstanceFromRoot = exports.getFragmentFromRoot = void 0;
exports.getFragmentFromRoot = getFragmentFromRoot;
exports.getInstanceFromRoot = getInstanceFromRoot;
exports.getModuleFromRoot = getModuleFromRoot;
exports.getOptionsFromRoot = getOptionsFromRoot;
exports.getChildren = getChildren;
exports.trimChildren = trimChildren;
exports.getFragment = getFragment;
exports.getModifiers = getModifiers;
exports.getTestFromIfBlock = getTestFromIfBlock;
exports.getConsequentFromIfBlock = getConsequentFromIfBlock;
exports.getAlternateFromIfBlock = getAlternateFromIfBlock;
exports.getBodyFromEachBlock = getBodyFromEachBlock;
exports.getFallbackFromEachBlock = getFallbackFromEachBlock;
exports.getPendingFromAwaitBlock = getPendingFromAwaitBlock;
exports.getThenFromAwaitBlock = getThenFromAwaitBlock;
exports.getCatchFromAwaitBlock = getCatchFromAwaitBlock;
exports.getDeclaratorFromConstTag = getDeclaratorFromConstTag;
// Root

@@ -9,11 +25,8 @@ function getFragmentFromRoot(svelteAst) {

}
exports.getFragmentFromRoot = getFragmentFromRoot;
function getInstanceFromRoot(svelteAst) {
return svelteAst.instance;
}
exports.getInstanceFromRoot = getInstanceFromRoot;
function getModuleFromRoot(svelteAst) {
return svelteAst.module;
}
exports.getModuleFromRoot = getModuleFromRoot;
function getOptionsFromRoot(svelteAst) {

@@ -38,3 +51,2 @@ const root = svelteAst;

}
exports.getOptionsFromRoot = getOptionsFromRoot;
function getChildren(fragment) {

@@ -44,3 +56,2 @@ var _a;

}
exports.getChildren = getChildren;
function trimChildren(children) {

@@ -86,3 +97,2 @@ if (!startsWithWhitespace(children[0]) &&

}
exports.trimChildren = trimChildren;
function getFragment(element) {

@@ -94,3 +104,2 @@ if (element.fragment) {

}
exports.getFragment = getFragment;
function getModifiers(node) {

@@ -100,3 +109,2 @@ var _a;

}
exports.getModifiers = getModifiers;
// IfBlock

@@ -107,3 +115,2 @@ function getTestFromIfBlock(block) {

}
exports.getTestFromIfBlock = getTestFromIfBlock;
function getConsequentFromIfBlock(block) {

@@ -113,3 +120,2 @@ var _a;

}
exports.getConsequentFromIfBlock = getConsequentFromIfBlock;
function getAlternateFromIfBlock(block) {

@@ -122,3 +128,2 @@ var _a;

}
exports.getAlternateFromIfBlock = getAlternateFromIfBlock;
// EachBlock

@@ -131,3 +136,2 @@ function getBodyFromEachBlock(block) {

}
exports.getBodyFromEachBlock = getBodyFromEachBlock;
function getFallbackFromEachBlock(block) {

@@ -140,3 +144,2 @@ var _a;

}
exports.getFallbackFromEachBlock = getFallbackFromEachBlock;
// AwaitBlock

@@ -153,3 +156,2 @@ function getPendingFromAwaitBlock(block) {

}
exports.getPendingFromAwaitBlock = getPendingFromAwaitBlock;
function getThenFromAwaitBlock(block) {

@@ -165,3 +167,2 @@ const then = block.then;

}
exports.getThenFromAwaitBlock = getThenFromAwaitBlock;
function getCatchFromAwaitBlock(block) {

@@ -177,3 +178,2 @@ const catchFragment = block.catch;

}
exports.getCatchFromAwaitBlock = getCatchFromAwaitBlock;
// ConstTag

@@ -184,2 +184,1 @@ function getDeclaratorFromConstTag(node) {

}
exports.getDeclaratorFromConstTag = getDeclaratorFromConstTag;

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

/// <reference types="svelte" />
import type { SvelteAttribute, SvelteShorthandAttribute, SvelteDirective, SvelteSpreadAttribute, SvelteStartTag, SvelteStyleDirective } from "../../ast";

@@ -3,0 +2,0 @@ import type { Context } from "../../context";

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.convertAttributes = void 0;
exports.convertAttributes = convertAttributes;
const common_1 = require("./common");

@@ -67,3 +67,2 @@ const mustache_1 = require("./mustache");

}
exports.convertAttributes = convertAttributes;
/** Convert for Attribute */

@@ -70,0 +69,0 @@ function convertAttribute(node, parent, ctx) {

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

/// <reference types="svelte" />
import type * as SvAST from "../svelte-ast-types";

@@ -3,0 +2,0 @@ import type * as Compiler from "svelte/compiler";

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.convertSnippetBlock = exports.convertKeyBlock = exports.convertAwaitBlock = exports.convertEachBlock = exports.convertIfBlock = void 0;
exports.convertIfBlock = convertIfBlock;
exports.convertEachBlock = convertEachBlock;
exports.convertAwaitBlock = convertAwaitBlock;
exports.convertKeyBlock = convertKeyBlock;
exports.convertSnippetBlock = convertSnippetBlock;
const element_1 = require("./element");

@@ -106,3 +110,2 @@ const common_1 = require("./common");

}
exports.convertIfBlock = convertIfBlock;
function startBlockIndexForElse(elseFragment, beforeFragment, lastExpression, ctx) {

@@ -182,3 +185,2 @@ let baseStart;

}
exports.convertEachBlock = convertEachBlock;
/** Convert for AwaitBlock */

@@ -254,3 +256,6 @@ function convertAwaitBlock(node, parent, ctx) {

preparationScript: [
`const ${id} = ${expression};`,
{
script: `const ${id} = ${expression};`,
nodeType: "VariableDeclaration",
},
generateAwaitThenValueType(idAwaitThenValue),

@@ -330,3 +335,2 @@ ],

}
exports.convertAwaitBlock = convertAwaitBlock;
/** Convert for KeyBlock */

@@ -349,3 +353,2 @@ function convertKeyBlock(node, parent, ctx) {

}
exports.convertKeyBlock = convertKeyBlock;
/** Convert for SnippetBlock */

@@ -359,3 +362,6 @@ function convertSnippetBlock(node, parent, ctx) {

: node.expression).end);
const scopeKind = parent.type === "Program" ? "snippet" : "render";
const scopeKind = parent.type === "Program"
? "snippet"
: // use currentScriptScopeKind
null;
ctx.scriptLet.nestSnippetBlock(node.expression, closeParenIndex, snippetBlock, scopeKind, (id, params) => {

@@ -375,3 +381,2 @@ snippetBlock.id = id;

}
exports.convertSnippetBlock = convertSnippetBlock;
/** Extract mustache block tokens */

@@ -397,3 +402,4 @@ function extractMustacheBlockTokens(node, ctx, option) {

function generateAwaitThenValueType(id) {
return `type ${id}<T> = T extends null | undefined
return {
script: `type ${id}<T> = T extends null | undefined
? T

@@ -404,3 +410,5 @@ : T extends { then(value: infer F): any }

: never
: T;`;
: T;`,
nodeType: "TSTypeAliasDeclaration",
};
}

@@ -407,0 +415,0 @@ /** Checks whether the given name identifier is exists or not. */

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.getWithLoc = exports.lastIndexOf = exports.indexOf = void 0;
exports.indexOf = indexOf;
exports.lastIndexOf = lastIndexOf;
exports.getWithLoc = getWithLoc;
/** indexOf */

@@ -15,3 +17,2 @@ function indexOf(str, search, start, end) {

}
exports.indexOf = indexOf;
/** lastIndexOf */

@@ -27,3 +28,2 @@ function lastIndexOf(str, search, end) {

}
exports.lastIndexOf = lastIndexOf;
/** Get node with location */

@@ -33,2 +33,1 @@ function getWithLoc(node) {

}
exports.getWithLoc = getWithLoc;

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

/// <reference types="svelte" />
import type { SvelteConstTag } from "../../ast";

@@ -3,0 +2,0 @@ import type { Context } from "../../context";

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.convertConstTag = void 0;
exports.convertConstTag = convertConstTag;
const compat_1 = require("../compat");

@@ -18,2 +18,1 @@ /** Convert for ConstTag */

}
exports.convertConstTag = convertConstTag;

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

/// <reference types="svelte" />
import type { SvelteAwaitBlock, SvelteAwaitCatchBlock, SvelteAwaitPendingBlock, SvelteAwaitThenBlock, SvelteConstTag, SvelteDebugTag, SvelteEachBlock, SvelteElement, SvelteElseBlockAlone, SvelteHTMLComment, SvelteIfBlock, SvelteIfBlockAlone, SvelteKeyBlock, SvelteMustacheTag, SvelteProgram, SvelteRenderTag, SvelteScriptElement, SvelteSnippetBlock, SvelteStyleElement, SvelteText } from "../../ast";

@@ -3,0 +2,0 @@ import type { Context } from "../../context";

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.extractElementTags = exports.convertChildren = void 0;
exports.convertChildren = convertChildren;
exports.extractElementTags = extractElementTags;
const block_1 = require("./block");

@@ -143,3 +144,2 @@ const common_1 = require("./common");

}
exports.convertChildren = convertChildren;
/** Extract `let:` directives. */

@@ -574,2 +574,1 @@ function extractLetDirectives(fragment) {

}
exports.extractElementTags = extractElementTags;

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

/// <reference types="svelte" />
import type { SvelteDebugTag, SvelteMustacheTag, SvelteMustacheTagRaw, SvelteMustacheTagText } from "../../ast";

@@ -3,0 +2,0 @@ import type { Context } from "../../context";

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.convertDebugTag = exports.convertRawMustacheTag = exports.convertMustacheTag = void 0;
exports.convertMustacheTag = convertMustacheTag;
exports.convertRawMustacheTag = convertRawMustacheTag;
exports.convertDebugTag = convertDebugTag;
const utils_1 = require("../../utils");

@@ -9,3 +11,2 @@ /** Convert for MustacheTag */

}
exports.convertMustacheTag = convertMustacheTag;
/** Convert for MustacheTag */

@@ -21,3 +22,2 @@ function convertRawMustacheTag(node, parent, ctx) {

}
exports.convertRawMustacheTag = convertRawMustacheTag;
/** Convert for DebugTag */

@@ -38,3 +38,2 @@ function convertDebugTag(node, parent, ctx) {

}
exports.convertDebugTag = convertDebugTag;
/** Convert to MustacheTag */

@@ -41,0 +40,0 @@ function convertMustacheTag0(node, kind, parent, typing, ctx) {

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

/// <reference types="svelte" />
import type { SvelteRenderTag } from "../../ast";

@@ -3,0 +2,0 @@ import type { Context } from "../../context";

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.convertRenderTag = void 0;
exports.convertRenderTag = convertRenderTag;
const common_1 = require("./common");

@@ -20,2 +20,1 @@ /** Convert for RenderTag */

}
exports.convertRenderTag = convertRenderTag;

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

/// <reference types="svelte" />
import type * as SvAST from "../svelte-ast-types";

@@ -3,0 +2,0 @@ import type * as Compiler from "svelte/compiler";

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.convertSvelteRoot = void 0;
exports.convertSvelteRoot = convertSvelteRoot;
const element_1 = require("./element");

@@ -116,3 +116,2 @@ const attr_1 = require("./attr");

}
exports.convertSvelteRoot = convertSvelteRoot;
/** Extract attrs */

@@ -119,0 +118,0 @@ function extractAttributes(element, ctx) {

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.convertTextToLiteral = exports.convertText = void 0;
exports.convertText = convertText;
exports.convertTextToLiteral = convertTextToLiteral;
/** Convert for Text */

@@ -10,3 +11,2 @@ function convertText(node, parent, ctx) {

}
exports.convertText = convertText;
/** Convert for Text to Literal */

@@ -18,3 +18,2 @@ function convertTextToLiteral(node, parent, ctx) {

}
exports.convertTextToLiteral = convertTextToLiteral;
/** Extract tokens */

@@ -21,0 +20,0 @@ function extractTextTokens(node, ctx) {

@@ -6,3 +6,3 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.getEspree = void 0;
exports.getEspree = getEspree;
const module_1 = __importDefault(require("module"));

@@ -57,2 +57,1 @@ const path_1 = __importDefault(require("path"));

}
exports.getEspree = getEspree;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.getGlobalsForSvelteScript = exports.getGlobalsForSvelte = exports.globalsForRunes = void 0;
exports.globalsForRunes = void 0;
exports.getGlobalsForSvelte = getGlobalsForSvelte;
exports.getGlobalsForSvelteScript = getGlobalsForSvelteScript;
const globalsForSvelte = ["$$slots", "$$props", "$$restProps"];

@@ -20,3 +22,2 @@ exports.globalsForRunes = [

}
exports.getGlobalsForSvelte = getGlobalsForSvelte;
function getGlobalsForSvelteScript(svelteParseContext) {

@@ -28,2 +29,1 @@ if (svelteParseContext.runes) {

}
exports.getGlobalsForSvelteScript = getGlobalsForSvelteScript;

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

/// <reference types="svelte" />
import type * as Compiler from "svelte/compiler";

@@ -3,0 +2,0 @@ /** Parse HTML attributes */

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.parseAttributes = void 0;
exports.parseAttributes = parseAttributes;
const espree_1 = require("./espree");

@@ -54,3 +54,2 @@ const RE_IS_SPACE = /^\s$/u;

}
exports.parseAttributes = parseAttributes;
/** Parse HTML attribute */

@@ -57,0 +56,0 @@ function parseAttribute(state) {

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

/// <reference types="svelte" />
import type { Comment, SvelteProgram, Token } from "../ast";

@@ -3,0 +2,0 @@ import type { Program } from "estree";

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.parseForESLint = void 0;
exports.parseForESLint = parseForESLint;
const visitor_keys_1 = require("../visitor-keys");

@@ -39,3 +39,2 @@ const context_1 = require("../context");

}
exports.parseForESLint = parseForESLint;
/**

@@ -42,0 +41,0 @@ * Parse source code as svelte component

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.isTSESLintParserObject = exports.maybeTSESLintParserObject = exports.isBasicParserObject = exports.isEnhancedParserObject = exports.isParserObject = void 0;
exports.isParserObject = isParserObject;
exports.isEnhancedParserObject = isEnhancedParserObject;
exports.isBasicParserObject = isBasicParserObject;
exports.maybeTSESLintParserObject = maybeTSESLintParserObject;
exports.isTSESLintParserObject = isTSESLintParserObject;
/** Checks whether given object is ParserObject */

@@ -8,3 +12,2 @@ function isParserObject(value) {

}
exports.isParserObject = isParserObject;
/** Checks whether given object is EnhancedParserObject */

@@ -14,3 +17,2 @@ function isEnhancedParserObject(value) {

}
exports.isEnhancedParserObject = isEnhancedParserObject;
/** Checks whether given object is BasicParserObject */

@@ -20,3 +22,2 @@ function isBasicParserObject(value) {

}
exports.isBasicParserObject = isBasicParserObject;
/** Checks whether given object maybe "@typescript-eslint/parser" */

@@ -30,3 +31,2 @@ function maybeTSESLintParserObject(value) {

}
exports.maybeTSESLintParserObject = maybeTSESLintParserObject;
/** Checks whether given object is "@typescript-eslint/parser" */

@@ -47,2 +47,1 @@ function isTSESLintParserObject(value) {

}
exports.isTSESLintParserObject = isTSESLintParserObject;

@@ -6,3 +6,4 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.isTypeScript = exports.normalizeParserOptions = void 0;
exports.normalizeParserOptions = normalizeParserOptions;
exports.isTypeScript = isTypeScript;
const fs_1 = __importDefault(require("fs"));

@@ -21,3 +22,2 @@ const path_1 = __importDefault(require("path"));

}
exports.normalizeParserOptions = normalizeParserOptions;
const TS_PARSER_NAMES = [

@@ -62,2 +62,1 @@ "@typescript-eslint/parser",

}
exports.isTypeScript = isTypeScript;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.getParser = exports.getParserForLang = void 0;
exports.getParserForLang = getParserForLang;
exports.getParser = getParser;
const espree_1 = require("./espree");

@@ -21,3 +22,2 @@ const parser_object_1 = require("./parser-object");

}
exports.getParserForLang = getParserForLang;
/** Get parser */

@@ -35,2 +35,1 @@ function getParser(attrs, parser) {

}
exports.getParser = getParser;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.parseScriptWithoutAnalyzeScope = exports.parseScript = exports.parseScriptInSvelte = void 0;
exports.parseScriptInSvelte = parseScriptInSvelte;
exports.parseScript = parseScript;
exports.parseScriptWithoutAnalyzeScope = parseScriptWithoutAnalyzeScope;
const analyze_scope_1 = require("./analyze-scope");

@@ -30,3 +32,2 @@ const traverse_1 = require("../traverse");

}
exports.parseScriptInSvelte = parseScriptInSvelte;
/**

@@ -43,3 +44,2 @@ * Parse for script

}
exports.parseScript = parseScript;
/**

@@ -58,3 +58,2 @@ * Parse for script without analyze scope

}
exports.parseScriptWithoutAnalyzeScope = parseScriptWithoutAnalyzeScope;
/**

@@ -61,0 +60,0 @@ * Parse for script without analyze scope

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.sortNodes = void 0;
exports.sortNodes = sortNodes;
/**

@@ -18,2 +18,1 @@ * Sort tokens

}
exports.sortNodes = sortNodes;

@@ -6,3 +6,5 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.styleNodeRange = exports.styleNodeLoc = exports.parseStyleContext = void 0;
exports.parseStyleContext = parseStyleContext;
exports.styleNodeLoc = styleNodeLoc;
exports.styleNodeRange = styleNodeRange;
const postcss_1 = __importDefault(require("postcss"));

@@ -50,3 +52,2 @@ const postcss_scss_1 = require("postcss-scss");

}
exports.parseStyleContext = parseStyleContext;
/**

@@ -74,3 +75,2 @@ * Extracts a node location (like that of any ESLint node) from a parsed svelte style node.

}
exports.styleNodeLoc = styleNodeLoc;
/**

@@ -88,3 +88,2 @@ * Extracts a node range (like that of any ESLint node) from a parsed svelte style node.

}
exports.styleNodeRange = styleNodeRange;
/**

@@ -91,0 +90,0 @@ * Fixes PostCSS AST locations to be relative to the whole file instead of relative to the <style> element.

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

/// <reference types="svelte" />
import type * as Compiler from "svelte/compiler";

@@ -3,0 +2,0 @@ import type * as SvAST from "./svelte-ast-types";

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.resolveSvelteParseContextForSvelteScript = exports.resolveSvelteParseContextForSvelte = exports.isEnableRunes = void 0;
exports.isEnableRunes = isEnableRunes;
exports.resolveSvelteParseContextForSvelte = resolveSvelteParseContextForSvelte;
exports.resolveSvelteParseContextForSvelteScript = resolveSvelteParseContextForSvelteScript;
const svelte_version_1 = require("./svelte-version");

@@ -17,3 +19,2 @@ function isEnableRunes(svelteConfig, parserOptions) {

}
exports.isEnableRunes = isEnableRunes;
function resolveSvelteParseContextForSvelte(svelteConfig, parserOptions, svelteAst) {

@@ -34,7 +35,5 @@ const svelteOptions = svelteAst.options;

}
exports.resolveSvelteParseContextForSvelte = resolveSvelteParseContextForSvelte;
function resolveSvelteParseContextForSvelteScript(svelteConfig, parserOptions) {
return resolveSvelteParseContext(svelteConfig, parserOptions);
}
exports.resolveSvelteParseContextForSvelteScript = resolveSvelteParseContextForSvelteScript;
function resolveSvelteParseContext(svelteConfig, parserOptions) {

@@ -41,0 +40,0 @@ return {

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

/// <reference types="svelte" />
import { VERSION as compilerVersion } from "svelte/compiler";

@@ -3,0 +2,0 @@ export { compilerVersion };

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

/// <reference types="svelte" />
import type * as Compiler from "svelte/compiler";

@@ -3,0 +2,0 @@ import type * as SvAST from "./svelte-ast-types";

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.parseTemplate = void 0;
exports.parseTemplate = parseTemplate;
const compiler_1 = require("svelte/compiler");

@@ -30,2 +30,1 @@ const index_1 = require("./converts/index");

}
exports.parseTemplate = parseTemplate;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.analyzeTypeScript = exports.analyzeTypeScriptInSvelte = void 0;
exports.analyzeTypeScriptInSvelte = analyzeTypeScriptInSvelte;
exports.analyzeTypeScript = analyzeTypeScript;
const scope_1 = require("../../../scope");

@@ -33,3 +34,2 @@ const utils_1 = require("../../../utils");

}
exports.analyzeTypeScriptInSvelte = analyzeTypeScriptInSvelte;
/**

@@ -52,3 +52,2 @@ * Analyze TypeScript source code.

}
exports.analyzeTypeScript = analyzeTypeScript;
/**

@@ -55,0 +54,0 @@ * Analyze the store reference names.

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.parseTypeScript = exports.parseTypeScriptInSvelte = void 0;
exports.parseTypeScriptInSvelte = parseTypeScriptInSvelte;
exports.parseTypeScript = parseTypeScript;
const script_1 = require("../script");

@@ -16,3 +17,2 @@ const analyze_1 = require("./analyze");

}
exports.parseTypeScriptInSvelte = parseTypeScriptInSvelte;
/**

@@ -28,2 +28,1 @@ * Parse for TypeScript

}
exports.parseTypeScript = parseTypeScript;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.setParent = void 0;
exports.setParent = setParent;
const __1 = require("../..");

@@ -19,2 +19,1 @@ function setParent(result) {

}
exports.setParent = setParent;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.simplifyScope = exports.addAllReferences = exports.addReference = exports.addVariable = exports.replaceScope = exports.removeScope = exports.removeReference = exports.removeIdentifierReference = exports.getAllReferences = exports.removeIdentifierVariable = exports.getProgramScope = exports.findVariable = exports.getScopeFromNode = exports.removeAllScopeAndVariableAndReference = void 0;
exports.removeAllScopeAndVariableAndReference = removeAllScopeAndVariableAndReference;
exports.getScopeFromNode = getScopeFromNode;
exports.findVariable = findVariable;
exports.getProgramScope = getProgramScope;
exports.removeIdentifierVariable = removeIdentifierVariable;
exports.getAllReferences = getAllReferences;
exports.removeIdentifierReference = removeIdentifierReference;
exports.removeReference = removeReference;
exports.removeScope = removeScope;
exports.replaceScope = replaceScope;
exports.addVariable = addVariable;
exports.addReference = addReference;
exports.addAllReferences = addAllReferences;
exports.simplifyScope = simplifyScope;
const traverse_1 = require("../traverse");

@@ -40,3 +53,2 @@ const utils_1 = require("../utils");

}
exports.removeAllScopeAndVariableAndReference = removeAllScopeAndVariableAndReference;
/**

@@ -64,3 +76,2 @@ * Gets the scope for the current node

}
exports.getScopeFromNode = getScopeFromNode;
/**

@@ -80,3 +91,2 @@ * Find the variable of a given identifier.

}
exports.findVariable = findVariable;
/**

@@ -89,3 +99,2 @@ * Gets the scope for the Program node

}
exports.getProgramScope = getProgramScope;
/** Remove variable */

@@ -156,3 +165,2 @@ function removeIdentifierVariable(node, scope) {

}
exports.removeIdentifierVariable = removeIdentifierVariable;
/** Get all references */

@@ -197,3 +205,2 @@ function* getAllReferences(node, scope) {

}
exports.getAllReferences = getAllReferences;
/** Remove reference */

@@ -226,3 +233,2 @@ function removeIdentifierReference(node, scope) {

}
exports.removeIdentifierReference = removeIdentifierReference;
/** Remove reference */

@@ -262,3 +268,2 @@ function removeReference(reference, baseScope) {

}
exports.removeReference = removeReference;
/** Move reference to through */

@@ -292,3 +297,2 @@ function referencesToThrough(references, baseScope) {

}
exports.removeScope = removeScope;
/** Replace scope */

@@ -317,3 +321,2 @@ function replaceScope(scopeManager, scope, newChildScopes = []) {

}
exports.replaceScope = replaceScope;
/**

@@ -334,3 +337,2 @@ * Add variable to array

}
exports.addVariable = addVariable;
/**

@@ -342,3 +344,2 @@ * Add reference to array

}
exports.addReference = addReference;
/**

@@ -350,3 +351,2 @@ * Add all references to array

}
exports.addAllReferences = addAllReferences;
/**

@@ -372,3 +372,2 @@ * Simplify scope data.

}
exports.simplifyScope = simplifyScope;
/**

@@ -375,0 +374,0 @@ * Simplify variables data.

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

/// <reference types="svelte" />
import type * as Compiler from "svelte/compiler";

@@ -3,0 +2,0 @@ export type SvelteConfig = {

@@ -6,3 +6,3 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.resolveSvelteConfigFromOption = void 0;
exports.resolveSvelteConfigFromOption = resolveSvelteConfigFromOption;
const path_1 = __importDefault(require("path"));

@@ -21,3 +21,2 @@ const fs_1 = __importDefault(require("fs"));

}
exports.resolveSvelteConfigFromOption = resolveSvelteConfigFromOption;
/**

@@ -29,5 +28,8 @@ * Resolves `svelte.config.js`.

function resolveSvelteConfig(filePath) {
const cwd = filePath && fs_1.default.existsSync(filePath)
? path_1.default.dirname(filePath)
: process.cwd();
let cwd = filePath && fs_1.default.existsSync(filePath) ? path_1.default.dirname(filePath) : null;
if (cwd == null) {
if (typeof process === "undefined")
return null;
cwd = process.cwd();
}
const configFilePath = findConfigFilePath(cwd);

@@ -63,5 +65,8 @@ if (!configFilePath)

}
directory = path_1.default.dirname(directory);
const next = path_1.default.dirname(directory);
if (next === directory)
break;
directory = next;
}
return null;
}
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.parseConfig = void 0;
exports.parseConfig = parseConfig;
const traverse_1 = require("../traverse");

@@ -35,3 +35,2 @@ const espree_1 = require("../parser/espree");

}
exports.parseConfig = parseConfig;
function parseAst(ast, scopeManager) {

@@ -38,0 +37,0 @@ const edd = ast.body.find((node) => node.type === "ExportDefaultDeclaration");

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.traverseNodes = exports.getNodes = exports.getKeys = exports.getFallbackKeys = void 0;
exports.getFallbackKeys = getFallbackKeys;
exports.getKeys = getKeys;
exports.getNodes = getNodes;
exports.traverseNodes = traverseNodes;
const visitor_keys_1 = require("./visitor-keys");

@@ -32,3 +35,2 @@ /**

}
exports.getFallbackKeys = getFallbackKeys;
/**

@@ -43,3 +45,2 @@ * Get the keys of the given node to traverse it.

}
exports.getKeys = getKeys;
/**

@@ -62,3 +63,2 @@ * Get the nodes of the given node.

}
exports.getNodes = getNodes;
/**

@@ -96,2 +96,1 @@ * Check whether a given value is a node.

}
exports.traverseNodes = traverseNodes;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.hasTypeInfo = exports.sortedLastIndex = exports.addElementsToSortedArray = exports.addElementToSortedArray = void 0;
exports.addElementToSortedArray = addElementToSortedArray;
exports.addElementsToSortedArray = addElementsToSortedArray;
exports.sortedLastIndex = sortedLastIndex;
exports.hasTypeInfo = hasTypeInfo;
/**

@@ -11,3 +14,2 @@ * Add element to a sorted array

}
exports.addElementToSortedArray = addElementToSortedArray;
/**

@@ -34,3 +36,2 @@ * Add element to a sorted array

}
exports.addElementsToSortedArray = addElementsToSortedArray;
/**

@@ -57,3 +58,2 @@ * Uses a binary search to determine the highest index at which value should be inserted into array in order to maintain its sort order.

}
exports.sortedLastIndex = sortedLastIndex;
function hasTypeInfo(element) {

@@ -83,2 +83,1 @@ var _a;

}
exports.hasTypeInfo = hasTypeInfo;
{
"name": "svelte-eslint-parser",
"version": "0.39.1",
"version": "0.39.2",
"description": "Svelte parser for ESLint",

@@ -55,11 +55,11 @@ "repository": "git+https://github.com/sveltejs/svelte-eslint-parser.git",

"@types/mocha": "^10.0.6",
"@types/node": "^20.14.2",
"@types/node": "^20.14.4",
"@types/semver": "^7.5.8",
"@typescript-eslint/eslint-plugin": "^7.12.0",
"@typescript-eslint/parser": "~7.13.0",
"@typescript-eslint/types": "~7.13.0",
"@typescript-eslint/eslint-plugin": "^7.13.1",
"@typescript-eslint/parser": "~7.13.1",
"@typescript-eslint/types": "~7.13.1",
"benchmark": "^2.1.4",
"chai": "^4.4.1",
"env-cmd": "^10.1.0",
"esbuild": "^0.21.4",
"esbuild": "^0.21.5",
"esbuild-register": "^3.5.0",

@@ -71,7 +71,7 @@ "eslint": "^8.57.0",

"eslint-plugin-jsonc": "^2.16.0",
"eslint-plugin-n": "^17.8.1",
"eslint-plugin-n": "^17.9.0",
"eslint-plugin-node-dependencies": "^0.12.0",
"eslint-plugin-prettier": "^5.1.3",
"eslint-plugin-regexp": "^2.6.0",
"eslint-plugin-svelte": "^2.39.2",
"eslint-plugin-svelte": "^2.40.0",
"eslint-plugin-yml": "^1.14.0",

@@ -84,3 +84,3 @@ "estree-walker": "^3.0.3",

"nyc": "^17.0.0",
"prettier": "~3.3.0",
"prettier": "~3.3.2",
"prettier-plugin-pkg": "^0.18.1",

@@ -90,5 +90,5 @@ "prettier-plugin-svelte": "^3.2.4",

"semver": "^7.6.2",
"svelte": "^5.0.0-next.152",
"svelte2tsx": "^0.7.9",
"typescript": "~5.4.5",
"svelte": "^5.0.0-next.158",
"svelte2tsx": "^0.7.10",
"typescript": "~5.5.0",
"typescript-eslint-parser-for-extra-files": "^0.7.0"

@@ -95,0 +95,0 @@ },

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc