Skip to content
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

breaking: Redesigned ESLint config #957

Closed
wants to merge 24 commits into from
Closed
Show file tree
Hide file tree
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
5 changes: 5 additions & 0 deletions .changeset/mean-garlics-march.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'eslint-plugin-svelte': major
---

breaking: redesigned eslint config
1 change: 1 addition & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"editor.defaultFormatter": "esbenp.prettier-vscode",
"editor.codeActionsOnSave": {
"source.fixAll": "explicit",
"source.fixAll.eslint": "explicit",
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ESLint fix didn’t work on save for some reason, but it started working after adding this.

"source.fixAll.stylelint": "explicit"
},
"svelte.plugin.typescript.diagnostics.enable": false,
Expand Down
82 changes: 41 additions & 41 deletions README.md

Large diffs are not rendered by default.

14 changes: 8 additions & 6 deletions docs-svelte-kit/src/lib/footer/Footer.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@
export let frontmatter = {};

let prev, next;
$: ({
url: { pathname }
} = $page);
$: {
let prevItem, currItem;
for (const item of iterateMenuItem($menuItems)) {
Expand Down Expand Up @@ -39,10 +42,10 @@

<footer class:hidden-menu={frontmatter.hiddenMenu}>
<div class="footer-tools">
<div class="edit-link">
<div>
<a
href="https://github.com/sveltejs/eslint-plugin-svelte/edit/main/docs/{markdownPath(
$page.url.pathname
pathname
)}"
target="_blank"
rel="noopener noreferrer">Edit this page</a
Expand All @@ -57,7 +60,6 @@
viewBox="0 0 100 100"
width="15"
height="15"
class="icon outbound"
><path
fill="currentColor"
d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"
Expand All @@ -71,14 +73,14 @@
</div>
{#if fileInfo.lastUpdated}
<div class="last-updated">
<span class="prefix">Last Updated:</span>
<span class="time">{fileInfo.lastUpdated}</span>
<span>Last Updated:</span>
<span>{fileInfo.lastUpdated}</span>
</div>
{/if}
</div>
<div class="footer-move">
{#if prev}
<span class="prev">←<a href="{baseUrl}{prev.path}">{prev.title}</a></span>
<span>←<a href="{baseUrl}{prev.path}">{prev.title}</a></span>
{/if}
{#if next}
<span class="next"><a href="{baseUrl}{next.path}">{next.title}</a>→ </span>
Expand Down
16 changes: 2 additions & 14 deletions docs-svelte-kit/src/lib/header/Header.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,7 @@
on:click={handleToggleSidebar}
on:keydown={(e) => (e.code === 'Enter' || e.code === 'Space') && handleToggleSidebar()}
>
<svg
xmlns="http://www.w3.org/2000/svg"
aria-hidden="true"
role="img"
viewBox="0 0 448 512"
class="icon"
>
<svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" role="img" viewBox="0 0 448 512">
<path
fill="currentColor"
d="M436 124H12c-6.627 0-12-5.373-12-12V80c0-6.627 5.373-12 12-12h424c6.627 0 12 5.373 12 12v32c0 6.627-5.373 12-12 12zm0 160H12c-6.627 0-12-5.373-12-12v-32c0-6.627 5.373-12 12-12h424c6.627 0 12 5.373 12 12v32c0 6.627-5.373 12-12 12zm0 160H12c-6.627 0-12-5.373-12-12v-32c0-6.627 5.373-12 12-12h424c6.627 0 12 5.373 12 12v32c0 6.627-5.373 12-12 12z"
Expand Down Expand Up @@ -79,13 +73,7 @@
rel="noopener noreferrer"
aria-label="GitHub"
>
<svg
version="1.1"
width="16"
height="16"
viewBox="0 0 16 16"
class="octicon octicon-mark-github"
aria-hidden="true"
<svg version="1.1" width="16" height="16" viewBox="0 0 16 16" aria-hidden="true"
><path
style:fill="#2c3e50"
fill-rule="evenodd"
Expand Down
15 changes: 11 additions & 4 deletions docs-svelte-kit/src/lib/sidemenu/UlMenu.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,16 @@
import { base as baseUrl } from '$app/paths';
export let children;
export let level = 1;

$: sidebarMenuLevelClass = `sidebar-menu--level${level}`;

$: ({
url: { pathname }
} = $page);
</script>

<ul class="sidebar-menu sidebar-menu--level{level}">
{#each children as item}
<ul class={sidebarMenuLevelClass}>
{#each children as item (item)}
<li
class="sidebar-menu-item"
class:active={item.active || (item.path && isActive(item.path, $page))}
Expand All @@ -16,9 +22,10 @@
<a
class="sidebar-menu-item-title"
class:active={item.active || (item.path && isActive(item.path, $page))}
href="{baseUrl}{item.path || `${stripBaseUrl($page.url.pathname)}#${item.id}`}"
>{item.title}</a
href="{baseUrl}{item.path || `${stripBaseUrl(pathname)}#${item.id}`}"
>
{item.title}
</a>
{:else}
<span class="sidebar-menu-item-title">{item.title}</span>
{/if}
Expand Down
9 changes: 7 additions & 2 deletions docs-svelte-kit/src/routes/+error.svelte
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
<script>
import { base as baseUrl } from '$app/paths';
import { page } from '$app/stores';

$: ({
status,
error: { message }
} = $page);
</script>

<h1>{$page.status}</h1>
<h1>{status}</h1>
<blockquote>
<p>{$page.error.message}</p>
<p>{message}</p>
<p>Take me <a href="{baseUrl}/">home</a></p>
</blockquote>
160 changes: 81 additions & 79 deletions docs/rules.md

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/rules/comment-directive.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ since: 'v0.0.13'

> support comment-directives in HTML template

- :gear: This rule is included in `"plugin:svelte/base"` and `"plugin:svelte/recommended"`.
- :gear: This rule is included in all of `"plugin:svelte/base"`, `"plugin:svelte/recommended"`, `"plugin:svelte/recommended_svelte5_without_legacy"` and `"plugin:svelte/recommended_svelte3_4"` configuration.

Sole purpose of this rule is to provide `eslint-disable` functionality in the template HTML.
It supports usage of the following comments:
Expand Down
2 changes: 2 additions & 0 deletions docs/rules/derived-has-same-inputs-outputs.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ since: 'v2.8.0'

> derived store should use same variable names between values and callback

- :gear: This rule is included in all of `"plugin:svelte/recommended"`, `"plugin:svelte/recommended_svelte5_without_legacy"` and `"plugin:svelte/recommended_svelte3_4"` configuration.

## :book: Rule Details

This rule reports where variable names and callback function's argument names are different.
Expand Down
2 changes: 2 additions & 0 deletions docs/rules/infinite-reactive-loop.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ since: 'v2.16.0'

> Svelte runtime prevents calling the same reactive statement twice in a microtask. But between different microtask, it doesn't prevent.

- :gear: This rule is included in `"plugin:svelte/recommended"` and `"plugin:svelte/recommended_svelte3_4"` configuration.

## :book: Rule Details

Svelte runtime prevents calling the same reactive statement twice in a microtask.<br/>
Expand Down
2 changes: 1 addition & 1 deletion docs/rules/no-at-debug-tags.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ since: 'v0.0.1'

> disallow the use of `{@debug}`

- :gear: This rule is included in `"plugin:svelte/recommended"`.
- :gear: This rule is included in all of `"plugin:svelte/recommended"`, `"plugin:svelte/recommended_svelte5_without_legacy"` and `"plugin:svelte/recommended_svelte3_4"` configuration.

## :book: Rule Details

Expand Down
2 changes: 1 addition & 1 deletion docs/rules/no-at-html-tags.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ since: 'v0.0.1'

> disallow use of `{@html}` to prevent XSS attack

- :gear: This rule is included in `"plugin:svelte/recommended"`.
- :gear: This rule is included in all of `"plugin:svelte/recommended"`, `"plugin:svelte/recommended_svelte5_without_legacy"` and `"plugin:svelte/recommended_svelte3_4"` configuration.

## :book: Rule Details

Expand Down
1 change: 1 addition & 0 deletions docs/rules/no-deprecated-raw-special-elements.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ since: 'v3.0.0-next.1'

> Recommends not using raw special elements in Svelte versions previous to 5.

- :gear: This rule is included in `"plugin:svelte/recommended"` and `"plugin:svelte/recommended_svelte5_without_legacy"` configuration.
- :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.

## :book: Rule Details
Expand Down
2 changes: 2 additions & 0 deletions docs/rules/no-dom-manipulating.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ since: 'v2.13.0'

> disallow DOM manipulating

- :gear: This rule is included in all of `"plugin:svelte/recommended"`, `"plugin:svelte/recommended_svelte5_without_legacy"` and `"plugin:svelte/recommended_svelte3_4"` configuration.

## :book: Rule Details

In general, DOM manipulating should delegate to Svelte runtime. If you manipulate the DOM directly, the Svelte runtime may confuse because there is a difference between the actual DOM and the Svelte runtime's expected DOM.
Expand Down
2 changes: 1 addition & 1 deletion docs/rules/no-dupe-else-if-blocks.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ since: 'v0.0.1'

> disallow duplicate conditions in `{#if}` / `{:else if}` chains

- :gear: This rule is included in `"plugin:svelte/recommended"`.
- :gear: This rule is included in all of `"plugin:svelte/recommended"`, `"plugin:svelte/recommended_svelte5_without_legacy"` and `"plugin:svelte/recommended_svelte3_4"` configuration.

## :book: Rule Details

Expand Down
2 changes: 2 additions & 0 deletions docs/rules/no-dupe-on-directives.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ since: 'v2.14.0'

> disallow duplicate `on:` directives

- :gear: This rule is included in `"plugin:svelte/recommended_svelte3_4"` configuration.

## :book: Rule Details

We can define any number of `on:` directive with the same event name, but duplicate directives with the exact same event name and expression are probably a mistake.
Expand Down
2 changes: 1 addition & 1 deletion docs/rules/no-dupe-style-properties.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ since: 'v0.31.0'

> disallow duplicate style properties

- :gear: This rule is included in `"plugin:svelte/recommended"`.
- :gear: This rule is included in all of `"plugin:svelte/recommended"`, `"plugin:svelte/recommended_svelte5_without_legacy"` and `"plugin:svelte/recommended_svelte3_4"` configuration.

## :book: Rule Details

Expand Down
2 changes: 2 additions & 0 deletions docs/rules/no-dupe-use-directives.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ since: 'v2.14.0'

> disallow duplicate `use:` directives

- :gear: This rule is included in all of `"plugin:svelte/recommended"`, `"plugin:svelte/recommended_svelte5_without_legacy"` and `"plugin:svelte/recommended_svelte3_4"` configuration.

## :book: Rule Details

We can define any number of `use:` directive with the same action, but duplicate directives with the exact same action and expression are probably a mistake.
Expand Down
2 changes: 1 addition & 1 deletion docs/rules/no-dynamic-slot-name.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ since: 'v0.14.0'

> disallow dynamic slot name

- :gear: This rule is included in `"plugin:svelte/recommended"`.
- :gear: This rule is included in `"plugin:svelte/recommended"` and `"plugin:svelte/recommended_svelte3_4"` configuration.
- :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.

## :book: Rule Details
Expand Down
1 change: 1 addition & 0 deletions docs/rules/no-extra-reactive-curlies.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ since: 'v2.4.0'

> disallow wrapping single reactive statements in curly braces

- :gear: This rule is included in `"plugin:svelte/recommended"` and `"plugin:svelte/recommended_svelte3_4"` configuration.
- :bulb: Some problems reported by this rule are manually fixable by editor [suggestions](https://eslint.org/docs/developer-guide/working-with-rules#providing-suggestions).

## :book: Rule Details
Expand Down
2 changes: 2 additions & 0 deletions docs/rules/no-ignored-unsubscribe.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ since: 'v2.34.0'

> disallow ignoring the unsubscribe method returned by the `subscribe()` on Svelte stores.

- :gear: This rule is included in all of `"plugin:svelte/recommended"`, `"plugin:svelte/recommended_svelte5_without_legacy"` and `"plugin:svelte/recommended_svelte3_4"` configuration.

## :book: Rule Details

This rule fails if an "unsubscriber" returned by call to `subscribe()` is neither assigned to a variable or property or passed to a function.
Expand Down
2 changes: 2 additions & 0 deletions docs/rules/no-immutable-reactive-statements.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ since: 'v2.27.0'

> disallow reactive statements that don't reference reactive values.

- :gear: This rule is included in `"plugin:svelte/recommended"` and `"plugin:svelte/recommended_svelte3_4"` configuration.

## :book: Rule Details

This rule reports if all variables referenced in reactive statements are immutable. That reactive statement is immutable and not reactive.
Expand Down
2 changes: 1 addition & 1 deletion docs/rules/no-inner-declarations.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ since: 'v0.0.8'

> disallow variable or `function` declarations in nested blocks

- :gear: This rule is included in `"plugin:svelte/recommended"`.
- :gear: This rule is included in all of `"plugin:svelte/recommended"`, `"plugin:svelte/recommended_svelte5_without_legacy"` and `"plugin:svelte/recommended_svelte3_4"` configuration.

## :book: Rule Details

Expand Down
2 changes: 2 additions & 0 deletions docs/rules/no-inspect.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ since: 'v2.45.0'

> Warns against the use of `$inspect` directive

- :gear: This rule is included in `"plugin:svelte/recommended"` and `"plugin:svelte/recommended_svelte5_without_legacy"` configuration.

## :book: Rule Details

This rule reports usages of `$inspect`.
Expand Down
2 changes: 1 addition & 1 deletion docs/rules/no-not-function-handler.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ since: 'v0.5.0'

> disallow use of not function in event handler

- :gear: This rule is included in `"plugin:svelte/recommended"`.
- :gear: This rule is included in `"plugin:svelte/recommended_svelte3_4"` configuration.

## :book: Rule Details

Expand Down
2 changes: 1 addition & 1 deletion docs/rules/no-object-in-text-mustaches.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ since: 'v0.5.0'

> disallow objects in text mustache interpolation

- :gear: This rule is included in `"plugin:svelte/recommended"`.
- :gear: This rule is included in all of `"plugin:svelte/recommended"`, `"plugin:svelte/recommended_svelte5_without_legacy"` and `"plugin:svelte/recommended_svelte3_4"` configuration.

## :book: Rule Details

Expand Down
1 change: 1 addition & 0 deletions docs/rules/no-reactive-functions.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ since: 'v2.5.0'

> it's not necessary to define functions in reactive statements

- :gear: This rule is included in `"plugin:svelte/recommended"` and `"plugin:svelte/recommended_svelte3_4"` configuration.
- :bulb: Some problems reported by this rule are manually fixable by editor [suggestions](https://eslint.org/docs/developer-guide/working-with-rules#providing-suggestions).

## :book: Rule Details
Expand Down
1 change: 1 addition & 0 deletions docs/rules/no-reactive-literals.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ since: 'v2.4.0'

> don't assign literal values in reactive statements

- :gear: This rule is included in `"plugin:svelte/recommended"` and `"plugin:svelte/recommended_svelte3_4"` configuration.
- :bulb: Some problems reported by this rule are manually fixable by editor [suggestions](https://eslint.org/docs/developer-guide/working-with-rules#providing-suggestions).

## :book: Rule Details
Expand Down
2 changes: 2 additions & 0 deletions docs/rules/no-reactive-reassign.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ since: 'v2.27.0'

> disallow reassigning reactive values

- :gear: This rule is included in `"plugin:svelte/recommended"` and `"plugin:svelte/recommended_svelte3_4"` configuration.

## :book: Rule Details

This rule aims to prevent unintended behavior caused by modification or reassignment of reactive values.
Expand Down
2 changes: 1 addition & 1 deletion docs/rules/no-shorthand-style-property-overrides.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ since: 'v0.31.0'

> disallow shorthand style properties that override related longhand properties

- :gear: This rule is included in `"plugin:svelte/recommended"`.
- :gear: This rule is included in all of `"plugin:svelte/recommended"`, `"plugin:svelte/recommended_svelte5_without_legacy"` and `"plugin:svelte/recommended_svelte3_4"` configuration.

## :book: Rule Details

Expand Down
2 changes: 2 additions & 0 deletions docs/rules/no-store-async.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ since: 'v2.7.0'

> disallow using async/await inside svelte stores because it causes issues with the auto-unsubscribing features

- :gear: This rule is included in all of `"plugin:svelte/recommended"`, `"plugin:svelte/recommended_svelte5_without_legacy"` and `"plugin:svelte/recommended_svelte3_4"` configuration.

## :book: Rule Details

This rule reports all uses of async/await inside svelte stores.
Expand Down
2 changes: 2 additions & 0 deletions docs/rules/no-svelte-internal.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ since: 'v2.39.0'

> svelte/internal will be removed in Svelte 6.

- :gear: This rule is included in all of `"plugin:svelte/recommended"`, `"plugin:svelte/recommended_svelte5_without_legacy"` and `"plugin:svelte/recommended_svelte3_4"` configuration.

## :book: Rule Details

This rule reports the use of the deprecated API `svelte/internal` and `svelte/internal/xxx`. `svelte/internal` is deprecated in Svelte 5. And it will be deleted in Svelte 6. These APIs can change in breaking ways at any time without notice.
Expand Down
2 changes: 1 addition & 1 deletion docs/rules/no-unknown-style-directive-property.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ since: 'v0.31.0'

> disallow unknown `style:property`

- :gear: This rule is included in `"plugin:svelte/recommended"`.
- :gear: This rule is included in all of `"plugin:svelte/recommended"`, `"plugin:svelte/recommended_svelte5_without_legacy"` and `"plugin:svelte/recommended_svelte3_4"` configuration.

## :book: Rule Details

Expand Down
2 changes: 2 additions & 0 deletions docs/rules/no-unused-class-name.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ since: 'v2.31.0'

> disallow the use of a class in the template without a corresponding style

- :gear: This rule is included in all of `"plugin:svelte/recommended"`, `"plugin:svelte/recommended_svelte5_without_legacy"` and `"plugin:svelte/recommended_svelte3_4"` configuration.

## :book: Rule Details

This rule is aimed at reducing unused classes in the HTML template. While `svelte-check` will produce the `css-unused-selector` if your `<style>` block includes any classes that aren't used in the template, this rule works the other way around - it reports cases wehre the template contains classes that aren't referred to in the `<style>` block.
Expand Down
2 changes: 1 addition & 1 deletion docs/rules/no-unused-svelte-ignore.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ since: 'v0.19.0'

> disallow unused svelte-ignore comments

- :gear: This rule is included in `"plugin:svelte/recommended"`.
- :gear: This rule is included in all of `"plugin:svelte/recommended"`, `"plugin:svelte/recommended_svelte5_without_legacy"` and `"plugin:svelte/recommended_svelte3_4"` configuration.

## :book: Rule Details

Expand Down
1 change: 1 addition & 0 deletions docs/rules/no-useless-mustaches.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ since: 'v0.0.4'

> disallow unnecessary mustache interpolations

- :gear: This rule is included in all of `"plugin:svelte/recommended"`, `"plugin:svelte/recommended_svelte5_without_legacy"` and `"plugin:svelte/recommended_svelte3_4"` configuration.
- :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.

## :book: Rule Details
Expand Down
Loading
Loading