Skip to content

chore: add migration guide for v3 #1065

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 9, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
96 changes: 96 additions & 0 deletions docs/migration.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,3 +62,99 @@ Therefore, you need to replace the package name, and the presets, rules, and set
+ "svelte": { ... }
},
```

## From `eslint-plugin-svelte` v2 To v3

This section explains the necessary changes when upgrading from `eslint-plugin-svelte` v2 to v3.
v3 includes **support for ESLint Flat Config only**, **changes to the recommended rule set**, and other breaking changes.

---

## Breaking Changes

### 1. **Minimum Node.js Version Requirement**

v3 requires **one of the following Node.js versions**:

- `^18.20.4`
- `^20.18.0`
- `>=22.10.0`

### 2. **ESLint Flat Config Only**

- `.eslintrc.js` and `.eslintrc.json` are **no longer supported**.
- You must use **Flat Config (`eslint.config.js`)**.
- See [README](README.md) for more details.

### 3. **ESLint Version Requirement**

- v3 requires **ESLint 8.57.1 or later** (including v9.x).

### 4. **Changes to Recommended Rule Set**

- The following rules are now included in `recommended`:
- `svelte/infinite-reactive-loop`
- `svelte/no-dom-manipulating`
- `svelte/no-dupe-on-directives`
- `svelte/no-reactive-reassign`
- `svelte/require-event-dispatcher-types`
- Many others (See [Changelog](https://github.com/sveltejs/eslint-plugin-svelte/releases/tag/eslint-plugin-svelte%403.0.0-next.16) for more details)
- `svelte/valid-compile` has been **removed** from `recommended`.

### 5. **Deprecated Rules**

- `svelte/no-dynamic-slot-name` is **deprecated**.
- `svelte/no-goto-without-base` is **deprecated** and replaced with `svelte/no-navigation-without-base`.

---

## New Features & Improvements

### 1. **Support for Svelte 5**

- Rules such as `no-not-function-handler` and `valid-prop-names-in-kit-pages` now support **Svelte 5**.

### 2. **New Rules**

- `consistent-selector-style`: Enforce consistent selector styles.
- `no-useless-children-snippet`: Prevent unnecessary `{@children}` usage.
- `prefer-const`: Prefer `const` over `let`.
- `no-navigation-without-base`: Ensure proper usage of `goto()`.

---

## Migration Steps

### 1. **Upgrade Package**

```sh
npm install eslint-plugin-svelte@3
```

### 2. **Check Node.js Version**

```sh
node -v
```

- Ensure it is `v18.20.4` or later.

### 3. **Check ESLint Version**

```sh
npx eslint -v
```

- Ensure it is `8.57.1` or later (or `9.x`).

### 4. **Use Flat Config (`eslint.config.js`)**

- Remove `.eslintrc.js` and migrate to `eslint.config.js`.

### 5. **Apply the Updated Recommended Rules**

- If using `recommended`, check the impact of newly added rules.

### 6. **Replace Deprecated Rules**

- Replace `no-goto-without-base` with `no-navigation-without-base`.