Skip to content

Commit d509d1c

Browse files
committed
update
1 parent 23f2327 commit d509d1c

File tree

3 files changed

+46
-164
lines changed

3 files changed

+46
-164
lines changed

Diff for: README.md

+20-140
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@ You can check it on [Online DEMO](https://sveltejs.github.io/svelte-eslint-parse
88
> Please refer to the README for the version you are using.\
99
> For example, <https://github.com/sveltejs/svelte-eslint-parser/blob/v0.43.0/README.md>
1010
11-
**_Note that this parser has experimental support for Svelte v5, but may break with new versions of Svelte v5._**
12-
1311
[![NPM license](https://img.shields.io/npm/l/svelte-eslint-parser.svg)](https://www.npmjs.com/package/svelte-eslint-parser)
1412
[![NPM version](https://img.shields.io/npm/v/svelte-eslint-parser.svg)](https://www.npmjs.com/package/svelte-eslint-parser)
1513
[![NPM downloads](https://img.shields.io/badge/dynamic/json.svg?label=downloads&colorB=green&suffix=/day&query=$.downloads&uri=https://api.npmjs.org//downloads/point/last-day/svelte-eslint-parser&maxAge=3600)](http://www.npmtrends.com/svelte-eslint-parser)
@@ -41,12 +39,6 @@ It provides many unique check rules by using the template AST.
4139
ESLint plugin for internationalization (i18n) with Svelte.
4240
It provides rules to help internationalization your application created with Svelte.
4341

44-
## ❗ Attention
45-
46-
The [svelte-eslint-parser] can not be used with the [eslint-plugin-svelte3].
47-
48-
[svelte-eslint-parser]: https://github.com/sveltejs/svelte-eslint-parser
49-
5042
## 💿 Installation
5143

5244
```bash
@@ -74,20 +66,6 @@ export default [
7466
];
7567
```
7668

77-
### ESLint Config (`.eslintrc.*`)
78-
79-
```json
80-
{
81-
"extends": "eslint:recommended",
82-
"overrides": [
83-
{
84-
"files": ["*.svelte"],
85-
"parser": "svelte-eslint-parser"
86-
}
87-
]
88-
}
89-
```
90-
9169
### CLI
9270

9371
```console
@@ -101,18 +79,26 @@ $ eslint src --ext .svelte
10179
[`parserOptions`] has the same properties as what [espree](https://github.com/eslint/espree#usage), the default parser of ESLint, is supporting.
10280
For example:
10381

104-
```json
105-
{
106-
"parserOptions": {
107-
"sourceType": "module",
108-
"ecmaVersion": 2021,
109-
"ecmaFeatures": {
110-
"globalReturn": false,
111-
"impliedStrict": false,
112-
"jsx": false
113-
}
114-
}
115-
}
82+
```js
83+
import svelteParser from "svelte-eslint-parser";
84+
export default [
85+
// ...
86+
{
87+
files: ["**/*.svelte", "*.svelte"],
88+
languageOptions: {
89+
parser: svelteParser,
90+
parserOptions: {
91+
sourceType: "module",
92+
ecmaVersion: 2021,
93+
ecmaFeatures: {
94+
globalReturn: false,
95+
impliedStrict: false,
96+
jsx: false,
97+
},
98+
},
99+
},
100+
},
101+
];
116102
```
117103

118104
[`parserOptions`]: https://eslint.org/docs/latest/use/configure/parser#configure-parser-options
@@ -139,17 +125,6 @@ export default [
139125
];
140126
```
141127

142-
For example in `.eslintrc.*`:
143-
144-
```json
145-
{
146-
"parser": "svelte-eslint-parser",
147-
"parserOptions": {
148-
"parser": "@typescript-eslint/parser"
149-
}
150-
}
151-
```
152-
153128
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.
154129

155130
For example in `eslint.config.js`:
@@ -183,32 +158,6 @@ export default [
183158
];
184159
```
185160

186-
For example in `.eslintrc.*`:
187-
188-
```js
189-
module.exports = {
190-
// ...
191-
parser: "@typescript-eslint/parser",
192-
parserOptions: {
193-
// ...
194-
project: "path/to/your/tsconfig.json",
195-
extraFileExtensions: [".svelte"], // This is a required setting in `@typescript-eslint/parser` v4.24.0.
196-
},
197-
overrides: [
198-
{
199-
files: ["*.svelte"],
200-
parser: "svelte-eslint-parser",
201-
// Parse the `<script>` in `.svelte` as TypeScript by adding the following configuration.
202-
parserOptions: {
203-
parser: "@typescript-eslint/parser",
204-
},
205-
},
206-
// ...
207-
],
208-
// ...
209-
};
210-
```
211-
212161
#### Multiple parsers
213162

214163
If you want to switch the parser for each lang, specify the object.
@@ -235,21 +184,6 @@ export default [
235184
];
236185
```
237186

238-
For example in `.eslintrc.*`:
239-
240-
```json
241-
{
242-
"parser": "svelte-eslint-parser",
243-
"parserOptions": {
244-
"parser": {
245-
"ts": "@typescript-eslint/parser",
246-
"js": "espree",
247-
"typescript": "@typescript-eslint/parser"
248-
}
249-
}
250-
}
251-
```
252-
253187
### parserOptions.svelteConfig
254188

255189
If you are using `eslint.config.js`, you can provide a `svelte.config.js` in the `parserOptions.svelteConfig` property.
@@ -289,7 +223,6 @@ export default [
289223
parser: svelteParser,
290224
parserOptions: {
291225
svelteFeatures: {
292-
/* It may be changed or removed in minor versions without notice. */
293226
// This option is for Svelte 5. The default value is `true`.
294227
// If `false`, ESLint will not recognize rune symbols.
295228
// If not configured this option, The parser will try to read the option from `compilerOptions.runes` from `svelte.config.js`.
@@ -302,28 +235,8 @@ export default [
302235
];
303236
```
304237

305-
For example in `.eslintrc.*`:
306-
307-
```jsonc
308-
{
309-
"parser": "svelte-eslint-parser",
310-
"parserOptions": {
311-
"svelteFeatures": {
312-
/* It may be changed or removed in minor versions without notice. */
313-
// This option is for Svelte 5. The default value is `true`.
314-
// If `false`, ESLint will not recognize rune symbols.
315-
// If not configured this option, The parser will try to read the option from `compilerOptions.runes` from `svelte.config.js`.
316-
// If `parserOptions.svelteConfig` is not specified and the file cannot be parsed by static analysis, it will behave as `true`.
317-
"runes": true,
318-
},
319-
},
320-
}
321-
```
322-
323238
### Runes support
324239

325-
**_This is an experimental feature. It may be changed or removed in minor versions without notice._**
326-
327240
If you install Svelte v5 the parser will be able to parse runes, and will also be able to parse `*.js` and `*.ts` files.
328241
If you don't want to use Runes, you may need to configure. Please read [parserOptions.svelteFeatures](#parseroptionssveltefeatures) for more details.
329242

@@ -369,38 +282,6 @@ export default [
369282
];
370283
```
371284

372-
For example in `.eslintrc.*`:
373-
374-
```jsonc
375-
{
376-
"overrides": [
377-
{
378-
"files": ["*.svelte"],
379-
"parser": "svelte-eslint-parser",
380-
"parserOptions": {
381-
"parser": "...",
382-
/* ... */
383-
},
384-
},
385-
{
386-
"files": ["*.svelte.js"],
387-
"parser": "svelte-eslint-parser",
388-
"parserOptions": {
389-
/* ... */
390-
},
391-
},
392-
{
393-
"files": ["*.svelte.ts"],
394-
"parser": "svelte-eslint-parser",
395-
"parserOptions": {
396-
"parser": "...(ts parser)...",
397-
/* ... */
398-
},
399-
},
400-
],
401-
}
402-
```
403-
404285
## :computer: Editor Integrations
405286

406287
### Visual Studio Code
@@ -439,4 +320,3 @@ See the [LICENSE](LICENSE) file for license rights and limitations (MIT).
439320

440321
[Svelte]: https://svelte.dev/
441322
[ESLint]: https://eslint.org/
442-
[eslint-plugin-svelte3]: https://github.com/sveltejs/eslint-plugin-svelte3

Diff for: src/index.ts

+2-24
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,2 @@
1-
import * as AST from "./ast/index.js";
2-
import { traverseNodes } from "./traverse.js";
3-
import { KEYS } from "./visitor-keys.js";
4-
import { ParseError } from "./errors.js";
5-
export {
6-
parseForESLint,
7-
type StyleContext,
8-
type StyleContextNoStyleElement,
9-
type StyleContextParseError,
10-
type StyleContextSuccess,
11-
type StyleContextUnknownLang,
12-
} from "./parser/index.js";
13-
export * as meta from "./meta.js";
14-
export { name } from "./meta.js";
15-
export type { SvelteConfig } from "./svelte-config/index.js";
16-
17-
export { AST, ParseError };
18-
19-
// Keys
20-
// eslint-disable-next-line @typescript-eslint/naming-convention -- ignore
21-
export const VisitorKeys = KEYS;
22-
23-
// tools
24-
export { traverseNodes };
1+
export * from "./main.js";
2+
export * as default from "./main.js";

Diff for: src/main.ts

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import * as AST from "./ast/index.js";
2+
import { traverseNodes } from "./traverse.js";
3+
import { KEYS } from "./visitor-keys.js";
4+
import { ParseError } from "./errors.js";
5+
export {
6+
parseForESLint,
7+
type StyleContext,
8+
type StyleContextNoStyleElement,
9+
type StyleContextParseError,
10+
type StyleContextSuccess,
11+
type StyleContextUnknownLang,
12+
} from "./parser/index.js";
13+
export * as meta from "./meta.js";
14+
export { name } from "./meta.js";
15+
export type { SvelteConfig } from "./svelte-config/index.js";
16+
17+
export { AST, ParseError };
18+
19+
// Keys
20+
// eslint-disable-next-line @typescript-eslint/naming-convention -- ignore
21+
export const VisitorKeys = KEYS;
22+
23+
// tools
24+
export { traverseNodes };

0 commit comments

Comments
 (0)