Skip to content

Commit 5dd8f92

Browse files
authored
Revert "docs: update readme" (#1499)
1 parent b59c762 commit 5dd8f92

3 files changed

Lines changed: 90 additions & 150 deletions

File tree

README.md

Lines changed: 45 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -32,33 +32,14 @@
3232

3333
`eslint-plugin-svelte` is the official [ESLint](https://eslint.org/) plugin for [Svelte](https://svelte.dev/).\
3434
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).
3936

4037
<!--USAGE_SECTION_START-->
4138
<!--USAGE_GUIDE_START-->
4239

4340
## Installation
4441

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.
58-
59-
### Manual Setup
60-
61-
```sh
42+
```bash
6243
npm install --save-dev svelte eslint eslint-plugin-svelte globals
6344
```
6445

@@ -71,48 +52,42 @@ npm install --save-dev svelte eslint eslint-plugin-svelte globals
7152
7253
## Usage
7354

74-
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).
7556

7657
### Configuration
7758

7859
#### JavaScript project
7960

8061
```js
8162
// eslint.config.js
82-
import svelteConfig from './svelte.config.js';
83-
import { defineConfig } from 'eslint/config';
84-
import globals from 'globals';
8563
import js from '@eslint/js';
8664
import svelte from 'eslint-plugin-svelte';
65+
import globals from 'globals';
66+
import svelteConfig from './svelte.config.js';
8767

88-
export default defineConfig([
89-
// ...
68+
/** @type {import('eslint').Linter.Config[]} */
69+
export default [
9070
js.configs.recommended,
91-
svelte.configs.recommended,
71+
...svelte.configs.recommended,
9272
{
9373
languageOptions: {
9474
globals: {
9575
...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
9877
}
9978
}
10079
},
10180
{
10281
files: ['**/*.svelte', '**/*.svelte.js'],
10382
languageOptions: {
10483
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.
10688
//
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 }}`)
11691
svelteConfig
11792
}
11893
}
@@ -123,7 +98,7 @@ export default defineConfig([
12398
// 'svelte/rule-name': 'error'
12499
}
125100
}
126-
]);
101+
];
127102
```
128103

129104
#### TypeScript project
@@ -134,55 +109,46 @@ npm install --save-dev typescript-eslint
134109

135110
```js
136111
// eslint.config.js
137-
import svelteConfig from './svelte.config.js';
138-
import { defineConfig } from 'eslint/config';
139-
import globals from 'globals';
140112
import js from '@eslint/js';
141-
import ts from 'typescript-eslint';
142113
import svelte from 'eslint-plugin-svelte';
114+
import globals from 'globals';
115+
import ts from 'typescript-eslint';
116+
import svelteConfig from './svelte.config.js';
143117

144-
export default defineConfig(
118+
export default ts.config(
145119
js.configs.recommended,
146-
ts.configs.recommended,
147-
svelte.configs.recommended,
120+
...ts.configs.recommended,
121+
...svelte.configs.recommended,
148122
{
149123
languageOptions: {
150124
globals: {
151125
...globals.browser,
152-
// for Sveltekit in non-SPA mode
153126
...globals.node
154127
}
155128
}
156-
// ...
157129
},
158130
{
159131
files: ['**/*.svelte', '**/*.svelte.ts', '**/*.svelte.js'],
160132
// See more details at: https://typescript-eslint.io/packages/parser/
161133
languageOptions: {
162134
parserOptions: {
163135
projectService: true,
164-
// Enable typescript parsing for `.svelte` files.
165-
extraFileExtensions: ['.svelte'],
166-
136+
extraFileExtensions: ['.svelte'], // Add support for additional file extensions, such as .svelte
137+
parser: ts.parser,
167138
// Specify a parser for each language, if needed:
168139
// parser: {
169140
// ts: ts.parser,
141+
// js: espree, // Use espree for .js files (add: import espree from 'espree')
170142
// typescript: ts.parser
171-
// js: espree, // add `import espree from 'espree'`
172143
// },
173-
parser: ts.parser,
174144

175-
// explicitly importing allows for better compatibilty and functionality with rules and other tooling that depend on the config file.
145+
// We recommend importing and specifying svelte.config.js.
146+
// By doing so, some rules in eslint-plugin-svelte will automatically read the configuration and adjust their behavior accordingly.
147+
// While certain Svelte settings may be statically loaded from svelte.config.js even if you don’t specify it,
148+
// explicitly specifying it ensures better compatibility and functionality.
176149
//
177-
// Note: `eslint --cache` will fail with non-serializable properties.
178-
// In those cases, please remove the non-serializable properties.
179-
// svelteConfig: {
180-
// ...svelteConfig,
181-
// kit: {
182-
// ...svelteConfig.kit,
183-
// typescript: undefined
184-
// }
185-
// }
150+
// If non-serializable properties are included, running ESLint with the --cache flag will fail.
151+
// In that case, please remove the non-serializable properties. (e.g. `svelteConfig: { ...svelteConfig, kit: { ...svelteConfig.kit, typescript: undefined }}`)
186152
svelteConfig
187153
}
188154
}
@@ -205,10 +171,10 @@ export default defineConfig(
205171

206172
This plugin provides the following configurations:
207173

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.
174+
- **`eslintPluginSvelte.configs.base`** ... Enables correct Svelte parsing.
175+
- **`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.
212178

213179
For more details, see [the rule list](https://sveltejs.github.io/eslint-plugin-svelte/rules/) to explore the rules provided by this plugin.
214180

@@ -218,7 +184,7 @@ You can customize the behavior of this plugin using specific settings.
218184

219185
```js
220186
// eslint.config.js
221-
export default defineConfig([
187+
export default [
222188
// ...
223189
{
224190
settings: {
@@ -229,10 +195,9 @@ export default defineConfig([
229195
'@typescript-eslint/no-unsafe-assignment',
230196
'@typescript-eslint/no-unsafe-member-access'
231197
],
232-
233198
// Specifies options for Svelte compilation.
234199
// This affects rules that rely on Svelte compilation,
235-
// such as `svelte/valid-compile` and `svelte/no-unused-svelte-ignore`.
200+
// such as svelte/valid-compile and svelte/no-unused-svelte-ignore.
236201
// Note that this setting does not impact ESLint’s custom parser.
237202
compileOptions: {
238203
// Specifies options related to PostCSS. You can disable the PostCSS processing by setting it to false.
@@ -241,7 +206,6 @@ export default defineConfig([
241206
configFilePath: './path/to/my/postcss.config.js'
242207
}
243208
},
244-
245209
// Even if settings.svelte.kit is not specified, the rules will attempt to load information from svelte.config.js.
246210
// However, if the default behavior does not work as expected, you should specify settings.svelte.kit explicitly.
247211
// If you are using SvelteKit with a non-default configuration, you need to set the following options.
@@ -256,7 +220,7 @@ export default defineConfig([
256220
}
257221
}
258222
// ...
259-
]);
223+
];
260224
```
261225

262226
## Editor Integrations
@@ -265,12 +229,18 @@ export default defineConfig([
265229
Install [dbaeumer.vscode-eslint](https://marketplace.visualstudio.com/items?itemName=dbaeumer.vscode-eslint).\
266230
Configure `.svelte` files in `.vscode/settings.json`:
267231

232+
```json
233+
{
234+
"eslint.validate": ["javascript", "javascriptreact", "svelte"]
235+
}
236+
```
237+
268238
<!--USAGE_GUIDE_END-->
269239
<!--USAGE_SECTION_END-->
270240

271241
## Migration Guide
272242

273-
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/).
274244

275245
## Versioning Policy
276246

docs/README.md

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,13 @@ title: 'eslint-plugin-svelte'
66

77
`eslint-plugin-svelte` is the official [ESLint](https://eslint.org/) plugin for [Svelte](https://svelte.dev/).\
88
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).
1310

1411
See [User Guide](./user-guide.md).
1512

1613
## Migration Guide
1714

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).
1916

2017
## Versioning Policy
2118

0 commit comments

Comments
 (0)