Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

svelte-eslint-parser

Package Overview
Dependencies
Maintainers
1
Versions
113
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.4.5 to 0.4.6

4

lib/context/index.js

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

}
const parserName = resolve_parser_1.getParserName(this.sourceCode.scripts.attrs, (_a = this.parserOptions) === null || _a === void 0 ? void 0 : _a.parser);
const parserName = (0, resolve_parser_1.getParserName)(this.sourceCode.scripts.attrs, (_a = this.parserOptions) === null || _a === void 0 ? void 0 : _a.parser);
if (parserName === "@typescript-eslint/parser") {

@@ -190,3 +190,3 @@ return (this.state.isTypeScript = true);

const codeRange = [startTagEnd, endTagStart];
const attrRe = /(?<key>[^\s=]+)(?:=(?:"(?<val1>[^"]*)"|'(?<val2>[^"]*)'|(?<val3>[^\s=]+)))?/giu;
const attrRe = /(?<key>[^\s=]+)(?:=(?:"(?<val1>[^"]*)"|'(?<val2>[^"]*)'|(?<val3>[^\s=]+)))?/gu;
const attrs = {};

@@ -193,0 +193,0 @@ let attrRes;

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

if (node.leadingComments) {
start = common_1.getWithLoc(node.leadingComments[0]).start;
start = (0, common_1.getWithLoc)(node.leadingComments[0]).start;
}
if (node.trailingComments) {
end = common_1.getWithLoc(node.trailingComments[node.trailingComments.length - 1]).end;
end = (0, common_1.getWithLoc)(node.trailingComments[node.trailingComments.length - 1]).end;
}

@@ -25,3 +25,3 @@ if (start != null && end != null) {

}
const loc = common_1.getWithLoc(node);
const loc = (0, common_1.getWithLoc)(node);
return [start !== null && start !== void 0 ? start : loc.start, end !== null && end !== void 0 ? end : loc.end];

@@ -317,3 +317,3 @@ }

const removeStatements = [];
traverse_1.traverseNodes(result.ast, {
(0, traverse_1.traverseNodes)(result.ast, {
visitorKeys: result.visitorKeys,

@@ -442,3 +442,3 @@ enterNode: (node) => {

const traversed = new Set();
traverse_1.traverseNodes(node, {
(0, traverse_1.traverseNodes)(node, {
visitorKeys,

@@ -445,0 +445,0 @@ enterNode: (n) => {

"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.analyzePropsScope = exports.analyzeStoreScope = exports.analyzeReactiveScope = exports.analyzeScope = void 0;
const eslint_scope_1 = require("eslint-scope");
const eslint_scope_2 = __importDefault(require("eslint-scope"));
const traverse_1 = require("../traverse");

@@ -24,3 +20,3 @@ /**

};
return eslint_scope_2.default.analyze(root, {
return (0, eslint_scope_1.analyze)(root, {
ignoreEval: true,

@@ -27,0 +23,0 @@ nodejsScope: false,

@@ -96,7 +96,7 @@ "use strict";

}
attribute.value.push(text_1.convertTextToLiteral(v, attribute, ctx));
attribute.value.push((0, text_1.convertTextToLiteral)(v, attribute, ctx));
continue;
}
if (v.type === "MustacheTag") {
const mustache = mustache_1.convertMustacheTag(v, attribute, ctx);
const mustache = (0, mustache_1.convertMustacheTag)(v, attribute, ctx);
attribute.value.push(mustache);

@@ -215,7 +215,7 @@ continue;

let nextStart = nameRange.end + 1;
let nextEnd = common_1.indexOf(ctx.code, (c) => c === "=" || c === ">" || c === "/" || c === "|" || !c.trim(), nextStart);
let nextEnd = (0, common_1.indexOf)(ctx.code, (c) => c === "=" || c === ">" || c === "/" || c === "|" || !c.trim(), nextStart);
ctx.addToken("HTMLIdentifier", { start: nextStart, end: nextEnd });
while (ctx.code[nextEnd] === "|") {
nextStart = nextEnd + 1;
nextEnd = common_1.indexOf(ctx.code, (c) => c === "=" ||
nextEnd = (0, common_1.indexOf)(ctx.code, (c) => c === "=" ||
c === ">" ||

@@ -234,8 +234,8 @@ c === "/" ||

node.expression.name === node.name &&
common_1.getWithLoc(node.expression).start === nameRange.start;
(0, common_1.getWithLoc)(node.expression).start === nameRange.start;
if (isShorthandExpression &&
common_1.getWithLoc(node.expression).end !== nameRange.end) {
(0, common_1.getWithLoc)(node.expression).end !== nameRange.end) {
// The identifier location may be incorrect in some edge cases.
// e.g. bind:value=""
common_1.getWithLoc(node.expression).end = nameRange.end;
(0, common_1.getWithLoc)(node.expression).end = nameRange.end;
}

@@ -242,0 +242,0 @@ processExpression(node.expression, isShorthandExpression).push((es) => {

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

});
ifBlock.children.push(...element_1.convertChildren(node, ifBlock, ctx));
ifBlock.children.push(...(0, element_1.convertChildren)(node, ifBlock, ctx));
ctx.scriptLet.closeScope();

@@ -52,3 +52,3 @@ if (node.elseif) {

ctx.scriptLet.nestBlock(elseBlock);
elseBlock.children.push(...element_1.convertChildren(node.else, elseBlock, ctx));
elseBlock.children.push(...(0, element_1.convertChildren)(node.else, elseBlock, ctx));
ctx.scriptLet.closeScope();

@@ -66,3 +66,3 @@ extractMustacheBlockTokens(elseBlock, ctx, { startOnly: true });

if (node.index) {
const start = ctx.code.indexOf(node.index, common_1.getWithLoc(node.context).end);
const start = ctx.code.indexOf(node.index, (0, common_1.getWithLoc)(node.context).end);
indexRange = {

@@ -78,3 +78,3 @@ start,

});
const asStart = ctx.code.indexOf("as", common_1.getWithLoc(node.expression).end);
const asStart = ctx.code.indexOf("as", (0, common_1.getWithLoc)(node.expression).end);
ctx.addToken("Keyword", {

@@ -89,3 +89,3 @@ start: asStart,

}
eachBlock.children.push(...element_1.convertChildren(node, eachBlock, ctx));
eachBlock.children.push(...(0, element_1.convertChildren)(node, eachBlock, ctx));
ctx.scriptLet.closeScope();

@@ -103,3 +103,3 @@ extractMustacheBlockTokens(eachBlock, ctx);

ctx.scriptLet.nestBlock(elseBlock);
elseBlock.children.push(...element_1.convertChildren(node.else, elseBlock, ctx));
elseBlock.children.push(...(0, element_1.convertChildren)(node.else, elseBlock, ctx));
ctx.scriptLet.closeScope();

@@ -119,3 +119,3 @@ extractMustacheBlockTokens(elseBlock, ctx, { startOnly: true });

ctx.scriptLet.nestBlock(pendingBlock);
pendingBlock.children.push(...element_1.convertChildren(node.pending, pendingBlock, ctx));
pendingBlock.children.push(...(0, element_1.convertChildren)(node.pending, pendingBlock, ctx));
awaitBlock.pending = pendingBlock;

@@ -140,3 +140,3 @@ ctx.scriptLet.closeScope();

}
thenBlock.children.push(...element_1.convertChildren(node.then, thenBlock, ctx));
thenBlock.children.push(...(0, element_1.convertChildren)(node.then, thenBlock, ctx));
if (awaitBlock.pending) {

@@ -146,3 +146,3 @@ extractMustacheBlockTokens(thenBlock, ctx, { startOnly: true });

else {
const thenIndex = ctx.code.indexOf("then", common_1.getWithLoc(node.expression).end);
const thenIndex = ctx.code.indexOf("then", (0, common_1.getWithLoc)(node.expression).end);
ctx.addToken("MustacheKeyword", {

@@ -172,3 +172,3 @@ start: thenIndex,

}
catchBlock.children.push(...element_1.convertChildren(node.catch, catchBlock, ctx));
catchBlock.children.push(...(0, element_1.convertChildren)(node.catch, catchBlock, ctx));
if (awaitBlock.pending || awaitBlock.then) {

@@ -178,3 +178,3 @@ extractMustacheBlockTokens(catchBlock, ctx, { startOnly: true });

else {
const catchIndex = ctx.code.indexOf("catch", common_1.getWithLoc(node.expression).end);
const catchIndex = ctx.code.indexOf("catch", (0, common_1.getWithLoc)(node.expression).end);
ctx.addToken("MustacheKeyword", {

@@ -199,3 +199,3 @@ start: catchIndex,

ctx.scriptLet.nestBlock(keyBlock);
keyBlock.children.push(...element_1.convertChildren(node, keyBlock, ctx));
keyBlock.children.push(...(0, element_1.convertChildren)(node, keyBlock, ctx));
ctx.scriptLet.closeScope();

@@ -208,4 +208,4 @@ extractMustacheBlockTokens(keyBlock, ctx);

function extractMustacheBlockTokens(node, ctx, option) {
const startSectionNameStart = common_1.indexOf(ctx.code, (c) => Boolean(c.trim()), node.range[0] + 1);
const startSectionNameEnd = common_1.indexOf(ctx.code, (c) => c === "}" || !c.trim(), startSectionNameStart + 1);
const startSectionNameStart = (0, common_1.indexOf)(ctx.code, (c) => Boolean(c.trim()), node.range[0] + 1);
const startSectionNameEnd = (0, common_1.indexOf)(ctx.code, (c) => c === "}" || !c.trim(), startSectionNameStart + 1);
ctx.addToken("MustacheKeyword", {

@@ -218,4 +218,4 @@ start: startSectionNameStart,

}
const endSectionNameEnd = common_1.lastIndexOf(ctx.code, (c) => Boolean(c.trim()), node.range[1] - 2) + 1;
const endSectionNameStart = common_1.lastIndexOf(ctx.code, (c) => c === "{" || c === "/" || !c.trim(), endSectionNameEnd - 1);
const endSectionNameEnd = (0, common_1.lastIndexOf)(ctx.code, (c) => Boolean(c.trim()), node.range[1] - 2) + 1;
const endSectionNameStart = (0, common_1.lastIndexOf)(ctx.code, (c) => c === "{" || c === "/" || !c.trim(), endSectionNameEnd - 1);
ctx.addToken("MustacheKeyword", {

@@ -222,0 +222,0 @@ start: endSectionNameStart,

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

if (child.type === "Text") {
yield text_1.convertText(child, parent, ctx);
yield (0, text_1.convertText)(child, parent, ctx);
continue;

@@ -42,7 +42,7 @@ }

if (child.type === "MustacheTag") {
yield mustache_1.convertMustacheTag(child, parent, ctx);
yield (0, mustache_1.convertMustacheTag)(child, parent, ctx);
continue;
}
if (child.type === "RawMustacheTag") {
yield mustache_1.convertRawMustacheTag(child, parent, ctx);
yield (0, mustache_1.convertRawMustacheTag)(child, parent, ctx);
continue;

@@ -52,3 +52,3 @@ }

// {#if expr} {/if}
yield block_1.convertIfBlock(child, parent, ctx);
yield (0, block_1.convertIfBlock)(child, parent, ctx);
continue;

@@ -58,3 +58,3 @@ }

// {#each expr as item, index (key)} {/each}
yield block_1.convertEachBlock(child, parent, ctx);
yield (0, block_1.convertEachBlock)(child, parent, ctx);
continue;

@@ -64,3 +64,3 @@ }

// {#await promise} {:then number} {:catch error} {/await}
yield block_1.convertAwaitBlock(child, parent, ctx);
yield (0, block_1.convertAwaitBlock)(child, parent, ctx);
continue;

@@ -70,3 +70,3 @@ }

// {#key expression}...{/key}
yield block_1.convertKeyBlock(child, parent, ctx);
yield (0, block_1.convertKeyBlock)(child, parent, ctx);
continue;

@@ -99,3 +99,3 @@ }

if (child.type === "DebugTag") {
yield mustache_1.convertDebugTag(child, parent, ctx);
yield (0, mustache_1.convertDebugTag)(child, parent, ctx);
continue;

@@ -133,3 +133,3 @@ }

ctx.letDirCollections.beginExtract();
element.startTag.attributes.push(...attr_1.convertAttributes(node.attributes, element.startTag, ctx));
element.startTag.attributes.push(...(0, attr_1.convertAttributes)(node.attributes, element.startTag, ctx));
const lets = ctx.letDirCollections.extract();

@@ -182,3 +182,3 @@ if (lets.isEmpty()) {

ctx.letDirCollections.beginExtract();
element.startTag.attributes.push(...attr_1.convertAttributes(node.attributes, element.startTag, ctx));
element.startTag.attributes.push(...(0, attr_1.convertAttributes)(node.attributes, element.startTag, ctx));
const lets = ctx.letDirCollections.extract();

@@ -196,6 +196,6 @@ if (lets.isEmpty()) {

node.name === "svelte:component") {
const eqIndex = ctx.code.lastIndexOf("=", common_1.getWithLoc(node.expression).start);
const eqIndex = ctx.code.lastIndexOf("=", (0, common_1.getWithLoc)(node.expression).start);
const startIndex = ctx.code.lastIndexOf("this", eqIndex);
const closeIndex = ctx.code.indexOf("}", common_1.getWithLoc(node.expression).end);
const endIndex = common_1.indexOf(ctx.code, (c) => c === ">" || !c.trim(), closeIndex);
const closeIndex = ctx.code.indexOf("}", (0, common_1.getWithLoc)(node.expression).end);
const endIndex = (0, common_1.indexOf)(ctx.code, (c) => c === ">" || !c.trim(), closeIndex);
const thisAttr = Object.assign({ type: "SvelteSpecialDirective", kind: "this", key: null, expression: null, parent: element.startTag }, ctx.getConvertLocation({ start: startIndex, end: endIndex }));

@@ -240,3 +240,3 @@ thisAttr.key = Object.assign({ type: "SvelteSpecialDirectiveKey", parent: thisAttr }, ctx.getConvertLocation({ start: startIndex, end: eqIndex }));

ctx.letDirCollections.beginExtract();
element.startTag.attributes.push(...attr_1.convertAttributes(node.attributes, element.startTag, ctx));
element.startTag.attributes.push(...(0, attr_1.convertAttributes)(node.attributes, element.startTag, ctx));
const lets = ctx.letDirCollections.extract();

@@ -324,3 +324,3 @@ if (lets.isEmpty()) {

var _a, _b;
const startTagNameEnd = common_1.indexOf(ctx.code, (c) => c === "/" || c === ">" || !c.trim(), element.range[0] + 1);
const startTagNameEnd = (0, common_1.indexOf)(ctx.code, (c) => c === "/" || c === ">" || !c.trim(), element.range[0] + 1);
const openTokenRange = {

@@ -349,3 +349,3 @@ start: element.range[0] + 1,

const endTagNameStart = endTagOpen + 2;
const endTagNameEnd = common_1.indexOf(ctx.code, (c) => c === ">" || !c.trim(), endTagNameStart);
const endTagNameEnd = (0, common_1.indexOf)(ctx.code, (c) => c === ">" || !c.trim(), endTagNameStart);
const endTagClose = ctx.code.indexOf(">", endTagNameEnd);

@@ -352,0 +352,0 @@ element.endTag = Object.assign({ type: "SvelteEndTag", parent: element }, ctx.getConvertLocation({ start: endTagOpen, end: endTagClose + 1 }));

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

const fragment = svelteAst.html;
body.push(...element_1.convertChildren(fragment, ast, ctx));
body.push(...(0, element_1.convertChildren)(fragment, ast, ctx));
}

@@ -22,3 +22,3 @@ if (svelteAst.instance) {

extractAttributes(script, ctx);
element_1.extractElementTags(script, ctx, {
(0, element_1.extractElementTags)(script, ctx, {
buildNameNode: (openTokenRange) => {

@@ -36,3 +36,3 @@ ctx.addToken("HTMLIdentifier", openTokenRange);

extractAttributes(script, ctx);
element_1.extractElementTags(script, ctx, {
(0, element_1.extractElementTags)(script, ctx, {
buildNameNode: (openTokenRange) => {

@@ -49,3 +49,3 @@ ctx.addToken("HTMLIdentifier", openTokenRange);

extractAttributes(style, ctx);
element_1.extractElementTags(style, ctx, {
(0, element_1.extractElementTags)(style, ctx, {
buildNameNode: (openTokenRange) => {

@@ -75,9 +75,26 @@ ctx.addToken("HTMLIdentifier", openTokenRange);

const script = element.type === "SvelteScriptElement";
const code = " ".repeat(element.range[0]) +
ctx.sourceCode.template
.slice(...element.range)
.replace(script
? /<script(\s[\s\S]*?)?>([\s\S]*?)<\/script>/giu
: /<style(\s[\s\S]*?)?>([\s\S]*?)<\/style>/giu, (_tag, attributes, context) => `${script ? "<div " : "<div "}${attributes || ""}>${" ".repeat(context.length)}</div>`);
const svelteAst = compiler_1.parse(code);
let code = " ".repeat(element.range[0]);
const elementCode = ctx.sourceCode.template.slice(...element.range);
const startRegex = script
? /<script(\s[\s\S]*?)?>/giu
: /<style(\s[\s\S]*?)?>/giu;
const endTag = script ? "</script>" : "</style>";
let re;
let index = 0;
while ((re = startRegex.exec(elementCode))) {
const [, attributes] = re;
const endTagIndex = elementCode.indexOf(endTag, startRegex.lastIndex);
if (endTagIndex >= 0) {
const contextLength = endTagIndex - startRegex.lastIndex;
code += elementCode.slice(index, re.index);
code += `${script ? "<div " : "<div "}${attributes || ""}>`;
code += `${" ".repeat(contextLength)}</div>`;
startRegex.lastIndex = index = endTagIndex + endTag.length;
}
else {
break;
}
}
code += elementCode.slice(index);
const svelteAst = (0, compiler_1.parse)(code);
const fakeElement = svelteAst.html.children.find((c) => c.type === "Element");

@@ -98,3 +115,3 @@ element.startTag = {

};
element.startTag.attributes.push(...attr_1.convertAttributes(fakeElement.attributes, element.startTag, ctx));
element.startTag.attributes.push(...(0, attr_1.convertAttributes)(fakeElement.attributes, element.startTag, ctx));
}

@@ -22,11 +22,12 @@ "use strict";

const ctx = new context_1.Context(code, parserOptions);
const resultTemplate = template_1.parseTemplate(ctx.sourceCode.template, ctx, parserOptions);
const resultScript = script_1.parseScript(ctx.sourceCode.scripts, parserOptions);
const resultTemplate = (0, template_1.parseTemplate)(ctx.sourceCode.template, ctx, parserOptions);
const resultScript = (0, script_1.parseScript)(ctx.sourceCode.scripts, parserOptions);
ctx.scriptLet.restore(resultScript);
ctx.tokens.push(...resultScript.ast.tokens);
ctx.comments.push(...resultScript.ast.comments);
sort_1.sort(ctx.comments);
sort_1.sort(ctx.tokens);
(0, sort_1.sort)(ctx.comments);
(0, sort_1.sort)(ctx.tokens);
extractTokens(ctx);
analyze_scope_1.analyzeStoreScope(resultScript.scopeManager);
(0, analyze_scope_1.analyzeStoreScope)(resultScript.scopeManager);
(0, analyze_scope_1.analyzeReactiveScope)(resultScript.scopeManager);
// Add $$xxx variable

@@ -73,3 +74,3 @@ for (const $$name of ["$$slots", "$$props", "$$restProps"]) {

attr.value[0].value === "module")) {
analyze_scope_1.analyzePropsScope(body, resultScript.scopeManager);
(0, analyze_scope_1.analyzePropsScope)(body, resultScript.scopeManager);
}

@@ -93,3 +94,3 @@ }

function extractTokens(ctx) {
const useRanges = sort_1.sort([...ctx.tokens, ...ctx.comments]).map((t) => t.range);
const useRanges = (0, sort_1.sort)([...ctx.tokens, ...ctx.comments]).map((t) => t.range);
let range = useRanges.shift();

@@ -117,4 +118,4 @@ for (let index = 0; index < ctx.sourceCode.template.length; index++) {

}
sort_1.sort(ctx.comments);
sort_1.sort(ctx.tokens);
(0, sort_1.sort)(ctx.comments);
(0, sort_1.sort)(ctx.tokens);
/**

@@ -121,0 +122,0 @@ * Checks if the given char is punctuator

@@ -28,4 +28,4 @@ "use strict";

}
return espree_1.getEspree();
return (0, espree_1.getEspree)();
}
exports.getParser = getParser;

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

if (!result.scopeManager) {
const scopeManager = analyze_scope_1.analyzeScope(result.ast, parserOptions);
const scopeManager = (0, analyze_scope_1.analyzeScope)(result.ast, parserOptions);
result.scopeManager = scopeManager;
}
traverse_1.traverseNodes(result.ast, {
(0, traverse_1.traverseNodes)(result.ast, {
visitorKeys: result.visitorKeys,

@@ -33,3 +33,2 @@ enterNode(node, parent) {

});
analyze_scope_1.analyzeReactiveScope(result.scopeManager);
return result;

@@ -43,3 +42,3 @@ }

var _a, _b, _c;
const parser = resolve_parser_1.getParser(attrs, options.parser);
const parser = (0, resolve_parser_1.getParser)(attrs, options.parser);
const result = (_b = (_a = parser.parseForESLint) === null || _a === void 0 ? void 0 : _a.call(parser, vcode, options)) !== null && _b !== void 0 ? _b : (_c = parser.parse) === null || _c === void 0 ? void 0 : _c.call(parser, vcode, options);

@@ -46,0 +45,0 @@ if ("ast" in result && result.ast != null) {

@@ -13,7 +13,7 @@ "use strict";

try {
const svelteAst = compiler_1.parse(code, {
const svelteAst = (0, compiler_1.parse)(code, {
filename: parserOptions.filePath,
});
const ast = index_1.convertSvelteRoot(svelteAst, ctx);
sort_1.sort(ast.body);
const ast = (0, index_1.convertSvelteRoot)(svelteAst, ctx);
(0, sort_1.sort)(ast.body);
return {

@@ -20,0 +20,0 @@ ast,

@@ -26,3 +26,3 @@ import type { VisitorKeys } from "eslint-visitor-keys";

}
export declare function traverseNodes(node: SvelteNode, visitor: Visitor<SvelteNode>): void;
export declare function traverseNodes(node: SvelteNode, visitor: Visitor<SvelteNode | ESTree.Node>): void;
export declare function traverseNodes(node: ESTree.Node, visitor: Visitor<ESTree.Node>): void;

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

};
exports.KEYS = eslint_visitor_keys_1.unionWith(svelteKeys);
exports.KEYS = (0, eslint_visitor_keys_1.unionWith)(svelteKeys);
{
"name": "svelte-eslint-parser",
"version": "0.4.5",
"version": "0.4.6",
"description": "Svelte parser for ESLint",

@@ -39,3 +39,3 @@ "main": "lib/index.js",

"dependencies": {
"eslint-scope": "^5.1.1",
"eslint-scope": "^6.0.0",
"eslint-visitor-keys": "^3.0.0",

@@ -48,8 +48,8 @@ "espree": "^8.0.0"

"devDependencies": {
"@ota-meshi/eslint-plugin": "^0.7.0",
"@ota-meshi/eslint-plugin-svelte": "^0.8.1",
"@ota-meshi/eslint-plugin": "^0.8.0",
"@ota-meshi/eslint-plugin-svelte": "^0.10.0",
"@types/eslint": "^7.2.0",
"@types/eslint-scope": "^3.7.0",
"@types/eslint-visitor-keys": "^1.0.0",
"@types/mocha": "^8.0.0",
"@types/mocha": "^9.0.0",
"@types/node": "^14.0.13",

@@ -65,4 +65,5 @@ "@typescript-eslint/eslint-plugin": "^4.9.1",

"eslint-plugin-node": "^11.1.0",
"eslint-plugin-prettier": "^3.2.0",
"eslint-plugin-regexp": "^0.13.0",
"eslint-plugin-node-dependencies": "^0.5.0",
"eslint-plugin-prettier": "^4.0.0",
"eslint-plugin-regexp": "^1.0.0",
"eslint-plugin-svelte3": "^3.2.0",

@@ -69,0 +70,0 @@ "eslint-plugin-vue": "^7.2.0",

@@ -58,3 +58,3 @@ # svelte-eslint-parser

[svelte-eslint-parser]: https://www.npmjs.com/package/svelte-eslint-parser
[svelte-eslint-parser]: https://github.com/ota-meshi/svelte-eslint-parser

@@ -125,2 +125,28 @@ ## 💿 Installation

For example, if you are using the `"@typescript-eslint/parser"`, and if you want to use TypeScript in `<script>` of `.svelte`, you need to add more `parserOptions` configuration.
```js
module.exports = {
// ...
parser: "@typescript-eslint/parser",
parserOptions: {
// ...
project: "path/to/your/tsconfig.json",
extraFileExtensions: [".svelte"], // This is a required setting in `@typescript-eslint/parser` v4.24.0.
},
overrides: [
{
files: ["*.svelte"],
parser: "svelte-eslint-parser",
// Parse the `<script>` in `.svelte` as TypeScript by adding the following configuration.
parserOptions: {
parser: "@typescript-eslint/parser",
},
},
// ...
],
// ...
}
```
#### Multiple parsers

@@ -127,0 +153,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