Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 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/thin-dryers-know.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'eslint-plugin-svelte': minor
---

Renamed `no-deprecated-raw-special-elements` in favor of `no-raw-special-elements`
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,6 @@ These rules relate to possible syntax or logic errors in Svelte code:
| Rule ID | Description | |
|:--------|:------------|:---|
| [svelte/infinite-reactive-loop](https://sveltejs.github.io/eslint-plugin-svelte/rules/infinite-reactive-loop/) | Svelte runtime prevents calling the same reactive statement twice in a microtask. But between different microtask, it doesn't prevent. | |
| [svelte/no-deprecated-raw-special-elements](https://sveltejs.github.io/eslint-plugin-svelte/rules/no-deprecated-raw-special-elements/) | Recommends not using raw special elements in Svelte versions previous to 5. | :wrench: |
| [svelte/no-dom-manipulating](https://sveltejs.github.io/eslint-plugin-svelte/rules/no-dom-manipulating/) | disallow DOM manipulating | |
| [svelte/no-dupe-else-if-blocks](https://sveltejs.github.io/eslint-plugin-svelte/rules/no-dupe-else-if-blocks/) | disallow duplicate conditions in `{#if}` / `{:else if}` chains | :star: |
| [svelte/no-dupe-on-directives](https://sveltejs.github.io/eslint-plugin-svelte/rules/no-dupe-on-directives/) | disallow duplicate `on:` directives | |
Expand All @@ -330,6 +329,7 @@ These rules relate to possible syntax or logic errors in Svelte code:
| [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. | |
| [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: |
| [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: |
| [svelte/no-raw-special-elements](https://sveltejs.github.io/eslint-plugin-svelte/rules/no-raw-special-elements/) | Checks for invalid raw HTML elements | :wrench: |
| [svelte/no-reactive-reassign](https://sveltejs.github.io/eslint-plugin-svelte/rules/no-reactive-reassign/) | disallow reassigning reactive values | |
| [svelte/no-shorthand-style-property-overrides](https://sveltejs.github.io/eslint-plugin-svelte/rules/no-shorthand-style-property-overrides/) | disallow shorthand style properties that override related longhand properties | :star: |
| [svelte/no-store-async](https://sveltejs.github.io/eslint-plugin-svelte/rules/no-store-async/) | disallow using async/await inside svelte stores because it causes issues with the auto-unsubscribing features | |
Expand Down
2 changes: 1 addition & 1 deletion docs/rules.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ These rules relate to possible syntax or logic errors in Svelte code:
| Rule ID | Description | |
| :------------------------------------------------------------------------------------------------------------- | :------------------------------------------------------------------------------------------------------------------------------------- | :------------- |
| [svelte/infinite-reactive-loop](./rules/infinite-reactive-loop.md) | Svelte runtime prevents calling the same reactive statement twice in a microtask. But between different microtask, it doesn't prevent. | |
| [svelte/no-deprecated-raw-special-elements](./rules/no-deprecated-raw-special-elements.md) | Recommends not using raw special elements in Svelte versions previous to 5. | :wrench: |
| [svelte/no-dom-manipulating](./rules/no-dom-manipulating.md) | disallow DOM manipulating | |
| [svelte/no-dupe-else-if-blocks](./rules/no-dupe-else-if-blocks.md) | disallow duplicate conditions in `{#if}` / `{:else if}` chains | :star: |
| [svelte/no-dupe-on-directives](./rules/no-dupe-on-directives.md) | disallow duplicate `on:` directives | |
Expand All @@ -27,6 +26,7 @@ These rules relate to possible syntax or logic errors in Svelte code:
| [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. | |
| [svelte/no-not-function-handler](./rules/no-not-function-handler.md) | disallow use of not function in event handler | :star: |
| [svelte/no-object-in-text-mustaches](./rules/no-object-in-text-mustaches.md) | disallow objects in text mustache interpolation | :star: |
| [svelte/no-raw-special-elements](./rules/no-raw-special-elements.md) | Checks for invalid raw HTML elements | :wrench: |
| [svelte/no-reactive-reassign](./rules/no-reactive-reassign.md) | disallow reassigning reactive values | |
| [svelte/no-shorthand-style-property-overrides](./rules/no-shorthand-style-property-overrides.md) | disallow shorthand style properties that override related longhand properties | :star: |
| [svelte/no-store-async](./rules/no-store-async.md) | disallow using async/await inside svelte stores because it causes issues with the auto-unsubscribing features | |
Expand Down
Original file line number Diff line number Diff line change
@@ -1,26 +1,26 @@
---
pageClass: 'rule-details'
sidebarDepth: 0
title: 'svelte/no-deprecated-raw-special-elements'
description: 'Recommends not using raw special elements in Svelte versions previous to 5.'
title: 'svelte/no-raw-special-elements'
description: 'Checks for invalid raw HTML elements'
since: 'v3.0.0-next.1'
---

# svelte/no-deprecated-raw-special-elements
# svelte/no-raw-special-elements

> Recommends not using raw special elements in Svelte versions previous to 5.
> Checks for invalid raw HTML elements

- :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

This rule reports the usage of `head`, `body`, `window`, `document`, `element` and `options` HTML elements. These elements were valid in in versions proior to 5, but since Svelte 5 they must be used with `svelte:`.
This rule reports the usage of `head`, `body`, `window`, `document`, `element` and `options` HTML elements. These elements are not valid in Svelte, despite them working in versions previous to v5. Such elements must be prefixed with `svelte:`.

<!--eslint-skip-->

```svelte
<script>
/* eslint svelte/no-deprecated-raw-special-elements: "error" */
/* eslint svelte/no-raw-special-elements: "error" */
</script>

<!-- ✓ GOOD -->
Expand Down Expand Up @@ -48,5 +48,5 @@ This rule was introduced in eslint-plugin-svelte v3.0.0-next.1

## :mag: Implementation

- [Rule source](https://github.com/sveltejs/eslint-plugin-svelte/blob/main/packages/eslint-plugin-svelte/src/rules/no-deprecated-raw-special-elements.ts)
- [Test source](https://github.com/sveltejs/eslint-plugin-svelte/blob/main/packages/eslint-plugin-svelte/tests/src/rules/no-deprecated-raw-special-elements.ts)
- [Rule source](https://github.com/sveltejs/eslint-plugin-svelte/blob/main/packages/eslint-plugin-svelte/src/rules/no-raw-special-elements.ts)
- [Test source](https://github.com/sveltejs/eslint-plugin-svelte/blob/main/packages/eslint-plugin-svelte/tests/src/rules/no-raw-special-elements.ts)
10 changes: 5 additions & 5 deletions packages/eslint-plugin-svelte/src/rule-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,11 +104,6 @@ export interface RuleOptions {
* @see https://sveltejs.github.io/eslint-plugin-svelte/rules/no-at-html-tags/
*/
'svelte/no-at-html-tags'?: Linter.RuleEntry<[]>
/**
* Recommends not using raw special elements in Svelte versions previous to 5.
* @see https://sveltejs.github.io/eslint-plugin-svelte/rules/no-deprecated-raw-special-elements/
*/
'svelte/no-deprecated-raw-special-elements'?: Linter.RuleEntry<[]>
/**
* disallow DOM manipulating
* @see https://sveltejs.github.io/eslint-plugin-svelte/rules/no-dom-manipulating/
Expand Down Expand Up @@ -195,6 +190,11 @@ export interface RuleOptions {
* @see https://sveltejs.github.io/eslint-plugin-svelte/rules/no-object-in-text-mustaches/
*/
'svelte/no-object-in-text-mustaches'?: Linter.RuleEntry<[]>
/**
* Checks for invalid raw HTML elements
* @see https://sveltejs.github.io/eslint-plugin-svelte/rules/no-raw-special-elements/
*/
'svelte/no-raw-special-elements'?: Linter.RuleEntry<[]>
/**
* it's not necessary to define functions in reactive statements
* @see https://sveltejs.github.io/eslint-plugin-svelte/rules/no-reactive-functions/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@
const INVALID_HTML_ELEMENTS = ['head', 'body', 'window', 'document', 'element', 'options'];
const VALID_PREFIX = 'svelte:';

export default createRule('no-deprecated-raw-special-elements', {
export default createRule('no-raw-special-elements', {
meta: {
docs: {
description: 'Recommends not using raw special elements in Svelte versions previous to 5.',
description: 'Checks for invalid raw HTML elements',
category: 'Possible Errors',
// TODO: Switch to recommended in the major version

Check warning on line 12 in packages/eslint-plugin-svelte/src/rules/no-raw-special-elements.ts

View workflow job for this annotation

GitHub Actions / lint

Unexpected 'todo' comment: 'TODO: Switch to recommended in the major...'
recommended: false
},
schema: [],
Expand Down
4 changes: 2 additions & 2 deletions packages/eslint-plugin-svelte/src/utils/rules.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import maxAttributesPerLine from '../rules/max-attributes-per-line.js';
import mustacheSpacing from '../rules/mustache-spacing.js';
import noAtDebugTags from '../rules/no-at-debug-tags.js';
import noAtHtmlTags from '../rules/no-at-html-tags.js';
import noDeprecatedRawSpecialElements from '../rules/no-deprecated-raw-special-elements.js';
import noDomManipulating from '../rules/no-dom-manipulating.js';
import noDupeElseIfBlocks from '../rules/no-dupe-else-if-blocks.js';
import noDupeOnDirectives from '../rules/no-dupe-on-directives.js';
Expand All @@ -38,6 +37,7 @@ import noInspect from '../rules/no-inspect.js';
import noNavigationWithoutBase from '../rules/no-navigation-without-base.js';
import noNotFunctionHandler from '../rules/no-not-function-handler.js';
import noObjectInTextMustaches from '../rules/no-object-in-text-mustaches.js';
import noRawSpecialElements from '../rules/no-raw-special-elements.js';
import noReactiveFunctions from '../rules/no-reactive-functions.js';
import noReactiveLiterals from '../rules/no-reactive-literals.js';
import noReactiveReassign from '../rules/no-reactive-reassign.js';
Expand Down Expand Up @@ -91,7 +91,6 @@ export const rules = [
mustacheSpacing,
noAtDebugTags,
noAtHtmlTags,
noDeprecatedRawSpecialElements,
noDomManipulating,
noDupeElseIfBlocks,
noDupeOnDirectives,
Expand All @@ -109,6 +108,7 @@ export const rules = [
noNavigationWithoutBase,
noNotFunctionHandler,
noObjectInTextMustaches,
noRawSpecialElements,
noReactiveFunctions,
noReactiveLiterals,
noReactiveReassign,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { RuleTester } from '../../utils/eslint-compat.js';
import rule from '../../../src/rules/no-deprecated-raw-special-elements.js';
import rule from '../../../src/rules/no-raw-special-elements.js';
import { loadTestCases } from '../../utils/utils.js';

const tester = new RuleTester({
Expand All @@ -10,7 +10,7 @@ const tester = new RuleTester({
});

tester.run(
'no-deprecated-raw-special-elements',
'no-raw-special-elements',
rule as any,
loadTestCases('no-deprecated-raw-special-elements')
loadTestCases('no-raw-special-elements')
);
Loading