Skip to content

Commit 0bbad48

Browse files
committed
Merge remote-tracking branch 'origin/main' into breaking/update-config
2 parents ed82143 + b384d57 commit 0bbad48

File tree

145 files changed

+1763
-209
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

145 files changed

+1763
-209
lines changed

.changeset/blue-panthers-run.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'eslint-plugin-svelte': patch
3+
---
4+
5+
fix: support each blocks without an item

.changeset/cold-starfishes-doubt.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'eslint-plugin-svelte': minor
3+
---
4+
5+
feat: added the no-navigation-without-base rule

.changeset/fifty-parents-itch.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'eslint-plugin-svelte': minor
3+
---
4+
5+
feat: Added suggestion to the `block-lang` rule.

.changeset/green-squids-compete.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'eslint-plugin-svelte': minor
3+
---
4+
5+
Add `prefer-const` rule

.changeset/olive-melons-explain.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'eslint-plugin-svelte': major
3+
---
4+
5+
breaking: deprecated the no-goto-without-base rule

.changeset/pre.json

+7
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,18 @@
66
"docs": "0.0.0"
77
},
88
"changesets": [
9+
"blue-panthers-run",
10+
"cold-starfishes-doubt",
911
"cool-rockets-allow",
1012
"fast-coins-fly",
13+
"fifty-parents-itch",
14+
"green-squids-compete",
15+
"hungry-grapes-shave",
1116
"lazy-eyes-wait",
17+
"olive-melons-explain",
1218
"olive-wolves-travel",
1319
"quiet-toys-burn",
20+
"sixty-news-look",
1421
"small-days-agree",
1522
"small-donuts-end",
1623
"thick-items-retire",

.changeset/sixty-news-look.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'eslint-plugin-svelte': minor
3+
---
4+
5+
feat: support Svelte5 of `valid-prop-names-in-kit-pages` rule

.github/workflows/pkg.pr.new.yml

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
name: Publish to pkg.pr.new
2+
on: [push, pull_request]
3+
4+
jobs:
5+
build:
6+
runs-on: ubuntu-latest
7+
8+
steps:
9+
- uses: actions/checkout@v4
10+
- uses: pnpm/action-setup@v2
11+
- uses: actions/setup-node@v4
12+
- name: Install Packages
13+
run: pnpm install
14+
- name: Build
15+
run: pnpm run build
16+
- run: pnpx pkg-pr-new publish --compact './packages/eslint-plugin-svelte'

.vscode/extensions.json

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"recommendations": ["rvest.vs-code-prettier-eslint"]
3+
}

.vscode/settings.json

+4-1
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,8 @@
88
"source.fixAll.stylelint": "explicit"
99
},
1010
"svelte.plugin.typescript.diagnostics.enable": false,
11-
"typescript.tsdk": "node_modules/typescript/lib"
11+
"typescript.tsdk": "node_modules/typescript/lib",
12+
"[typescript]": {
13+
"editor.defaultFormatter": "esbenp.prettier-vscode"
14+
}
1215
}

README.md

+53-50
Large diffs are not rendered by default.

docs/README.md

-2
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,6 @@ You can check on the [Online DEMO](https://eslint-online-playground.netlify.app/
1414
> For example, <https://github.com/sveltejs/eslint-plugin-svelte/blob/eslint-plugin-svelte%402.46.0/README.md>
1515
> and <https://github.com/sveltejs/eslint-plugin-svelte/blob/eslint-plugin-svelte%402.46.0/docs>
1616
17-
**_We are working on experimental support for Svelte v5, but may break with new versions of Svelte v5._**
18-
1917
[![NPM license](https://img.shields.io/npm/l/eslint-plugin-svelte.svg)](https://www.npmjs.com/package/eslint-plugin-svelte)
2018
[![NPM version](https://img.shields.io/npm/v/eslint-plugin-svelte.svg)](https://www.npmjs.com/package/eslint-plugin-svelte)
2119
[![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/eslint-plugin-svelte&maxAge=3600)](http://www.npmtrends.com/eslint-plugin-svelte)

docs/rules.md

+83-83
Large diffs are not rendered by default.

docs/rules/block-lang.md

+2
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ since: 'v2.18.0'
1010

1111
> disallows the use of languages other than those specified in the configuration for the lang attribute of `<script>` and `<style>` blocks.
1212
13+
- :bulb: Some problems reported by this rule are manually fixable by editor [suggestions](https://eslint.org/docs/developer-guide/working-with-rules#providing-suggestions).
14+
1315
## :book: Rule Details
1416

1517
This rule enforces all svelte components to use the same set of languages for their scripts and styles.

docs/rules/no-goto-without-base.md

+2
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ since: 'v2.36.0-next.9'
1010

1111
> disallow using goto() without the base path
1212
13+
- :warning: This rule was **deprecated** and replaced by [svelte/no-navigation-without-base](no-navigation-without-base.md) rule.
14+
1315
## :book: Rule Details
1416

1517
This rule reports navigation using SvelteKit's `goto()` function without prefixing a relative URL with the base path. If a non-prefixed relative URL is used for navigation, the `goto` function navigates away from the base path, which is usually not what you wanted to do (for external URLs, `window.location = url` should be used instead).
+94
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
---
2+
pageClass: 'rule-details'
3+
sidebarDepth: 0
4+
title: 'svelte/no-navigation-without-base'
5+
description: 'disallow using navigation (links, goto, pushState, replaceState) without the base path'
6+
since: 'v2.36.0-next.9'
7+
---
8+
9+
# svelte/no-navigation-without-base
10+
11+
> disallow using navigation (links, goto, pushState, replaceState) without the base path
12+
13+
## :book: Rule Details
14+
15+
This rule reports navigation using HTML `<a>` tags, SvelteKit's `goto()`, `pushState()` and `replaceState()` functions without prefixing a relative URL with the base path. All four of these may be used for navigation, with `goto()`, `pushState()` and `replaceState()` being intended solely for iternal navigation (i.e. not leaving the site), while `<a>` tags may be used for both internal and external navigation. When using any way of internal navigation, the base path must be prepended, otherwise the site may break. For programmatic navigation to external URLs, using `window.location` is advised.
16+
17+
This rule checks all 4 navigation options for the presence of the base path, with an exception for `<a>` links to absolute URLs, which are assumed to be used for external navigation and so do not require the base path, and for shallow outing functions with an empty string as the path, which keeps the current URL.
18+
19+
<!--eslint-skip-->
20+
21+
```svelte
22+
<script>
23+
/* eslint svelte/no-navigation-without-base: "error" */
24+
25+
import { goto, pushState, replaceState } from '$app/navigation';
26+
import { base } from '$app/paths';
27+
28+
// ✓ GOOD
29+
goto(base + '/foo/');
30+
goto(`${base}/foo/`);
31+
32+
pushState(base + '/foo/', {});
33+
pushState(`${base}/foo/`, {});
34+
pushState('', {});
35+
36+
replaceState(base + '/foo/', {});
37+
replaceState(`${base}/foo/`, {});
38+
replaceState('', {});
39+
40+
// ✗ BAD
41+
goto('/foo');
42+
goto('/foo/' + base);
43+
44+
pushState('/foo', {});
45+
replaceState('/foo', {});
46+
</script>
47+
48+
<!-- ✓ GOOD -->
49+
<a href={base + '/foo/'}>Click me!</a>
50+
<a href={`${base}/foo/`}>Click me!</a>
51+
<a href="https://svelte.dev">Click me!</a>
52+
53+
<!-- ✗ BAD -->
54+
<a href="/foo">Click me!</a>
55+
<a href={'/foo'}>Click me!</a>
56+
```
57+
58+
## :wrench: Options
59+
60+
```json
61+
{
62+
"svelte/no-navigation-without-base": [
63+
"error",
64+
{
65+
"ignoreGoto": false,
66+
"ignoreLinks": false,
67+
"ignorePushState": false,
68+
"ignoreReplaceState": false
69+
}
70+
]
71+
}
72+
```
73+
74+
- `ignoreGoto` ... Whether to ignore all `goto()` calls. Default `false`.
75+
- `ignoreLinks` ... Whether to ignore all `<a>` tags. Default `false`.
76+
- `ignorePushState` ... Whether to ignore all `pushState()` calls. Default `false`.
77+
- `ignoreReplaceState` ... Whether to ignore all `replaceState()` calls. Default `false`.
78+
79+
## :books: Further Reading
80+
81+
- [`base` documentation](https://svelte.dev/docs/kit/$app-paths#base)
82+
- [Shallow routing](https://svelte.dev/docs/kit/shallow-routing)
83+
- [`goto()` documentation](https://svelte.dev/docs/kit/$app-navigation#goto)
84+
- [`pushState()` documentation](https://svelte.dev/docs/kit/$app-navigation#pushState)
85+
- [`replaceState()` documentation](https://svelte.dev/docs/kit/$app-navigation#replaceState)
86+
87+
## :rocket: Version
88+
89+
This rule was introduced in eslint-plugin-svelte v2.36.0-next.9
90+
91+
## :mag: Implementation
92+
93+
- [Rule source](https://github.com/sveltejs/eslint-plugin-svelte/blob/main/packages/eslint-plugin-svelte/src/rules/no-navigation-without-base.ts)
94+
- [Test source](https://github.com/sveltejs/eslint-plugin-svelte/blob/main/packages/eslint-plugin-svelte/tests/src/rules/no-navigation-without-base.ts)

docs/rules/prefer-const.md

+73
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
---
2+
pageClass: 'rule-details'
3+
sidebarDepth: 0
4+
title: 'svelte/prefer-const'
5+
description: 'Require `const` declarations for variables that are never reassigned after declared'
6+
since: 'v3.0.0-next.6'
7+
---
8+
9+
# svelte/prefer-const
10+
11+
> Require `const` declarations for variables that are never reassigned after declared
12+
13+
- :wrench: The `--fix` option on the [command line](https://eslint.org/docs/user-guide/command-line-interface#fixing-problems) can automatically fix some of the problems reported by this rule.
14+
15+
## :book: Rule Details
16+
17+
This rule reports the same as the base ESLint `prefer-const` rule, except that ignores Svelte reactive values such as `$derived` and `$props`. If this rule is active, make sure to disable the base `prefer-const` rule, as it will conflict with this rule.
18+
19+
<!--eslint-skip-->
20+
21+
```svelte
22+
<script>
23+
/* eslint svelte/prefer-const: "error" */
24+
25+
// ✓ GOOD
26+
const { a, b } = $props();
27+
let c = $state('');
28+
let d = $derived(a * 2);
29+
let e = $derived.by(() => b * 2);
30+
31+
// ✗ BAD
32+
let obj = { a, b };
33+
let g = $state(0);
34+
let h = $state({ count: 1 });
35+
</script>
36+
37+
<input bind:value={c} />
38+
<input bind:value={h.count} />
39+
```
40+
41+
## :wrench: Options
42+
43+
```json
44+
{
45+
"svelte/prefer-const": [
46+
"error",
47+
{
48+
"destructuring": "any",
49+
"ignoreReadonly": true
50+
}
51+
]
52+
}
53+
```
54+
55+
- `destructuring`: The kind of the way to address variables in destructuring. There are 2 values:
56+
- `any` (default): if any variables in destructuring should be const, this rule warns for those variables.
57+
- `all`: if all variables in destructuring should be const, this rule warns the variables. Otherwise, ignores them.
58+
- `ignoreReadonly`: If `true`, this rule will ignore variables that are read between the declaration and the _first_ assignment.
59+
60+
## :books: Further Reading
61+
62+
- See [ESLint `prefer-const` rule](https://eslint.org/docs/latest/rules/prefer-const) for more information about the base rule.
63+
64+
## :rocket: Version
65+
66+
This rule was introduced in eslint-plugin-svelte v3.0.0-next.6
67+
68+
## :mag: Implementation
69+
70+
- [Rule source](https://github.com/sveltejs/eslint-plugin-svelte/blob/main/packages/eslint-plugin-svelte/src/rules/prefer-const.ts)
71+
- [Test source](https://github.com/sveltejs/eslint-plugin-svelte/blob/main/packages/eslint-plugin-svelte/tests/src/rules/prefer-const.ts)
72+
73+
<sup>Taken with ❤️ [from ESLint core](https://eslint.org/docs/rules/prefer-const)</sup>

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"private": true,
55
"license": "MIT",
66
"funding": "https://github.com/sponsors/ota-meshi",
7-
"packageManager": "[email protected].0",
7+
"packageManager": "[email protected].2",
88
"scripts": {
99
"prerelease": "cd packages/eslint-plugin-svelte && pnpm clean && pnpm run build && cd ../.. && cp README.md packages/eslint-plugin-svelte",
1010
"release": "changeset publish",

packages/eslint-plugin-svelte/CHANGELOG.md

+34
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,39 @@
11
# eslint-plugin-svelte
22

3+
## 3.0.0-next.8
4+
5+
### Minor Changes
6+
7+
- [#844](https://github.com/sveltejs/eslint-plugin-svelte/pull/844) [`2bbd049`](https://github.com/sveltejs/eslint-plugin-svelte/commit/2bbd0497ab7e05db0aab3c8958db08e3fdf4b9b2) Thanks [@Winter](https://github.com/Winter)! - feat: Added suggestion to the `block-lang` rule.
8+
9+
## 3.0.0-next.7
10+
11+
### Major Changes
12+
13+
- [#900](https://github.com/sveltejs/eslint-plugin-svelte/pull/900) [`4759b47`](https://github.com/sveltejs/eslint-plugin-svelte/commit/4759b47b195abee605a0597360fc9fc4c6d95f68) Thanks [@marekdedic](https://github.com/marekdedic)! - breaking: deprecated the no-goto-without-base rule
14+
15+
### Minor Changes
16+
17+
- [#900](https://github.com/sveltejs/eslint-plugin-svelte/pull/900) [`4759b47`](https://github.com/sveltejs/eslint-plugin-svelte/commit/4759b47b195abee605a0597360fc9fc4c6d95f68) Thanks [@marekdedic](https://github.com/marekdedic)! - feat: added the no-navigation-without-base rule
18+
19+
## 3.0.0-next.6
20+
21+
### Minor Changes
22+
23+
- [#933](https://github.com/sveltejs/eslint-plugin-svelte/pull/933) [`71eca84`](https://github.com/sveltejs/eslint-plugin-svelte/commit/71eca843c43250591ec6fa2dd1dc547b1074d6ad) Thanks [@mikededo](https://github.com/mikededo)! - Add `prefer-const` rule
24+
25+
- [#963](https://github.com/sveltejs/eslint-plugin-svelte/pull/963) [`2c551b2`](https://github.com/sveltejs/eslint-plugin-svelte/commit/2c551b20557bcd53e35479336bf0c25e88a7643b) Thanks [@baseballyama](https://github.com/baseballyama)! - feat: support Svelte5 of `valid-prop-names-in-kit-pages` rule
26+
27+
### Patch Changes
28+
29+
- [#961](https://github.com/sveltejs/eslint-plugin-svelte/pull/961) [`117e60d`](https://github.com/sveltejs/eslint-plugin-svelte/commit/117e60d4290966911450c7e0db8566279e4511bb) Thanks [@baseballyama](https://github.com/baseballyama)! - fix: support each blocks without an item
30+
31+
## 3.0.0-next.5
32+
33+
### Patch Changes
34+
35+
- [#956](https://github.com/sveltejs/eslint-plugin-svelte/pull/956) [`157ee1f`](https://github.com/sveltejs/eslint-plugin-svelte/commit/157ee1fade79aab88f01d125b0b01cf375da4cd1) Thanks [@baseballyama](https://github.com/baseballyama)! - chore: update `svelte-eslint-parser` to v1.0.0-next.4
36+
337
## 3.0.0-next.4
438

539
### Major Changes

packages/eslint-plugin-svelte/package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "eslint-plugin-svelte",
3-
"version": "3.0.0-next.4",
3+
"version": "3.0.0-next.8",
44
"description": "ESLint plugin for Svelte using AST",
55
"repository": "git+https://github.com/sveltejs/eslint-plugin-svelte.git",
66
"homepage": "https://sveltejs.github.io/eslint-plugin-svelte",
@@ -30,7 +30,7 @@
3030
"cover": "c8 --reporter=lcov pnpm run test",
3131
"debug": "pnpm run mocha \"tests/src/**/*.ts\" --reporter dot --timeout 60000",
3232
"lint": "run-p lint:*",
33-
"lint-fix": "pnpm run lint:es --fix && pnpm run lint:style --fix",
33+
"lint-fix": "pnpm run lint:es --fix",
3434
"lint:es": "eslint --cache .",
3535
"mocha": "pnpm run ts ./node_modules/mocha/bin/mocha.js",
3636
"new": "pnpm run ts ./tools/new-rule.ts",

packages/eslint-plugin-svelte/src/meta.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22
// This file has been automatically generated,
33
// in order to update its content execute "pnpm run update"
44
export const name = 'eslint-plugin-svelte';
5-
export const version = '3.0.0-next.4';
5+
export const version = '3.0.0-next.8';

0 commit comments

Comments
 (0)