Skip to content

Commit c31afeb

Browse files
committed
Merge branch 'main' into no-unused-class-name-parser-services
2 parents f594c9c + ab9e6e7 commit c31afeb

40 files changed

+482
-64
lines changed

.changeset/tasty-beds-compare.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"eslint-plugin-svelte": minor
3+
---
4+
5+
fix(deps): update dependency svelte-eslint-parser to ^0.31.0

.changeset/wise-flies-lay.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"eslint-plugin-svelte": minor
3+
---
4+
5+
feat: add `no-restricted-html-elements` rule

.env-cmdrc

Lines changed: 0 additions & 11 deletions
This file was deleted.

.env-cmdrc.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
"use strict"
2+
3+
module.exports = {
4+
version: {
5+
IN_VERSION_SCRIPT: "true",
6+
},
7+
"version-ci": {
8+
IN_VERSION_CI_SCRIPT: "true",
9+
},
10+
debug: {
11+
DEBUG: "eslint-plugin-svelte*",
12+
},
13+
sveltekit: {
14+
NODE_OPTIONS: `--experimental-loader ./svelte-kit-import-hook.mjs ${
15+
// eslint-disable-next-line no-process-env -- ignore
16+
process.env.NODE_OPTIONS || ""
17+
}`,
18+
},
19+
}

.eslintrc.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ module.exports = {
2020
"plugin:@ota-meshi/+prettier",
2121
],
2222
rules: {
23-
"require-jsdoc": "error",
23+
"require-jsdoc": "off",
2424
"no-warning-comments": "warn",
2525
"no-lonely-if": "off",
2626
"new-cap": "off",
@@ -33,6 +33,7 @@ module.exports = {
3333
usePrettierrc: true,
3434
},
3535
],
36+
"node/no-missing-import": "off", // It's a plugin bug. Should be replaced with eslint-plugin-n.
3637
// Repo rule
3738
"no-restricted-imports": [
3839
"error",
@@ -149,7 +150,6 @@ module.exports = {
149150
project: require.resolve("./tsconfig.json"),
150151
},
151152
rules: {
152-
"require-jsdoc": "off",
153153
"no-console": "off",
154154
},
155155
},

.github/workflows/NodeCI.yml

Lines changed: 28 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ jobs:
1919
run: |+
2020
pnpm run build
2121
pnpm run lint
22+
- name: Type Coverage
23+
run: pnpm run typecov
2224
build:
2325
runs-on: ubuntu-latest
2426
steps:
@@ -38,7 +40,31 @@ jobs:
3840
matrix:
3941
os: [ubuntu-latest]
4042
eslint: [7, 8]
41-
node: [14, 16, 17, 18, 20]
43+
node: [16, 17, 18, 20]
44+
steps:
45+
- name: Checkout
46+
uses: actions/checkout@v3
47+
- uses: pnpm/action-setup@v2
48+
- name: Setup Node.js ${{ matrix.node }}
49+
uses: actions/setup-node@v3
50+
with:
51+
node-version: ${{ matrix.node }}
52+
- name: Install ESLint ${{ matrix.eslint }}
53+
run: |+
54+
pnpm install -D eslint@${{ matrix.eslint }}
55+
rm -rf node_modules
56+
if: matrix.eslint != 8
57+
- name: Install Packages
58+
run: pnpm install
59+
- name: Test
60+
run: pnpm run test
61+
test-for-svelte-v3:
62+
name: Test for Svelte v3
63+
runs-on: ${{ matrix.os }}
64+
strategy:
65+
matrix:
66+
os: [ubuntu-latest]
67+
node: [14]
4268
steps:
4369
- name: Checkout
4470
uses: actions/checkout@v3
@@ -53,16 +79,12 @@ jobs:
5379
rm -rf node_modules
5480
- name: Install ESLint ${{ matrix.eslint }}
5581
run: |+
56-
pnpm install -D eslint@${{ matrix.eslint }}
82+
pnpm install -D svelte@3
5783
rm -rf node_modules
58-
rm -rf pnpm-lock.yaml
59-
if: matrix.eslint != 8
6084
- name: Install Packages
6185
run: pnpm install
6286
- name: Test
6387
run: pnpm run test
64-
- name: Type Coverage
65-
run: pnpm run typecov
6688
update-resources:
6789
runs-on: ubuntu-latest
6890
steps:

CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
11
# eslint-plugin-svelte
22

3+
## 2.30.0
4+
5+
### Minor Changes
6+
7+
- [#494](https://github.com/sveltejs/eslint-plugin-svelte/pull/494) [`e5ea6fe`](https://github.com/sveltejs/eslint-plugin-svelte/commit/e5ea6fe641788e05339f468ce6c3d818df7b2446) Thanks [@ota-meshi](https://github.com/ota-meshi)! - feat: add experimental support for Svelte v4
8+
9+
- [#494](https://github.com/sveltejs/eslint-plugin-svelte/pull/494) [`e5ea6fe`](https://github.com/sveltejs/eslint-plugin-svelte/commit/e5ea6fe641788e05339f468ce6c3d818df7b2446) Thanks [@ota-meshi](https://github.com/ota-meshi)! - fix(deps): update dependency svelte-eslint-parser to ^0.30.0
10+
311
## 2.29.0
412

513
### Minor Changes

README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -310,7 +310,7 @@ These rules relate to possible syntax or logic errors in Svelte code:
310310
| [svelte/no-dupe-style-properties](https://sveltejs.github.io/eslint-plugin-svelte/rules/no-dupe-style-properties/) | disallow duplicate style properties | :star: |
311311
| [svelte/no-dupe-use-directives](https://sveltejs.github.io/eslint-plugin-svelte/rules/no-dupe-use-directives/) | disallow duplicate `use:` directives | |
312312
| [svelte/no-dynamic-slot-name](https://sveltejs.github.io/eslint-plugin-svelte/rules/no-dynamic-slot-name/) | disallow dynamic slot name | :star::wrench: |
313-
| [svelte/no-export-load-in-svelte-module-in-kit-pages](https://sveltejs.github.io/eslint-plugin-svelte/rules/no-export-load-in-svelte-module-in-kit-pages/) | disallow exporting load functions in `*.svelte` module in Svelte Kit page components. | |
313+
| [svelte/no-export-load-in-svelte-module-in-kit-pages](https://sveltejs.github.io/eslint-plugin-svelte/rules/no-export-load-in-svelte-module-in-kit-pages/) | disallow exporting load functions in `*.svelte` module in SvelteKit page components. | |
314314
| [svelte/no-not-function-handler](https://sveltejs.github.io/eslint-plugin-svelte/rules/no-not-function-handler/) | disallow use of not function in event handler | :star: |
315315
| [svelte/no-object-in-text-mustaches](https://sveltejs.github.io/eslint-plugin-svelte/rules/no-object-in-text-mustaches/) | disallow objects in text mustache interpolation | :star: |
316316
| [svelte/no-reactive-reassign](https://sveltejs.github.io/eslint-plugin-svelte/rules/no-reactive-reassign/) | disallow reassigning reactive values | |
@@ -320,7 +320,7 @@ These rules relate to possible syntax or logic errors in Svelte code:
320320
| [svelte/require-store-callbacks-use-set-param](https://sveltejs.github.io/eslint-plugin-svelte/rules/require-store-callbacks-use-set-param/) | store callbacks must use `set` param | |
321321
| [svelte/require-store-reactive-access](https://sveltejs.github.io/eslint-plugin-svelte/rules/require-store-reactive-access/) | disallow to use of the store itself as an operand. Need to use $ prefix or get function. | :wrench: |
322322
| [svelte/valid-compile](https://sveltejs.github.io/eslint-plugin-svelte/rules/valid-compile/) | disallow warnings when compiling. | :star: |
323-
| [svelte/valid-prop-names-in-kit-pages](https://sveltejs.github.io/eslint-plugin-svelte/rules/valid-prop-names-in-kit-pages/) | disallow props other than data or errors in Svelte Kit page components. | |
323+
| [svelte/valid-prop-names-in-kit-pages](https://sveltejs.github.io/eslint-plugin-svelte/rules/valid-prop-names-in-kit-pages/) | disallow props other than data or errors in SvelteKit page components. | |
324324

325325
## Security Vulnerability
326326

@@ -368,6 +368,7 @@ These rules relate to style guidelines, and are therefore quite subjective:
368368
| [svelte/max-attributes-per-line](https://sveltejs.github.io/eslint-plugin-svelte/rules/max-attributes-per-line/) | enforce the maximum number of attributes per line | :wrench: |
369369
| [svelte/mustache-spacing](https://sveltejs.github.io/eslint-plugin-svelte/rules/mustache-spacing/) | enforce unified spacing in mustache | :wrench: |
370370
| [svelte/no-extra-reactive-curlies](https://sveltejs.github.io/eslint-plugin-svelte/rules/no-extra-reactive-curlies/) | disallow wrapping single reactive statements in curly braces | :bulb: |
371+
| [svelte/no-restricted-html-elements](https://sveltejs.github.io/eslint-plugin-svelte/rules/no-restricted-html-elements/) | disallow specific HTML elements | |
371372
| [svelte/no-spaces-around-equal-signs-in-attribute](https://sveltejs.github.io/eslint-plugin-svelte/rules/no-spaces-around-equal-signs-in-attribute/) | disallow spaces around equal signs in attribute | :wrench: |
372373
| [svelte/prefer-class-directive](https://sveltejs.github.io/eslint-plugin-svelte/rules/prefer-class-directive/) | require class directives instead of ternary expressions | :wrench: |
373374
| [svelte/prefer-style-directive](https://sveltejs.github.io/eslint-plugin-svelte/rules/prefer-style-directive/) | require style directives instead of style attribute | :wrench: |

docs-svelte-kit/src/lib/header/Header.svelte

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616
<div class="corner">
1717
<div
1818
class="sidebar-button"
19+
role="button"
20+
tabindex="0"
1921
on:click={handleToggleSidebar}
2022
on:keydown={(e) =>
2123
(e.code === "Enter" || e.code === "Space") && handleToggleSidebar()}
@@ -44,20 +46,20 @@
4446
</svg>
4547
<ul>
4648
<li class:active={isActive("/", $page)}>
47-
<a sveltekit:prefetch href="{baseUrl}/">Home</a>
49+
<a href="{baseUrl}/">Home</a>
4850
</li>
4951
<li class:active={isActive("/user-guide/", $page)}>
50-
<a sveltekit:prefetch href="{baseUrl}/user-guide/">User Guide</a>
52+
<a href="{baseUrl}/user-guide/">User Guide</a>
5153
</li>
5254
<li class:active={isActive("/rules/", $page)}>
53-
<a sveltekit:prefetch href="{baseUrl}/rules/">Rules</a>
55+
<a href="{baseUrl}/rules/">Rules</a>
5456
</li>
5557
<li class:active={isActive("/playground/", $page)}>
56-
<a sveltekit:prefetch href="{baseUrl}/playground/">Playground</a>
58+
<a href="{baseUrl}/playground/">Playground</a>
5759
</li>
5860
</ul>
5961
<div class="nav-title">
60-
<a sveltekit:prefetch href="{baseUrl}/">
62+
<a href="{baseUrl}/">
6163
<img src={logo} alt="Logo" />eslint-plugin-svelte</a
6264
>
6365
</div>

docs-svelte-kit/src/routes/+layout.svelte

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333

3434
<SideMenu {sidebarOpen} hiddenMenu={frontmatter.hiddenMenu} />
3535

36+
<!-- svelte-ignore a11y-no-noninteractive-element-interactions -->
3637
<main
3738
class:hidden-menu={frontmatter.hiddenMenu}
3839
on:click={sidebarOpen ? resetSidebarOpen : null}

docs-svelte-kit/tools/generate-routes.mts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ const dirname = path.dirname(
88
),
99
)
1010

11-
/** Generate svelte kit routes files */
11+
/** Generate SvelteKit routes files */
1212
export default function generateRoutes(): void {
1313
const srcRoot = path.join(dirname, "../../docs")
1414
const distRoot = path.join(dirname, "../src/routes")

docs/rules.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ These rules relate to possible syntax or logic errors in Svelte code:
2323
| [svelte/no-dupe-style-properties](./rules/no-dupe-style-properties.md) | disallow duplicate style properties | :star: |
2424
| [svelte/no-dupe-use-directives](./rules/no-dupe-use-directives.md) | disallow duplicate `use:` directives | |
2525
| [svelte/no-dynamic-slot-name](./rules/no-dynamic-slot-name.md) | disallow dynamic slot name | :star::wrench: |
26-
| [svelte/no-export-load-in-svelte-module-in-kit-pages](./rules/no-export-load-in-svelte-module-in-kit-pages.md) | disallow exporting load functions in `*.svelte` module in Svelte Kit page components. | |
26+
| [svelte/no-export-load-in-svelte-module-in-kit-pages](./rules/no-export-load-in-svelte-module-in-kit-pages.md) | disallow exporting load functions in `*.svelte` module in SvelteKit page components. | |
2727
| [svelte/no-not-function-handler](./rules/no-not-function-handler.md) | disallow use of not function in event handler | :star: |
2828
| [svelte/no-object-in-text-mustaches](./rules/no-object-in-text-mustaches.md) | disallow objects in text mustache interpolation | :star: |
2929
| [svelte/no-reactive-reassign](./rules/no-reactive-reassign.md) | disallow reassigning reactive values | |
@@ -33,7 +33,7 @@ These rules relate to possible syntax or logic errors in Svelte code:
3333
| [svelte/require-store-callbacks-use-set-param](./rules/require-store-callbacks-use-set-param.md) | store callbacks must use `set` param | |
3434
| [svelte/require-store-reactive-access](./rules/require-store-reactive-access.md) | disallow to use of the store itself as an operand. Need to use $ prefix or get function. | :wrench: |
3535
| [svelte/valid-compile](./rules/valid-compile.md) | disallow warnings when compiling. | :star: |
36-
| [svelte/valid-prop-names-in-kit-pages](./rules/valid-prop-names-in-kit-pages.md) | disallow props other than data or errors in Svelte Kit page components. | |
36+
| [svelte/valid-prop-names-in-kit-pages](./rules/valid-prop-names-in-kit-pages.md) | disallow props other than data or errors in SvelteKit page components. | |
3737

3838
## Security Vulnerability
3939

@@ -81,6 +81,7 @@ These rules relate to style guidelines, and are therefore quite subjective:
8181
| [svelte/max-attributes-per-line](./rules/max-attributes-per-line.md) | enforce the maximum number of attributes per line | :wrench: |
8282
| [svelte/mustache-spacing](./rules/mustache-spacing.md) | enforce unified spacing in mustache | :wrench: |
8383
| [svelte/no-extra-reactive-curlies](./rules/no-extra-reactive-curlies.md) | disallow wrapping single reactive statements in curly braces | :bulb: |
84+
| [svelte/no-restricted-html-elements](./rules/no-restricted-html-elements.md) | disallow specific HTML elements | |
8485
| [svelte/no-spaces-around-equal-signs-in-attribute](./rules/no-spaces-around-equal-signs-in-attribute.md) | disallow spaces around equal signs in attribute | :wrench: |
8586
| [svelte/prefer-class-directive](./rules/prefer-class-directive.md) | require class directives instead of ternary expressions | :wrench: |
8687
| [svelte/prefer-style-directive](./rules/prefer-style-directive.md) | require style directives instead of style attribute | :wrench: |

docs/rules/no-export-load-in-svelte-module-in-kit-pages.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@
22
pageClass: "rule-details"
33
sidebarDepth: 0
44
title: "svelte/no-export-load-in-svelte-module-in-kit-pages"
5-
description: "disallow exporting load functions in `*.svelte` module in Svelte Kit page components."
5+
description: "disallow exporting load functions in `*.svelte` module in SvelteKit page components."
66
since: "v2.12.0"
77
---
88

99
# svelte/no-export-load-in-svelte-module-in-kit-pages
1010

11-
> disallow exporting load functions in `*.svelte` module in Svelte Kit page components.
11+
> disallow exporting load functions in `*.svelte` module in SvelteKit page components.
1212
1313
## :book: Rule Details
1414

Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
---
2+
pageClass: "rule-details"
3+
sidebarDepth: 0
4+
title: "svelte/no-restricted-html-elements"
5+
description: "disallow specific HTML elements"
6+
---
7+
8+
# svelte/no-restricted-html-elements
9+
10+
> disallow specific HTML elements
11+
12+
- :exclamation: <badge text="This rule has not been released yet." vertical="middle" type="error"> **_This rule has not been released yet._** </badge>
13+
14+
## :book: Rule Details
15+
16+
This rule reports to usage of resticted HTML elements.
17+
18+
<ESLintCodeBlock>
19+
20+
<!--eslint-skip-->
21+
22+
```svelte
23+
<script>
24+
/* eslint svelte/no-restricted-html-elements: ["error", "h1", "h2", "h3", "h4", "h5", "h6"] */
25+
</script>
26+
27+
<!-- ✓ GOOD -->
28+
<div>
29+
<p>Hi!</p>
30+
</div>
31+
32+
<!-- ✗ BAD -->
33+
<h1>foo</h1>
34+
35+
<div>
36+
<h2>bar</h2>
37+
</div>
38+
```
39+
40+
</ESLintCodeBlock>
41+
42+
---
43+
44+
<ESLintCodeBlock>
45+
46+
<!--eslint-skip-->
47+
48+
```svelte
49+
<script>
50+
/* eslint svelte/no-restricted-html-elements: ["error", { "elements": ["marquee"], "message": "Do not use deprecated HTML tags" }] */
51+
</script>
52+
53+
<!-- ✓ GOOD -->
54+
<div>
55+
<p>Hi!</p>
56+
</div>
57+
58+
<!-- ✗ BAD -->
59+
<marquee>foo</marquee>
60+
61+
<div>
62+
<marquee>bar</marquee>
63+
</div>
64+
```
65+
66+
</ESLintCodeBlock>
67+
68+
## :wrench: Options
69+
70+
This rule takes a list of strings, where each string is an HTML element name to be restricted:
71+
72+
```json
73+
{
74+
"svelte/no-restricted-html-elements": [
75+
"error",
76+
"h1",
77+
"h2",
78+
"h3",
79+
"h4",
80+
"h5",
81+
"h6"
82+
]
83+
}
84+
```
85+
86+
Alternatively, the rule also accepts objects.
87+
88+
```json
89+
{
90+
"svelte/no-restricted-html-elements": [
91+
"error",
92+
{
93+
"elements": ["h1", "h2", "h3", "h4", "h5", "h6"],
94+
"message": "Prefer use of our custom <Heading /> component"
95+
},
96+
{
97+
"elements": ["marquee"],
98+
"message": "Do not use deprecated HTML tags"
99+
}
100+
]
101+
}
102+
```
103+
104+
## :mag: Implementation
105+
106+
- [Rule source](https://github.com/sveltejs/eslint-plugin-svelte/blob/main/src/rules/no-restricted-html-elements.ts)
107+
- [Test source](https://github.com/sveltejs/eslint-plugin-svelte/blob/main/tests/src/rules/no-restricted-html-elements.ts)

docs/rules/valid-prop-names-in-kit-pages.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@
22
pageClass: "rule-details"
33
sidebarDepth: 0
44
title: "svelte/valid-prop-names-in-kit-pages"
5-
description: "disallow props other than data or errors in Svelte Kit page components."
5+
description: "disallow props other than data or errors in SvelteKit page components."
66
since: "v2.12.0"
77
---
88

99
# svelte/valid-prop-names-in-kit-pages
1010

11-
> disallow props other than data or errors in Svelte Kit page components.
11+
> disallow props other than data or errors in SvelteKit page components.
1212
1313
## :book: Rule Details
1414

0 commit comments

Comments
 (0)