diff --git a/.changeset/wicked-swans-work.md b/.changeset/wicked-swans-work.md
new file mode 100644
index 0000000000..643fed2a97
--- /dev/null
+++ b/.changeset/wicked-swans-work.md
@@ -0,0 +1,5 @@
+---
+"@inlang/paraglide-js-adapter-sveltekit": patch
+---
+
+fix: Disable some lint errors when internally rewriting links with the spread syntax to avoid annoying logs (https://discord.com/channels/897438559458430986/1070750156644962434/1212320293578874880)
diff --git a/inlang/source-code/paraglide/paraglide-js-adapter-sveltekit/src/test.svelte b/inlang/source-code/paraglide/paraglide-js-adapter-sveltekit/src/test.svelte
new file mode 100644
index 0000000000..4db4a6c04c
--- /dev/null
+++ b/inlang/source-code/paraglide/paraglide-js-adapter-sveltekit/src/test.svelte
@@ -0,0 +1,2 @@
+ASD
+ASD
\ No newline at end of file
diff --git a/inlang/source-code/paraglide/paraglide-js-adapter-sveltekit/src/vite/preprocessor/index.test.ts b/inlang/source-code/paraglide/paraglide-js-adapter-sveltekit/src/vite/preprocessor/index.test.ts
index 4741baaeb8..f70cee104d 100644
--- a/inlang/source-code/paraglide/paraglide-js-adapter-sveltekit/src/vite/preprocessor/index.test.ts
+++ b/inlang/source-code/paraglide/paraglide-js-adapter-sveltekit/src/vite/preprocessor/index.test.ts
@@ -109,17 +109,17 @@ describe.concurrent("preprocessor", () => {
- Test`
+ content`
const html = await renderComponent(code)
- expect(html).toBe(`Test`)
+ expect(html).toBe(`content`)
})
it("uses the hreflang attribute", async () => {
- const code = ``
+ const code = `content`
const html = await renderComponent(code)
- expect(html).toBe(``)
+ expect(html).toBe(`content`)
})
it("uses the hreflang attribute with shorthand", async () => {
@@ -127,10 +127,10 @@ describe.concurrent("preprocessor", () => {
- `
+ content`
const html = await renderComponent(code)
- expect(html).toBe(``)
+ expect(html).toBe(`content`)
})
it("translates the spread operator - no hreflang", async () => {
@@ -138,10 +138,10 @@ describe.concurrent("preprocessor", () => {
- `
+ content`
const html = await renderComponent(code)
- expect(html).toBe(``)
+ expect(html).toBe(`content`)
})
it("translates the spread operator - with hreflang", async () => {
@@ -149,14 +149,14 @@ describe.concurrent("preprocessor", () => {
- `
+ content`
const html = await renderComponent(code)
- expect(html).toBe(``)
+ expect(html).toBe(`content`)
})
it("translates tags if they are links", async () => {
- const hardcoded = ``
+ const hardcoded = `content`
const parameterized = `
@@ -165,7 +165,7 @@ describe.concurrent("preprocessor", () => {
const hardcodedHtml = await renderComponent(hardcoded)
const parameterizedHtml = await renderComponent(parameterized)
- expect(hardcodedHtml).toBe(``)
+ expect(hardcodedHtml).toBe(`content`)
expect(parameterizedHtml).toBe(``)
})
@@ -181,13 +181,13 @@ describe.concurrent("preprocessor", () => {
- `
+ content`
const formHtml = await renderComponent(formCode)
const linkHtml = await renderComponent(linkCode)
expect(formHtml).toBe(``)
- expect(linkHtml).toBe(``)
+ expect(linkHtml).toBe(`content`)
})
it("ignores the href value if it isn't a string", async () => {
@@ -196,7 +196,7 @@ describe.concurrent("preprocessor", () => {
let href = undefined
-
+ content
`
const shorthandCode = `
@@ -204,7 +204,7 @@ describe.concurrent("preprocessor", () => {
let href = undefined
-
+ content
`
const spreadCode = `
@@ -212,12 +212,12 @@ describe.concurrent("preprocessor", () => {
let href = undefined
-
+ content
`
- expect(await renderComponent(attributeCode)).toBe(``)
- expect(await renderComponent(shorthandCode)).toBe(``)
- expect(await renderComponent(spreadCode)).toBe(``)
+ expect(await renderComponent(attributeCode)).toBe(`content`)
+ expect(await renderComponent(shorthandCode)).toBe(`content`)
+ expect(await renderComponent(spreadCode)).toBe(`content`)
})
it("translates the action attribute of forms", async () => {
@@ -239,10 +239,10 @@ describe.concurrent("preprocessor", () => {
- `
+ content`
const html = await renderComponent(code)
- expect(html).toBe(``)
+ expect(html).toBe(`content`)
})
it("handles conflicting hreflang values (last one wins)", async () => {
@@ -251,10 +251,10 @@ describe.concurrent("preprocessor", () => {
const props_1 = { href: "/test", hreflang: "en" }
const props_2 = { hreflang: "de" }
- `
+ content`
const html = await renderComponent(code)
- expect(html).toBe(``)
+ expect(html).toBe(`content`)
})
it("handles a language switcher", async () => {
@@ -275,16 +275,15 @@ describe.concurrent("preprocessor", () => {
)
})
-
it("handles stores as hrefs", async () => {
const code = `
- `
+ content`
const html = await renderComponent(code)
- expect(html).toBe(``)
+ expect(html).toBe(`content`)
})
})
@@ -318,14 +317,21 @@ async function renderComponent(svelteCode: string, props: Record =
filename: "src/Component.svelte",
})
- //console.log(preprocessedComponent.code)
+ const compiledEntry = compile(preprocessedEntry.code, compilerOptions)
+ const compiledComponent = compile(preprocessedComponent.code, compilerOptions)
+
+ // if there are warnings, throw them
+ if (compiledComponent.warnings.length >= 1) {
+ const warnings = [...compiledComponent.warnings]
+ throw new Error("Got Warning while compiling: \n\n" + warnings.map((w) => w.code).join("\n\n"))
+ }
const bundle = await rollup({
input: "src/Entry.svelte",
plugins: [
virtual({
- "src/Entry.svelte": compile(preprocessedEntry.code, compilerOptions).js.code,
- "src/Component.svelte": compile(preprocessedComponent.code, compilerOptions).js.code,
+ "src/Entry.svelte": compiledEntry.js.code,
+ "src/Component.svelte": compiledComponent.js.code,
}),
nodeResolve(),
],
diff --git a/inlang/source-code/paraglide/paraglide-js-adapter-sveltekit/src/vite/preprocessor/rewrite.ts b/inlang/source-code/paraglide/paraglide-js-adapter-sveltekit/src/vite/preprocessor/rewrite.ts
index 836f56aa0a..9eda11efca 100644
--- a/inlang/source-code/paraglide/paraglide-js-adapter-sveltekit/src/vite/preprocessor/rewrite.ts
+++ b/inlang/source-code/paraglide/paraglide-js-adapter-sveltekit/src/vite/preprocessor/rewrite.ts
@@ -44,6 +44,9 @@ export const rewrite = ({
//Add the new spread attribute
code.appendRight(element.start + element.name.length + 1, " " + newSpreadAttributeString)
+
+ //add just before the element
+ code.appendLeft(element.start, "")
} else {
for (const element_translations of Object.entries(translations)) {
const attribute_translations = element_translations[1]
@@ -116,6 +119,9 @@ export const rewrite = ({
const newSpreadAttributeString = c.spreadAttr(value)
code.appendRight(element.start + element.name.length + 1, " " + newSpreadAttributeString)
+
+ //add just before the element
+ code.appendLeft(element.start, "")
} else {
for (const [element_name, attribute_translations] of Object.entries(translations)) {
for (const { attribute_name, lang_attribute_name } of attribute_translations) {