Skip to content

Commit 25769c8

Browse files
committed
style: Linting
1 parent 6a5fa86 commit 25769c8

File tree

3 files changed

+20
-11
lines changed

3 files changed

+20
-11
lines changed

packages/kit/src/runtime/app/forms.js

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -165,19 +165,22 @@ export function enhance(form_element, submit = () => {}) {
165165
let result;
166166

167167
try {
168-
const is_valid_enctype = enctype?.match(/application\/x-www-form-urlencoded|multipart\/form|text\/plain/);
169-
168+
const is_valid_enctype = enctype?.match(
169+
/application\/x-www-form-urlencoded|multipart\/form|text\/plain/
170+
);
171+
170172
const headers = {
171173
accept: 'application/json',
172174
'Content-Type': is_valid_enctype ? enctype : 'application/x-www-form-urlencoded',
173175
'x-sveltekit-action': 'true'
174176
};
175-
177+
176178
// @ts-expect-error
177179
const body = enctype === 'multipart/form-data' ? form_data : new URLSearchParams(form_data);
178-
179-
// @ts-expect-error
180-
if (enctype === 'multipart/form-data' && headers['Content-Type']) delete headers['Content-Type'];
180+
181+
if (enctype === 'multipart/form-data' && headers['Content-Type'])
182+
// @ts-expect-error
183+
delete headers['Content-Type'];
181184

182185
const response = await fetch(action, {
183186
method: 'POST',

packages/kit/test/apps/basics/src/routes/actions/enhance/+page.svelte

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,12 +60,12 @@
6060

6161
<form action="?/login" enctype="application/x-www-form-urlencoded" method="post" use:enhance>
6262
<input class="form-enctype-input" name="username" type="text" />
63-
63+
6464
<button class="form-enctype-submit">Submit</button>
6565
</form>
6666

6767
<form action="?/send_file" enctype="multipart/form-data" method="post" use:enhance>
68-
<input type="file" name="file">
68+
<input type="file" name="file" />
6969

7070
<button class="form-file-submit" type="submit">Submit</button>
7171
</form>

packages/kit/test/apps/basics/test/test.js

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1153,7 +1153,9 @@ test.describe('Actions', () => {
11531153
await expect(page.locator('pre.formdata2')).toHaveText(JSON.stringify({ message: 'hello' }));
11541154
});
11551155

1156-
test('use:enhance with `enctype="application/x-www-form-urlencoded"` attribute in `<form>`', async ({ page }) => {
1156+
test('use:enhance with `enctype="application/x-www-form-urlencoded"` attribute in `<form>`', async ({
1157+
page
1158+
}) => {
11571159
await page.goto('/actions/enhance');
11581160

11591161
expect(await page.textContent('pre.formdata1')).toBe(JSON.stringify(null));
@@ -1176,8 +1178,12 @@ test.describe('Actions', () => {
11761178
await page.locator('input[name="file"]').setInputFiles('./test-file.txt');
11771179
await page.locator('button.form-file-submit').click();
11781180

1179-
await expect(page.locator('pre.formdata1')).toHaveText(JSON.stringify({ result: 'file name:test-file.txt' }));
1180-
await expect(page.locator('pre.formdata2')).toHaveText(JSON.stringify({ result: 'file name:test-file.txt' }));
1181+
await expect(page.locator('pre.formdata1')).toHaveText(
1182+
JSON.stringify({ result: 'file name:test-file.txt' })
1183+
);
1184+
await expect(page.locator('pre.formdata2')).toHaveText(
1185+
JSON.stringify({ result: 'file name:test-file.txt' })
1186+
);
11811187
await expect(page.locator('input[name=username].form-enctype-input')).toHaveValue('');
11821188
});
11831189

0 commit comments

Comments
 (0)