svelte-eslint-parser
Advanced tools
Comparing version 0.38.0 to 0.39.0
import * as AST from "./ast"; | ||
import { traverseNodes } from "./traverse"; | ||
import { ParseError } from "./errors"; | ||
export { parseForESLint, StyleContext, StyleContextNoStyleElement, StyleContextParseError, StyleContextSuccess, StyleContextUnknownLang, } from "./parser"; | ||
export { parseForESLint, type StyleContext, type StyleContextNoStyleElement, type StyleContextParseError, type StyleContextSuccess, type StyleContextUnknownLang, } from "./parser"; | ||
export * as meta from "./meta"; | ||
export { name } from "./meta"; | ||
export type { SvelteConfig } from "./svelte-config"; | ||
export { AST, ParseError }; | ||
export declare const VisitorKeys: import("eslint").SourceCode.VisitorKeys; | ||
export { traverseNodes }; |
export declare const name = "svelte-eslint-parser"; | ||
export declare const version = "0.38.0"; | ||
export declare const version = "0.39.0"; |
@@ -8,2 +8,2 @@ "use strict"; | ||
exports.name = "svelte-eslint-parser"; | ||
exports.version = "0.38.0"; | ||
exports.version = "0.39.0"; |
@@ -5,2 +5,3 @@ import type ESTree from "estree"; | ||
import type { NormalizedParserOptions } from "./parser-options"; | ||
import type { SvelteParseContext } from "./svelte-parse-context"; | ||
/** | ||
@@ -17,4 +18,4 @@ * Analyze scope | ||
/** Transform props exports */ | ||
export declare function analyzePropsScope(body: SvelteScriptElement, scopeManager: ScopeManager): void; | ||
export declare function analyzePropsScope(body: SvelteScriptElement, scopeManager: ScopeManager, svelteParseContext: SvelteParseContext): void; | ||
/** Analyze snippets in component scope */ | ||
export declare function analyzeSnippetsScope(snippets: SvelteSnippetBlock[], scopeManager: ScopeManager): void; |
@@ -120,3 +120,3 @@ "use strict"; | ||
/** Transform props exports */ | ||
function analyzePropsScope(body, scopeManager) { | ||
function analyzePropsScope(body, scopeManager, svelteParseContext) { | ||
var _a; | ||
@@ -148,15 +148,17 @@ const moduleScope = scopeManager.scopes.find((scope) => scope.type === "module"); | ||
else if (node.type === "VariableDeclaration") { | ||
// Process for Svelte v5 Runes props. e.g. `let { x = $bindable() } = $props()`; | ||
for (const decl of node.declarations) { | ||
if (((_a = decl.init) === null || _a === void 0 ? void 0 : _a.type) === "CallExpression" && | ||
decl.init.callee.type === "Identifier" && | ||
decl.init.callee.name === "$props" && | ||
decl.id.type === "ObjectPattern") { | ||
for (const pattern of extractPattern(decl.id)) { | ||
if (pattern.type === "AssignmentPattern" && | ||
pattern.left.type === "Identifier" && | ||
pattern.right.type === "CallExpression" && | ||
pattern.right.callee.type === "Identifier" && | ||
pattern.right.callee.name === "$bindable") { | ||
addPropReference(pattern.left, moduleScope); | ||
if (svelteParseContext.runes) { | ||
// Process for Svelte v5 Runes props. e.g. `let { x = $bindable() } = $props()`; | ||
for (const decl of node.declarations) { | ||
if (((_a = decl.init) === null || _a === void 0 ? void 0 : _a.type) === "CallExpression" && | ||
decl.init.callee.type === "Identifier" && | ||
decl.init.callee.name === "$props" && | ||
decl.id.type === "ObjectPattern") { | ||
for (const pattern of extractPattern(decl.id)) { | ||
if (pattern.type === "AssignmentPattern" && | ||
pattern.left.type === "Identifier" && | ||
pattern.right.type === "CallExpression" && | ||
pattern.right.callee.type === "Identifier" && | ||
pattern.right.callee.name === "$bindable") { | ||
addPropReference(pattern.left, moduleScope); | ||
} | ||
} | ||
@@ -163,0 +165,0 @@ } |
@@ -0,3 +1,7 @@ | ||
import type { SvelteParseContext } from "./svelte-parse-context"; | ||
declare const globalsForSvelte: readonly ["$$slots", "$$props", "$$restProps"]; | ||
export declare const globalsForRunes: readonly ["$state", "$derived", "$effect", "$props", "$bindable", "$inspect", "$host"]; | ||
export declare const globals: readonly ["$$slots", "$$props", "$$restProps"] | ("$props" | "$bindable" | "$$slots" | "$$props" | "$$restProps" | "$state" | "$derived" | "$effect" | "$inspect" | "$host")[]; | ||
export declare const globalsForSvelteScript: never[] | readonly ["$state", "$derived", "$effect", "$props", "$bindable", "$inspect", "$host"]; | ||
type Global = (typeof globalsForSvelte)[number] | (typeof globalsForRunes)[number]; | ||
export declare function getGlobalsForSvelte(svelteParseContext: SvelteParseContext): readonly Global[]; | ||
export declare function getGlobalsForSvelteScript(svelteParseContext: SvelteParseContext): readonly Global[]; | ||
export {}; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.globalsForSvelteScript = exports.globals = exports.globalsForRunes = void 0; | ||
const svelte_version_1 = require("./svelte-version"); | ||
const globalsForSvelte4 = ["$$slots", "$$props", "$$restProps"]; | ||
exports.getGlobalsForSvelteScript = exports.getGlobalsForSvelte = exports.globalsForRunes = void 0; | ||
const globalsForSvelte = ["$$slots", "$$props", "$$restProps"]; | ||
exports.globalsForRunes = [ | ||
@@ -15,8 +14,15 @@ "$state", | ||
]; | ||
const globalsForSvelte5 = [...globalsForSvelte4, ...exports.globalsForRunes]; | ||
exports.globals = svelte_version_1.svelteVersion.gte(5) | ||
? globalsForSvelte5 | ||
: globalsForSvelte4; | ||
exports.globalsForSvelteScript = svelte_version_1.svelteVersion.gte(5) | ||
? exports.globalsForRunes | ||
: []; | ||
function getGlobalsForSvelte(svelteParseContext) { | ||
if (svelteParseContext.runes) { | ||
return [...globalsForSvelte, ...exports.globalsForRunes]; | ||
} | ||
return globalsForSvelte; | ||
} | ||
exports.getGlobalsForSvelte = getGlobalsForSvelte; | ||
function getGlobalsForSvelteScript(svelteParseContext) { | ||
if (svelteParseContext.runes) { | ||
return exports.globalsForRunes; | ||
} | ||
return []; | ||
} | ||
exports.getGlobalsForSvelteScript = getGlobalsForSvelteScript; |
@@ -8,2 +8,3 @@ /// <reference types="svelte" /> | ||
import { type StyleContext, type StyleContextNoStyleElement, type StyleContextParseError, type StyleContextSuccess, type StyleContextUnknownLang } from "./style-context"; | ||
import { type SvelteParseContext } from "./svelte-parse-context"; | ||
export { StyleContext, StyleContextNoStyleElement, StyleContextParseError, StyleContextSuccess, StyleContextUnknownLang, }; | ||
@@ -33,5 +34,7 @@ export interface ESLintProgram extends Program { | ||
getStyleContext: () => StyleContext; | ||
svelteParseContext: SvelteParseContext; | ||
} | { | ||
isSvelte: false; | ||
isSvelteScript: true; | ||
svelteParseContext: SvelteParseContext; | ||
}); | ||
@@ -38,0 +41,0 @@ visitorKeys: { |
@@ -16,5 +16,6 @@ "use strict"; | ||
const globals_1 = require("./globals"); | ||
const svelte_version_1 = require("./svelte-version"); | ||
const parser_options_1 = require("./parser-options"); | ||
const compat_1 = require("./compat"); | ||
const svelte_parse_context_1 = require("./svelte-parse-context"); | ||
const svelte_config_1 = require("../svelte-config"); | ||
/** | ||
@@ -24,4 +25,5 @@ * Parse source code | ||
function parseForESLint(code, options) { | ||
const svelteConfig = (0, svelte_config_1.resolveSvelteConfigFromOption)(options); | ||
const parserOptions = (0, parser_options_1.normalizeParserOptions)(options); | ||
if (svelte_version_1.svelteVersion.hasRunes && | ||
if ((0, svelte_parse_context_1.isEnableRunes)(svelteConfig, parserOptions) && | ||
parserOptions.filePath && | ||
@@ -33,6 +35,7 @@ !parserOptions.filePath.endsWith(".svelte") && | ||
if (!trimmed.startsWith("<") && !trimmed.endsWith(">")) { | ||
return parseAsScript(code, parserOptions); | ||
const svelteParseContext = (0, svelte_parse_context_1.resolveSvelteParseContextForSvelteScript)(svelteConfig, parserOptions); | ||
return parseAsScript(code, parserOptions, svelteParseContext); | ||
} | ||
} | ||
return parseAsSvelte(code, parserOptions); | ||
return parseAsSvelte(code, svelteConfig, parserOptions); | ||
} | ||
@@ -43,8 +46,9 @@ exports.parseForESLint = parseForESLint; | ||
*/ | ||
function parseAsSvelte(code, parserOptions) { | ||
function parseAsSvelte(code, svelteConfig, parserOptions) { | ||
const ctx = new context_1.Context(code, parserOptions); | ||
const resultTemplate = (0, template_1.parseTemplate)(ctx.sourceCode.template, ctx, parserOptions); | ||
const svelteParseContext = (0, svelte_parse_context_1.resolveSvelteParseContextForSvelte)(svelteConfig, parserOptions, resultTemplate.svelteAst); | ||
const scripts = ctx.sourceCode.scripts; | ||
const resultScript = ctx.isTypeScript() | ||
? (0, typescript_1.parseTypeScriptInSvelte)(scripts.getCurrentVirtualCodeInfo(), scripts.attrs, parserOptions, { slots: ctx.slots }) | ||
? (0, typescript_1.parseTypeScriptInSvelte)(scripts.getCurrentVirtualCodeInfo(), scripts.attrs, parserOptions, { slots: ctx.slots, svelteParseContext }) | ||
: (0, script_1.parseScriptInSvelte)(scripts.getCurrentVirtualCode(), scripts.attrs, parserOptions); | ||
@@ -62,3 +66,3 @@ ctx.scriptLet.restore(resultScript); | ||
// Add $$xxx variable | ||
addGlobalVariables(resultScript.scopeManager, globals_1.globals); | ||
addGlobalVariables(resultScript.scopeManager, (0, globals_1.getGlobalsForSvelte)(svelteParseContext)); | ||
const ast = resultTemplate.ast; | ||
@@ -85,3 +89,3 @@ const statements = [...resultScript.ast.body]; | ||
attr.value[0].value === "module")) { | ||
(0, analyze_scope_1.analyzePropsScope)(body, resultScript.scopeManager); | ||
(0, analyze_scope_1.analyzePropsScope)(body, resultScript.scopeManager, svelteParseContext); | ||
} | ||
@@ -109,2 +113,3 @@ } | ||
styleNodeRange: style_context_1.styleNodeRange, | ||
svelteParseContext, | ||
}); | ||
@@ -117,13 +122,14 @@ resultScript.visitorKeys = Object.assign({}, visitor_keys_1.KEYS, resultScript.visitorKeys); | ||
*/ | ||
function parseAsScript(code, parserOptions) { | ||
function parseAsScript(code, parserOptions, svelteParseContext) { | ||
var _a; | ||
const lang = (_a = parserOptions.filePath) === null || _a === void 0 ? void 0 : _a.split(".").pop(); | ||
const resultScript = (0, parser_options_1.isTypeScript)(parserOptions, lang) | ||
? (0, typescript_1.parseTypeScript)(code, { lang }, parserOptions) | ||
? (0, typescript_1.parseTypeScript)(code, { lang }, parserOptions, svelteParseContext) | ||
: (0, script_1.parseScript)(code, { lang }, parserOptions); | ||
// Add $$xxx variable | ||
addGlobalVariables(resultScript.scopeManager, globals_1.globalsForSvelteScript); | ||
addGlobalVariables(resultScript.scopeManager, (0, globals_1.getGlobalsForSvelteScript)(svelteParseContext)); | ||
resultScript.services = Object.assign(resultScript.services || {}, { | ||
isSvelte: false, | ||
isSvelteScript: true, | ||
svelteParseContext, | ||
}); | ||
@@ -130,0 +136,0 @@ resultScript.visitorKeys = Object.assign({}, visitor_keys_1.KEYS, resultScript.visitorKeys); |
@@ -15,2 +15,3 @@ import { type UserOptionParser } from "./resolve-parser"; | ||
svelteFeatures?: { | ||
runes?: boolean; | ||
experimentalGenerics?: boolean; | ||
@@ -17,0 +18,0 @@ }; |
@@ -0,4 +1,6 @@ | ||
/// <reference types="svelte" /> | ||
import { VERSION as compilerVersion } from "svelte/compiler"; | ||
export { compilerVersion }; | ||
export declare const svelteVersion: { | ||
gte(v: number): boolean; | ||
hasRunes: boolean; | ||
}; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.svelteVersion = void 0; | ||
exports.svelteVersion = exports.compilerVersion = void 0; | ||
const compiler_1 = require("svelte/compiler"); | ||
Object.defineProperty(exports, "compilerVersion", { enumerable: true, get: function () { return compiler_1.VERSION; } }); | ||
const verStrings = compiler_1.VERSION.split("."); | ||
@@ -10,3 +11,2 @@ exports.svelteVersion = { | ||
}, | ||
hasRunes: Number(verStrings[0]) >= 5, | ||
}; |
import { VirtualTypeScriptContext } from "../context"; | ||
import type { SvelteHTMLElement } from "../../../ast"; | ||
import type { NormalizedParserOptions } from "../../parser-options"; | ||
import type { SvelteParseContext } from "../../svelte-parse-context"; | ||
export type AnalyzeTypeScriptContext = { | ||
slots: Set<SvelteHTMLElement>; | ||
svelteParseContext: SvelteParseContext; | ||
}; | ||
@@ -22,2 +24,2 @@ /** | ||
*/ | ||
export declare function analyzeTypeScript(code: string, attrs: Record<string, string | undefined>, parserOptions: NormalizedParserOptions): VirtualTypeScriptContext; | ||
export declare function analyzeTypeScript(code: string, attrs: Record<string, string | undefined>, parserOptions: NormalizedParserOptions, svelteParseContext: SvelteParseContext): VirtualTypeScriptContext; |
@@ -8,4 +8,4 @@ "use strict"; | ||
const context_1 = require("../context"); | ||
const globals_1 = require("../../../parser/globals"); | ||
const set_parent_1 = require("../set-parent"); | ||
const globals_1 = require("../../globals"); | ||
/** | ||
@@ -23,6 +23,9 @@ * Analyze TypeScript source code in <script>. | ||
ctx._beforeResult = result; | ||
analyzeStoreReferenceNames(result, ctx); | ||
analyzeDollarDollarVariables(result, ctx, context.slots); | ||
analyzeRuneVariables(result, ctx); | ||
applyTransforms([...analyzeReactiveScopes(result), ...analyzeDollarDerivedScopes(result)], ctx); | ||
analyzeStoreReferenceNames(result, context.svelteParseContext, ctx); | ||
analyzeDollarDollarVariables(result, ctx, context.svelteParseContext, context.slots); | ||
analyzeRuneVariables(result, ctx, context.svelteParseContext); | ||
applyTransforms([ | ||
...analyzeReactiveScopes(result), | ||
...analyzeDollarDerivedScopes(result, context.svelteParseContext), | ||
], ctx); | ||
analyzeRenderScopes(code, ctx); | ||
@@ -38,3 +41,3 @@ ctx.appendOriginalToEnd(); | ||
*/ | ||
function analyzeTypeScript(code, attrs, parserOptions) { | ||
function analyzeTypeScript(code, attrs, parserOptions, svelteParseContext) { | ||
const ctx = new context_1.VirtualTypeScriptContext(code); | ||
@@ -46,4 +49,4 @@ ctx.appendOriginal(/^\s*/u.exec(code)[0].length); | ||
ctx._beforeResult = result; | ||
analyzeRuneVariables(result, ctx); | ||
applyTransforms([...analyzeDollarDerivedScopes(result)], ctx); | ||
analyzeRuneVariables(result, ctx, svelteParseContext); | ||
applyTransforms([...analyzeDollarDerivedScopes(result, svelteParseContext)], ctx); | ||
ctx.appendOriginalToEnd(); | ||
@@ -57,3 +60,4 @@ return ctx; | ||
*/ | ||
function analyzeStoreReferenceNames(result, ctx) { | ||
function analyzeStoreReferenceNames(result, svelteParseContext, ctx) { | ||
const globals = (0, globals_1.getGlobalsForSvelte)(svelteParseContext); | ||
const scopeManager = result.scopeManager; | ||
@@ -67,3 +71,3 @@ const programScope = (0, scope_1.getProgramScope)(scopeManager); | ||
// Ignore globals | ||
!globals_1.globals.includes(reference.identifier.name) && | ||
!globals.includes(reference.identifier.name) && | ||
// Ignore if it is already defined. | ||
@@ -126,5 +130,6 @@ !programScope.set.has(reference.identifier.name)) { | ||
*/ | ||
function analyzeDollarDollarVariables(result, ctx, slots) { | ||
function analyzeDollarDollarVariables(result, ctx, svelteParseContext, slots) { | ||
const globals = (0, globals_1.getGlobalsForSvelte)(svelteParseContext); | ||
const scopeManager = result.scopeManager; | ||
for (const globalName of globals_1.globals) { | ||
for (const globalName of globals) { | ||
if (!scopeManager.globalScope.through.some((reference) => reference.identifier.name === globalName)) { | ||
@@ -209,3 +214,5 @@ continue; | ||
*/ | ||
function analyzeRuneVariables(result, ctx) { | ||
function analyzeRuneVariables(result, ctx, svelteParseContext) { | ||
if (!svelteParseContext.runes) | ||
return; | ||
const scopeManager = result.scopeManager; | ||
@@ -374,4 +381,6 @@ for (const globalName of globals_1.globalsForRunes) { | ||
*/ | ||
function* analyzeDollarDerivedScopes(result) { | ||
function* analyzeDollarDerivedScopes(result, svelteParseContext) { | ||
var _a; | ||
if (!svelteParseContext.runes) | ||
return; | ||
const scopeManager = result.scopeManager; | ||
@@ -378,0 +387,0 @@ const derivedReferences = scopeManager.globalScope.through.filter((reference) => reference.identifier.name === "$derived"); |
import type { ESLintExtendedProgram } from ".."; | ||
import type { NormalizedParserOptions } from "../parser-options"; | ||
import type { SvelteParseContext } from "../svelte-parse-context"; | ||
import type { AnalyzeTypeScriptContext } from "./analyze"; | ||
@@ -15,2 +16,2 @@ /** | ||
*/ | ||
export declare function parseTypeScript(code: string, attrs: Record<string, string | undefined>, parserOptions: NormalizedParserOptions): ESLintExtendedProgram; | ||
export declare function parseTypeScript(code: string, attrs: Record<string, string | undefined>, parserOptions: NormalizedParserOptions, svelteParseContext: SvelteParseContext): ESLintExtendedProgram; |
@@ -20,4 +20,4 @@ "use strict"; | ||
*/ | ||
function parseTypeScript(code, attrs, parserOptions) { | ||
const tsCtx = (0, analyze_1.analyzeTypeScript)(code, attrs, parserOptions); | ||
function parseTypeScript(code, attrs, parserOptions, svelteParseContext) { | ||
const tsCtx = (0, analyze_1.analyzeTypeScript)(code, attrs, parserOptions, svelteParseContext); | ||
const result = (0, script_1.parseScript)(tsCtx.script, attrs, parserOptions); | ||
@@ -24,0 +24,0 @@ (0, set_parent_1.setParent)(result); |
@@ -18,2 +18,6 @@ import type { ScopeManager, Scope, Reference, Variable } from "eslint-scope"; | ||
/** | ||
* Find the variable of a given identifier. | ||
*/ | ||
export declare function findVariable(scopeManager: ScopeManager, node: ESTree.Identifier): Variable | null; | ||
/** | ||
* Gets the scope for the Program node | ||
@@ -20,0 +24,0 @@ */ |
"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.getScopeFromNode = exports.removeAllScopeAndVariableAndReference = void 0; | ||
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; | ||
const traverse_1 = require("../traverse"); | ||
@@ -65,2 +65,17 @@ const utils_1 = require("../utils"); | ||
/** | ||
* Find the variable of a given identifier. | ||
*/ | ||
function findVariable(scopeManager, node) { | ||
let scope = getScopeFromNode(scopeManager, node); | ||
while (scope != null) { | ||
const variable = scope.set.get(node.name); | ||
if (variable != null) { | ||
return variable; | ||
} | ||
scope = scope.upper; | ||
} | ||
return null; | ||
} | ||
exports.findVariable = findVariable; | ||
/** | ||
* Gets the scope for the Program node | ||
@@ -67,0 +82,0 @@ */ |
{ | ||
"name": "svelte-eslint-parser", | ||
"version": "0.38.0", | ||
"version": "0.39.0", | ||
"description": "Svelte parser for ESLint", | ||
@@ -5,0 +5,0 @@ "repository": "git+https://github.com/sveltejs/svelte-eslint-parser.git", |
@@ -248,5 +248,30 @@ # svelte-eslint-parser | ||
### parserOptions.svelteConfig | ||
If you are using `eslint.config.js`, you can provide a `svelte.config.js` in the `parserOptions.svelteConfig` property. | ||
For example: | ||
```js | ||
import svelteConfig from "./svelte.config.js"; | ||
export default [ | ||
{ | ||
files: ["**/*.svelte", "*.svelte"], | ||
languageOptions: { | ||
parser: svelteParser, | ||
parserOptions: { | ||
svelteConfig: svelteConfig, | ||
}, | ||
}, | ||
}, | ||
]; | ||
``` | ||
If `parserOptions.svelteConfig` is not specified, some config will be statically parsed from the `svelte.config.js` file. | ||
The `.eslintrc.*` style configuration cannot load `svelte.config.js` because it cannot use ESM. We recommend using the `eslint.config.js` style configuration. | ||
### parserOptions.svelteFeatures | ||
You can use `parserOptions.svelteFeatures` property to specify how to parse related to Svelte features. For example: | ||
You can use `parserOptions.svelteFeatures` property to specify how to parse related to Svelte features. | ||
@@ -265,2 +290,8 @@ For example in `eslint.config.js`: | ||
/* It may be changed or removed in minor versions without notice. */ | ||
// If true, it will analyze Runes. | ||
// By default, it will try to read `compilerOptions.runes` from `svelte.config.js`. | ||
// However, note that if `parserOptions.svelteConfig` is not specified and the file cannot be parsed by static analysis, it will behave as `false`. | ||
runes: false, | ||
/* -- Experimental Svelte Features -- */ | ||
/* It may be changed or removed in minor versions without notice. */ | ||
// Whether to parse the `generics` attribute. | ||
@@ -285,2 +316,8 @@ // See https://github.com/sveltejs/rfcs/pull/38 | ||
/* It may be changed or removed in minor versions without notice. */ | ||
// If true, it will analyze Runes. | ||
// By default, it will try to read `compilerOptions.runes` from `svelte.config.js`. | ||
// However, note that if the file cannot be parsed by static analysis, it will behave as false. | ||
"runes": false, | ||
/* -- Experimental Svelte Features -- */ | ||
/* It may be changed or removed in minor versions without notice. */ | ||
// Whether to parse the `generics` attribute. | ||
@@ -298,3 +335,3 @@ // See https://github.com/sveltejs/rfcs/pull/38 | ||
If you install Svelte v5 the parser will be able to parse runes, and will also be able to parse `*.js` and `*.ts` files. | ||
If you install Svelte v5 and turn on runes (`compilerOptions.runes` in `svelte.config.js` or `parserOptions.svelteFeatures.runes` in ESLint config is `true`), the parser will be able to parse runes, and will also be able to parse `*.js` and `*.ts` files. | ||
@@ -306,2 +343,3 @@ When using this mode in an ESLint configuration, it is recommended to set it per file pattern as below. | ||
```js | ||
import svelteConfig from "./svelte.config.js"; | ||
export default [ | ||
@@ -314,2 +352,3 @@ { | ||
parser: "...", | ||
svelteConfig, | ||
/* ... */ | ||
@@ -324,2 +363,3 @@ }, | ||
parserOptions: { | ||
svelteConfig, | ||
/* ... */ | ||
@@ -335,2 +375,3 @@ }, | ||
parser: "...(ts parser)...", | ||
svelteConfig, | ||
/* ... */ | ||
@@ -353,2 +394,3 @@ }, | ||
"parser": "...", | ||
"svelteFeatures": { "runes": true }, | ||
/* ... */ | ||
@@ -361,2 +403,3 @@ }, | ||
"parserOptions": { | ||
"svelteFeatures": { "runes": true }, | ||
/* ... */ | ||
@@ -370,2 +413,3 @@ }, | ||
"parser": "...(ts parser)...", | ||
"svelteFeatures": { "runes": true }, | ||
/* ... */ | ||
@@ -372,0 +416,0 @@ }, |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
345522
105
8249
450
5