Skip to content

Commit 29b1315

Browse files
authored
feat: add fixer for no-at-debug-tags (#1164)
1 parent 2c79cb4 commit 29b1315

File tree

7 files changed

+52
-6
lines changed

7 files changed

+52
-6
lines changed

Diff for: .changeset/weak-crews-shake.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'eslint-plugin-svelte': minor
3+
---
4+
5+
Added a suggestion for `no-at-debug-tags` rule which removes the tags

Diff for: README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,7 @@ These rules relate to better ways of doing things to help you avoid problems:
294294
|:--------|:------------|:---|
295295
| [svelte/block-lang](https://sveltejs.github.io/eslint-plugin-svelte/rules/block-lang/) | disallows the use of languages other than those specified in the configuration for the lang attribute of `<script>` and `<style>` blocks. | :bulb: |
296296
| [svelte/button-has-type](https://sveltejs.github.io/eslint-plugin-svelte/rules/button-has-type/) | disallow usage of button without an explicit type attribute | |
297-
| [svelte/no-at-debug-tags](https://sveltejs.github.io/eslint-plugin-svelte/rules/no-at-debug-tags/) | disallow the use of `{@debug}` | :star: |
297+
| [svelte/no-at-debug-tags](https://sveltejs.github.io/eslint-plugin-svelte/rules/no-at-debug-tags/) | disallow the use of `{@debug}` | :star::bulb: |
298298
| [svelte/no-ignored-unsubscribe](https://sveltejs.github.io/eslint-plugin-svelte/rules/no-ignored-unsubscribe/) | disallow ignoring the unsubscribe method returned by the `subscribe()` on Svelte stores. | |
299299
| [svelte/no-immutable-reactive-statements](https://sveltejs.github.io/eslint-plugin-svelte/rules/no-immutable-reactive-statements/) | disallow reactive statements that don't reference reactive values. | :star: |
300300
| [svelte/no-inline-styles](https://sveltejs.github.io/eslint-plugin-svelte/rules/no-inline-styles/) | disallow attributes and directives that produce inline styles | |

Diff for: docs/rules.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ These rules relate to better ways of doing things to help you avoid problems:
5151
| :--------------------------------------------------------------------------------------- | :---------------------------------------------------------------------------------------------------------------------------------------- | :------------- |
5252
| [svelte/block-lang](./rules/block-lang.md) | disallows the use of languages other than those specified in the configuration for the lang attribute of `<script>` and `<style>` blocks. | :bulb: |
5353
| [svelte/button-has-type](./rules/button-has-type.md) | disallow usage of button without an explicit type attribute | |
54-
| [svelte/no-at-debug-tags](./rules/no-at-debug-tags.md) | disallow the use of `{@debug}` | :star: |
54+
| [svelte/no-at-debug-tags](./rules/no-at-debug-tags.md) | disallow the use of `{@debug}` | :star::bulb: |
5555
| [svelte/no-ignored-unsubscribe](./rules/no-ignored-unsubscribe.md) | disallow ignoring the unsubscribe method returned by the `subscribe()` on Svelte stores. | |
5656
| [svelte/no-immutable-reactive-statements](./rules/no-immutable-reactive-statements.md) | disallow reactive statements that don't reference reactive values. | :star: |
5757
| [svelte/no-inline-styles](./rules/no-inline-styles.md) | disallow attributes and directives that produce inline styles | |

Diff for: docs/rules/no-at-debug-tags.md

+1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ since: 'v0.0.1'
1111
> disallow the use of `{@debug}`
1212
1313
- :gear: This rule is included in `"plugin:svelte/recommended"`.
14+
- :bulb: Some problems reported by this rule are manually fixable by editor [suggestions](https://eslint.org/docs/developer-guide/working-with-rules#providing-suggestions).
1415

1516
## :book: Rule Details
1617

Diff for: packages/eslint-plugin-svelte/src/rules/no-at-debug-tags.ts

+10-2
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,11 @@ export default createRule('no-at-debug-tags', {
88
recommended: true,
99
default: 'warn'
1010
},
11+
hasSuggestions: true,
1112
schema: [],
1213
messages: {
13-
unexpected: 'Unexpected `{@debug}`.'
14+
unexpected: 'Unexpected `{@debug}`.',
15+
suggestRemove: 'Remove `{@debug}` from the source'
1416
},
1517
type: 'problem'
1618
},
@@ -19,7 +21,13 @@ export default createRule('no-at-debug-tags', {
1921
SvelteDebugTag(node) {
2022
context.report({
2123
node,
22-
messageId: 'unexpected'
24+
messageId: 'unexpected',
25+
suggest: [
26+
{
27+
messageId: 'suggestRemove',
28+
fix: (fixer) => fixer.remove(node)
29+
}
30+
]
2331
});
2432
}
2533
};
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,20 @@
11
- message: Unexpected `{@debug}`.
22
line: 11
33
column: 1
4-
suggestions: null
4+
suggestions:
5+
- desc: Remove `{@debug}` from the source
6+
messageId: suggestRemove
7+
output: |
8+
<script>
9+
let user = {
10+
firstname: 'Ada',
11+
lastname: 'Lovelace'
12+
};
13+
</script>
14+
15+
<input bind:value={user.firstname} />
16+
<input bind:value={user.lastname} />
17+
18+
19+
20+
<h1>Hello {user.firstname}!</h1>
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,20 @@
11
- message: Unexpected `{@debug}`.
22
line: 11
33
column: 1
4-
suggestions: null
4+
suggestions:
5+
- desc: Remove `{@debug}` from the source
6+
messageId: suggestRemove
7+
output: |
8+
<script>
9+
let user = {
10+
firstname: 'Ada',
11+
lastname: 'Lovelace'
12+
};
13+
</script>
14+
15+
<input bind:value={user.firstname} />
16+
<input bind:value={user.lastname} />
17+
18+
19+
20+
<h1>Hello {user.firstname}!</h1>

0 commit comments

Comments
 (0)