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

chore: fix tests for Svelte 5 #2626

Merged
merged 1 commit into from
Dec 10, 2024
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ describe('Svelte Plugin', () => {
const diagnostic = Diagnostic.create(
Range.create(1, 0, 1, 21),
isSvelte5Plus
? '`<img>` element should have an alt attribute'
? '`<img>` element should have an alt attribute\nhttps://svelte.dev/e/a11y_missing_attribute'
: 'A11y: <img> element should have an alt attribute',
DiagnosticSeverity.Warning,
isSvelte5Plus ? 'a11y_missing_attribute' : 'a11y-missing-attribute',
Expand All @@ -54,10 +54,12 @@ describe('Svelte Plugin', () => {

const diagnostics = await plugin.getDiagnostics(document);
const diagnostic = Diagnostic.create(
Range.create(0, 10, 0, 18),
isSvelte5Plus ? 'Can only bind to state or props' : 'whatever is not declared',
Range.create(0, isSvelte5Plus ? 5 : 10, 0, 18),
isSvelte5Plus
? '`bind:whatever` is not a valid binding\nhttps://svelte.dev/e/bind_invalid_name'
: 'whatever is not declared',
DiagnosticSeverity.Error,
isSvelte5Plus ? 'bind_invalid_value' : 'binding-undeclared',
isSvelte5Plus ? 'bind_invalid_name' : 'binding-undeclared',
'svelte'
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -471,7 +471,8 @@ describe('SveltePlugin#getDiagnostics', () => {
{
range: { start: { line: 1, character: 15 }, end: { line: 1, character: 27 } },
message:
"Component has unused export property 'name'. If it is for external reference only, please consider using `export const name`",
"Component has unused export property 'name'. If it is for external reference only, please consider using `export const name`" +
(isSvelte5Plus ? '\nhttps://svelte.dev/e/export_let_unused' : ''),
severity: 2,
source: 'svelte',
code: isSvelte5Plus ? 'export_let_unused' : 'unused-export-let'
Expand All @@ -489,7 +490,7 @@ describe('SveltePlugin#getDiagnostics', () => {
{
range: { start: { line: 1, character: 4 }, end: { line: 1, character: 26 } },
message: isSvelte5Plus
? 'Reactive declarations only exist at the top level of the instance script'
? 'Reactive declarations only exist at the top level of the instance script\nhttps://svelte.dev/e/reactive_declaration_invalid_placement'
: '$: has no effect in a module script',
severity: 2,
source: 'svelte',
Expand All @@ -511,7 +512,8 @@ describe('SveltePlugin#getDiagnostics', () => {
{
code: isSvelte5Plus ? 'export_let_unused' : 'unused-export-let',
message:
"Component has unused export property 'unused1'. If it is for external reference only, please consider using `export const unused1`",
"Component has unused export property 'unused1'. If it is for external reference only, please consider using `export const unused1`" +
(isSvelte5Plus ? '\nhttps://svelte.dev/e/export_let_unused' : ''),
range: {
start: {
line: 5,
Expand All @@ -528,7 +530,8 @@ describe('SveltePlugin#getDiagnostics', () => {
{
code: isSvelte5Plus ? 'export_let_unused' : 'unused-export-let',
message:
"Component has unused export property 'unused2'. If it is for external reference only, please consider using `export const unused2`",
"Component has unused export property 'unused2'. If it is for external reference only, please consider using `export const unused2`" +
(isSvelte5Plus ? '\nhttps://svelte.dev/e/export_let_unused' : ''),
range: {
start: {
line: 6,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"range": { "start": { "line": 1, "character": 0 }, "end": { "line": 1, "character": 0 } },
"severity": 1,
"source": "js",
"message": "A component can have a single top-level `<style>` element",
"message": "A component can have a single top-level `<style>` element\nhttps://svelte.dev/e/style_duplicate",
"code": -1
}
]
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"range": { "start": { "line": 4, "character": 0 }, "end": { "line": 4, "character": 0 } },
"severity": 1,
"source": "ts",
"message": "`<svelte:element>` must have a 'this' attribute with a value",
"message": "`<svelte:element>` must have a 'this' attribute with a value\nhttps://svelte.dev/e/svelte_element_missing_this",
"code": -1
}
]
Loading