You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+45-75Lines changed: 45 additions & 75 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -32,33 +32,14 @@
32
32
33
33
`eslint-plugin-svelte` is the official [ESLint](https://eslint.org/) plugin for [Svelte](https://svelte.dev/).\
34
34
It leverages the AST generated by [svelte-eslint-parser](https://github.com/sveltejs/svelte-eslint-parser) to provide custom linting for Svelte.\
35
-
36
-
> [!NOTE]
37
-
>
38
-
> `eslint-plugin-svelte` and `svelte-eslint-parser` cannot be used alongside [eslint-plugin-svelte3](https://github.com/sveltejs/eslint-plugin-svelte3).
35
+
Note that `eslint-plugin-svelte` and `svelte-eslint-parser` cannot be used alongside [eslint-plugin-svelte3](https://github.com/sveltejs/eslint-plugin-svelte3).
39
36
40
37
<!--USAGE_SECTION_START-->
41
38
<!--USAGE_GUIDE_START-->
42
39
43
40
## Installation
44
41
45
-
### CLI
46
-
47
-
The recommended way to get started is to use the CLI.
48
-
49
-
```sh
50
-
# new project
51
-
npx sv create
52
-
53
-
# existing project
54
-
npx sv add eslint
55
-
```
56
-
57
-
See the [CLI docs](https://svelte.dev/docs/cli/eslint) for more details.
Use `eslint.config.js` to configure rules. See [ESLint documentation](https://eslint.org/docs/latest/use/configure/configuration-files-new) for more details.
55
+
Use the `eslint.config.js`file to configure rules. For more details, see the [ESLint documentation](https://eslint.org/docs/latest/use/configure/configuration-files-new).
75
56
76
57
### Configuration
77
58
78
59
#### JavaScript project
79
60
80
61
```js
81
62
// eslint.config.js
82
-
importsvelteConfigfrom'./svelte.config.js';
83
-
import { defineConfig } from'eslint/config';
84
-
importglobalsfrom'globals';
85
63
importjsfrom'@eslint/js';
86
64
importsveltefrom'eslint-plugin-svelte';
65
+
importglobalsfrom'globals';
66
+
importsvelteConfigfrom'./svelte.config.js';
87
67
88
-
exportdefaultdefineConfig([
89
-
// ...
68
+
/**@type{import('eslint').Linter.Config[]}*/
69
+
exportdefault [
90
70
js.configs.recommended,
91
-
svelte.configs.recommended,
71
+
...svelte.configs.recommended,
92
72
{
93
73
languageOptions: {
94
74
globals: {
95
75
...globals.browser,
96
-
// for Sveltekit in non-SPA mode
97
-
...globals.node
76
+
...globals.node// Add this if you are using SvelteKit in non-SPA mode
98
77
}
99
78
}
100
79
},
101
80
{
102
81
files: ['**/*.svelte', '**/*.svelte.js'],
103
82
languageOptions: {
104
83
parserOptions: {
105
-
// explicitly importing allows for better compatibilty and functionality with rules and other tooling that depend on the config file.
84
+
// We recommend importing and specifying svelte.config.js.
85
+
// By doing so, some rules in eslint-plugin-svelte will automatically read the configuration and adjust their behavior accordingly.
86
+
// While certain Svelte settings may be statically loaded from svelte.config.js even if you don’t specify it,
87
+
// explicitly specifying it ensures better compatibility and functionality.
106
88
//
107
-
// Note: `eslint --cache` will fail with non-serializable properties.
108
-
// In those cases, please remove the non-serializable properties.
109
-
// svelteConfig: {
110
-
// ...svelteConfig,
111
-
// kit: {
112
-
// ...svelteConfig.kit,
113
-
// typescript: undefined
114
-
// }
115
-
// }
89
+
// If non-serializable properties are included, running ESLint with the --cache flag will fail.
90
+
// In that case, please remove the non-serializable properties. (e.g. `svelteConfig: { ...svelteConfig, kit: { ...svelteConfig.kit, typescript: undefined }}`)
This plugin provides the following configurations:
207
173
208
-
-**`svelte.configs.base`**- Enables correct Svelte parsing. What does this include exactly?
209
-
-**`svelte.configs.recommended`**- Extends the `base`config with additional rules for Svelte best practices.
210
-
-**`svelte.configs.prettier`**- Disables rules that may conflict with [Prettier](https://prettier.io/). You still need to configure Prettier to work with Svelte, for example, by using [prettier-plugin-svelte](https://github.com/sveltejs/prettier-plugin-svelte).
211
-
-**`svelte.configs.all`**- **Not Recommended**- Includes all available rules. Subject to change with every major and minor release. Use at your own risk.
-**`eslintPluginSvelte.configs.recommended`**... Includes `base`configuration, plus rules to prevent errors or unintended behavior.
176
+
-**`eslintPluginSvelte.configs.prettier`**... Disables rules that may conflict with [Prettier](https://prettier.io/). You still need to configure Prettier to work with Svelte manually, for example, by using [prettier-plugin-svelte](https://github.com/sveltejs/prettier-plugin-svelte).
177
+
-**`eslintPluginSvelte.configs.all`**... Includes all available rules. **Note:**This configuration is not recommended for production use, as it changes with every minor and major version of `eslint-plugin-svelte`. Use at your own risk.
212
178
213
179
For more details, see [the rule list](https://sveltejs.github.io/eslint-plugin-svelte/rules/) to explore the rules provided by this plugin.
214
180
@@ -218,7 +184,7 @@ You can customize the behavior of this plugin using specific settings.
If you’re migrating from `eslint-plugin-svelte@1` or [`@ota-meshi/eslint-plugin-svelte`](https://www.npmjs.com/package/@ota-meshi/eslint-plugin-svelte), see the [migration guide](https://sveltejs.github.io/eslint-plugin-svelte/migration/).
243
+
If you’re migrating from `eslint-plugin-svelte` v1 or [`@ota-meshi/eslint-plugin-svelte`](https://www.npmjs.com/package/@ota-meshi/eslint-plugin-svelte), see the [migration guide](https://sveltejs.github.io/eslint-plugin-svelte/migration/).
Copy file name to clipboardExpand all lines: docs/README.md
+2-5Lines changed: 2 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -6,16 +6,13 @@ title: 'eslint-plugin-svelte'
6
6
7
7
`eslint-plugin-svelte` is the official [ESLint](https://eslint.org/) plugin for [Svelte](https://svelte.dev/).\
8
8
It leverages the AST generated by [svelte-eslint-parser](https://github.com/sveltejs/svelte-eslint-parser) to provide custom linting for Svelte.\
9
-
10
-
> [!NOTE]
11
-
>
12
-
> `eslint-plugin-svelte` and `svelte-eslint-parser` cannot be used alongside [eslint-plugin-svelte3](https://github.com/sveltejs/eslint-plugin-svelte3).
9
+
Note that `eslint-plugin-svelte` and `svelte-eslint-parser` cannot be used alongside [eslint-plugin-svelte3](https://github.com/sveltejs/eslint-plugin-svelte3).
13
10
14
11
See [User Guide](./user-guide.md).
15
12
16
13
## Migration Guide
17
14
18
-
If you’re migrating from `eslint-plugin-svelte@1` or [`@ota-meshi/eslint-plugin-svelte`](https://www.npmjs.com/package/@ota-meshi/eslint-plugin-svelte), see the [migration guide](./migration.md).
15
+
If you’re migrating from `eslint-plugin-svelte` v1 or [`@ota-meshi/eslint-plugin-svelte`](https://www.npmjs.com/package/@ota-meshi/eslint-plugin-svelte), see the [migration guide](./migration.md).
0 commit comments