Skip to content

Commit 13dbec9

Browse files
committed
add options
1 parent 450b92f commit 13dbec9

File tree

3 files changed

+26
-1
lines changed

3 files changed

+26
-1
lines changed

README.md

+18
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,24 @@ module.exports = {
169169
}
170170
```
171171

172+
### parserOptions.svelteFeatures
173+
174+
You can use `parserOptions.svelteFeatures` property to specify how to parse related to Svelte features. For example:
175+
176+
```json
177+
{
178+
"parser": "svelte-eslint-parser",
179+
"parserOptions": {
180+
"svelteFeatures": {
181+
/* -- Experimental Svelte Features -- */
182+
// Whether to parse the `generics` attribute.
183+
// See https://github.com/sveltejs/rfcs/pull/38
184+
"experimentalGenerics": false
185+
}
186+
}
187+
}
188+
```
189+
172190
### Runes support
173191

174192
***This is an experimental feature. It may be changed or removed in minor versions without notice.***

src/parser/converts/root.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,8 @@ export function convertSvelteRoot(
5252
...ctx.getConvertLocation(instance),
5353
};
5454
extractAttributes(script, ctx);
55-
convertGenericsAttribute(script, ctx);
55+
if (ctx.parserOptions.svelteFeatures?.experimentalGenerics)
56+
convertGenericsAttribute(script, ctx);
5657
extractElementTags(script, ctx, {
5758
buildNameNode: (openTokenRange) => {
5859
ctx.addToken("HTMLIdentifier", openTokenRange);

src/parser/parser-options.ts

+6
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,12 @@ export type NormalizedParserOptions = {
1919
experimentalObjectRestSpread?: boolean | undefined;
2020
[key: string]: any;
2121
};
22+
svelteFeatures?: {
23+
/* -- Experimental Svelte Features -- */
24+
// Whether to parse the `generics` attribute.
25+
// See https://github.com/sveltejs/rfcs/pull/38
26+
experimentalGenerics?: boolean;
27+
};
2228
loc: boolean;
2329
range: boolean;
2430
raw: boolean;

0 commit comments

Comments
 (0)