Skip to content

Commit 968d554

Browse files
committed
chore: upgrade prettier to 3.1
1 parent f3265c5 commit 968d554

File tree

30 files changed

+128
-125
lines changed

30 files changed

+128
-125
lines changed

documentation/examples/20-7guis/05-7guis-crud/App.svelte

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
? people.filter((person) => {
1717
const name = `${person.last}, ${person.first}`;
1818
return name.toLowerCase().startsWith(prefix.toLowerCase());
19-
})
19+
})
2020
: people;
2121
2222
$: selected = filteredPeople[i];

package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@
1818
"build:sites": "pnpm -r --filter=./sites/* build",
1919
"preview-site": "npm run build --prefix sites/svelte-5-preview",
2020
"check": "cd packages/svelte && pnpm build && cd ../../ && pnpm -r check",
21-
"format": "prettier --write --plugin prettier-plugin-svelte .",
22-
"lint": "prettier --check --plugin prettier-plugin-svelte . && eslint ./",
21+
"format": "prettier --write .",
22+
"lint": "prettier --check . && eslint ./",
2323
"test": "vitest run --coverage",
2424
"test-output": "vitest run --reporter=json --outputFile=sites/svelte-5-preview/src/routes/status/results.json",
2525
"changeset:version": "changeset version && pnpm -r generate:version && git add --all",
@@ -38,8 +38,8 @@
3838
"eslint-plugin-lube": "^0.1.7",
3939
"jsdom": "22.0.0",
4040
"playwright": "^1.35.1",
41-
"prettier": "^3.0.1",
42-
"prettier-plugin-svelte": "^3.0.3",
41+
"prettier": "^3.1.1",
42+
"prettier-plugin-svelte": "^3.1.2",
4343
"typescript": "^5.2.2",
4444
"vitest": "^0.34.6"
4545
}

packages/svelte/src/compiler/errors.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -234,8 +234,8 @@ const attributes = {
234234
type === 'no-each'
235235
? `An element that uses the animate directive must be the immediate child of a keyed each block`
236236
: type === 'each-key'
237-
? `An element that uses the animate directive must be used inside a keyed each block. Did you forget to add a key to your each block?`
238-
: `An element that uses the animate directive must be the sole child of a keyed each block`,
237+
? `An element that uses the animate directive must be used inside a keyed each block. Did you forget to add a key to your each block?`
238+
: `An element that uses the animate directive must be the sole child of a keyed each block`,
239239
'duplicate-animation': () => `An element can only have one 'animate' directive`,
240240
/** @param {string[] | undefined} [modifiers] */
241241
'invalid-event-modifier': (modifiers) =>
@@ -262,7 +262,7 @@ const attributes = {
262262
? `An element can only have one '${directive1}' directive`
263263
: `An element cannot have both ${describe(directive1)} directive and ${describe(
264264
directive2
265-
)} directive`;
265+
)} directive`;
266266
},
267267
'invalid-let-directive-placement': () => 'let directive at invalid position'
268268
};

packages/svelte/src/compiler/legacy.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ export function convert(source, ast) {
108108
// @ts-ignore
109109
delete node.parent;
110110
}
111-
})
111+
})
112112
: undefined
113113
};
114114
},

packages/svelte/src/compiler/phases/1-parse/state/element.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -108,12 +108,12 @@ export default function tag(parser) {
108108
const type = meta_tags.has(name)
109109
? meta_tags.get(name)
110110
: regex_capital_letter.test(name[0]) || name === 'svelte:self' || name === 'svelte:component'
111-
? 'Component'
112-
: name === 'title' && parent_is_head(parser.stack)
113-
? 'TitleElement'
114-
: name === 'slot'
115-
? 'SlotElement'
116-
: 'RegularElement';
111+
? 'Component'
112+
: name === 'title' && parent_is_head(parser.stack)
113+
? 'TitleElement'
114+
: name === 'slot'
115+
? 'SlotElement'
116+
: 'RegularElement';
117117

118118
/** @type {import('#compiler').ElementLike} */
119119
// @ts-expect-error TODO can't figure out this error
@@ -132,7 +132,7 @@ export default function tag(parser) {
132132
can_delegate_events: null
133133
},
134134
parent: null
135-
}
135+
}
136136
: {
137137
type: /** @type {import('#compiler').ElementLike['type']} */ (type),
138138
start,
@@ -141,7 +141,7 @@ export default function tag(parser) {
141141
attributes: [],
142142
fragment: create_fragment(true),
143143
parent: null
144-
};
144+
};
145145

146146
parser.allow_whitespace();
147147

packages/svelte/src/compiler/phases/1-parse/utils/mapped_code.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,7 @@ export function combine_sourcemaps(filename, sourcemap_list) {
275275
sourcemap_list,
276276
() => null,
277277
true // skip optional field `sourcesContent`
278-
)
278+
)
279279
: remapping(
280280
// use loader interface
281281
sourcemap_list[0], // last map
@@ -291,7 +291,7 @@ export function combine_sourcemaps(filename, sourcemap_list) {
291291
}
292292
),
293293
true
294-
);
294+
);
295295

296296
if (!map.file) delete map.file; // skip optional field `file`
297297

packages/svelte/src/compiler/phases/2-analyze/index.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -713,12 +713,12 @@ const runes_scope_tweaker = {
713713
rune === '$state'
714714
? 'state'
715715
: rune === '$state.frozen'
716-
? 'frozen_state'
717-
: rune === '$derived'
718-
? 'derived'
719-
: path.is_rest
720-
? 'rest_prop'
721-
: 'prop';
716+
? 'frozen_state'
717+
: rune === '$derived'
718+
? 'derived'
719+
: path.is_rest
720+
? 'rest_prop'
721+
: 'prop';
722722
}
723723

724724
if (rune === '$props') {

packages/svelte/src/compiler/phases/3-transform/client/transform-client.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ export function client_component(source, analysis, options) {
201201
b.call('$.validate_store', store_reference, b.literal(name.slice(1))),
202202
store_get
203203
])
204-
)
204+
)
205205
: b.thunk(store_get)
206206
)
207207
);

packages/svelte/src/compiler/phases/3-transform/client/utils.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,11 @@ export function get_assignment_value(node, { state, visit }) {
2020
return operator === '='
2121
? /** @type {import('estree').Expression} */ (visit(node.right))
2222
: // turn something like x += 1 into x = x + 1
23-
b.binary(
23+
b.binary(
2424
/** @type {import('estree').BinaryOperator} */ (operator.slice(0, -1)),
2525
serialize_get_binding(node.left, state),
2626
/** @type {import('estree').Expression} */ (visit(node.right))
27-
);
27+
);
2828
} else if (
2929
node.left.type === 'MemberExpression' &&
3030
node.left.object.type === 'ThisExpression' &&
@@ -35,11 +35,11 @@ export function get_assignment_value(node, { state, visit }) {
3535
return operator === '='
3636
? /** @type {import('estree').Expression} */ (visit(node.right))
3737
: // turn something like x += 1 into x = x + 1
38-
b.binary(
38+
b.binary(
3939
/** @type {import('estree').BinaryOperator} */ (operator.slice(0, -1)),
4040
/** @type {import('estree').Expression} */ (visit(node.left)),
4141
/** @type {import('estree').Expression} */ (visit(node.right))
42-
);
42+
);
4343
} else {
4444
return /** @type {import('estree').Expression} */ (visit(node.right));
4545
}

packages/svelte/src/compiler/phases/3-transform/client/visitors/javascript-runes.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,11 @@ export const javascript_visitors_runes = {
8787
field.kind === 'state'
8888
? b.call('$.source', should_proxy_or_freeze(init) ? b.call('$.proxy', init) : init)
8989
: field.kind === 'frozen_state'
90-
? b.call('$.source', should_proxy_or_freeze(init) ? b.call('$.freeze', init) : init)
91-
: b.call('$.derived', b.thunk(init));
90+
? b.call(
91+
'$.source',
92+
should_proxy_or_freeze(init) ? b.call('$.freeze', init) : init
93+
)
94+
: b.call('$.derived', b.thunk(init));
9295
} else {
9396
// if no arguments, we know it's state as `$derived()` is a compile error
9497
value = b.call('$.source');

packages/svelte/src/compiler/phases/3-transform/client/visitors/template.js

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -655,15 +655,15 @@ function serialize_element_special_value_attribute(element, node_id, attribute,
655655
// This ensures things stay in sync with the select binding
656656
// in case of updates to the option value or new values appearing
657657
b.call('$.selected', node_id)
658-
])
658+
])
659659
: needs_option_call
660-
? b.sequence([
661-
inner_assignment,
662-
// This ensures a one-way street to the DOM in case it's <select {value}>
663-
// and not <select bind:value>
664-
b.call('$.select_option', node_id, value)
665-
])
666-
: inner_assignment
660+
? b.sequence([
661+
inner_assignment,
662+
// This ensures a one-way street to the DOM in case it's <select {value}>
663+
// and not <select bind:value>
664+
b.call('$.select_option', node_id, value)
665+
])
666+
: inner_assignment
667667
);
668668

669669
if (is_reactive) {
@@ -953,7 +953,7 @@ function serialize_inline_component(node, component_name, context) {
953953
: b.call(
954954
'$.spread_props',
955955
...props_and_spreads.map((p) => (Array.isArray(p) ? b.object(p) : p))
956-
);
956+
);
957957
/** @param {import('estree').Identifier} node_id */
958958
let fn = (node_id) =>
959959
b.call(
@@ -2340,7 +2340,7 @@ export const template_visitors = {
23402340
? b.arrow(
23412341
[b.id('$$anchor')],
23422342
/** @type {import('estree').BlockStatement} */ (context.visit(node.fallback))
2343-
)
2343+
)
23442344
: b.literal(null);
23452345
const key_function =
23462346
node.key && ((each_type & EACH_ITEM_REACTIVE) !== 0 || context.state.options.dev)
@@ -2351,7 +2351,7 @@ export const template_visitors = {
23512351
b.return(/** @type {import('estree').Expression} */ (context.visit(node.key)))
23522352
)
23532353
)
2354-
)
2354+
)
23552355
: b.literal(null);
23562356

23572357
if (node.index && each_node_meta.contains_group_binding) {
@@ -2413,7 +2413,7 @@ export const template_visitors = {
24132413
? b.arrow(
24142414
[b.id('$$anchor')],
24152415
/** @type {import('estree').BlockStatement} */ (context.visit(node.alternate))
2416-
)
2416+
)
24172417
: b.literal(null)
24182418
)
24192419
)
@@ -2432,29 +2432,29 @@ export const template_visitors = {
24322432
? b.arrow(
24332433
[b.id('$$anchor')],
24342434
/** @type {import('estree').BlockStatement} */ (context.visit(node.pending))
2435-
)
2435+
)
24362436
: b.literal(null),
24372437
node.then
24382438
? b.arrow(
24392439
node.value
24402440
? [
24412441
b.id('$$anchor'),
24422442
/** @type {import('estree').Pattern} */ (context.visit(node.value))
2443-
]
2443+
]
24442444
: [b.id('$$anchor')],
24452445
/** @type {import('estree').BlockStatement} */ (context.visit(node.then))
2446-
)
2446+
)
24472447
: b.literal(null),
24482448
node.catch
24492449
? b.arrow(
24502450
node.error
24512451
? [
24522452
b.id('$$anchor'),
24532453
/** @type {import('estree').Pattern} */ (context.visit(node.error))
2454-
]
2454+
]
24552455
: [b.id('$$anchor')],
24562456
/** @type {import('estree').BlockStatement} */ (context.visit(node.catch))
2457-
)
2457+
)
24582458
: b.literal(null)
24592459
)
24602460
)
@@ -2868,9 +2868,9 @@ export const template_visitors = {
28682868
/** @type {import('estree').Expression} */ (node.expression).type ===
28692869
'ObjectExpression'
28702870
? // @ts-expect-error types don't match, but it can't contain spread elements and the structure is otherwise fine
2871-
b.object_pattern(node.expression.properties)
2871+
b.object_pattern(node.expression.properties)
28722872
: // @ts-expect-error types don't match, but it can't contain spread elements and the structure is otherwise fine
2873-
b.array_pattern(node.expression.elements),
2873+
b.array_pattern(node.expression.elements),
28742874
b.member(b.id('$$slotProps'), b.id(node.name))
28752875
),
28762876
b.return(b.object(bindings.map((binding) => b.init(binding.node.name, binding.node))))
@@ -2963,7 +2963,7 @@ export const template_visitors = {
29632963
: b.arrow(
29642964
[b.id('$$anchor')],
29652965
b.block(create_block(node, 'fallback', node.fragment.nodes, context))
2966-
);
2966+
);
29672967

29682968
const expression = is_default
29692969
? b.member(b.id('$$props'), b.id('children'))

packages/svelte/src/compiler/phases/3-transform/server/transform-server.js

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -349,11 +349,11 @@ function get_assignment_value(node, { state, visit }) {
349349
return operator === '='
350350
? /** @type {import('estree').Expression} */ (visit(node.right))
351351
: // turn something like x += 1 into x = x + 1
352-
b.binary(
352+
b.binary(
353353
/** @type {import('estree').BinaryOperator} */ (operator.slice(0, -1)),
354354
serialize_get_binding(node.left, state),
355355
/** @type {import('estree').Expression} */ (visit(node.right))
356-
);
356+
);
357357
} else {
358358
return /** @type {import('estree').Expression} */ (visit(node.right));
359359
}
@@ -778,7 +778,7 @@ function serialize_element_spread_attributes(
778778
b.id('join')
779779
),
780780
b.literal(' ')
781-
)
781+
)
782782
: b.literal('');
783783
args.push(
784784
b.object([
@@ -931,7 +931,7 @@ function serialize_inline_component(node, component_name, context) {
931931
: b.call(
932932
'$.spread_props',
933933
b.array(props_and_spreads.map((p) => (Array.isArray(p) ? b.object(p) : p)))
934-
);
934+
);
935935

936936
/** @type {import('estree').Statement} */
937937
let statement = b.stmt(
@@ -940,7 +940,7 @@ function serialize_inline_component(node, component_name, context) {
940940
? b.call(
941941
'$.validate_component',
942942
typeof component_name === 'string' ? b.id(component_name) : component_name
943-
)
943+
)
944944
: component_name,
945945
b.id('$$payload'),
946946
props_expression
@@ -1032,7 +1032,7 @@ const javascript_visitors_legacy = {
10321032
'$.value_or_fallback',
10331033
prop,
10341034
/** @type {import('estree').Expression} */ (visit(declarator.init))
1035-
)
1035+
)
10361036
: prop;
10371037

10381038
declarations.push(b.declarator(declarator.id, init));
@@ -1177,7 +1177,7 @@ const template_visitors = {
11771177
template: [],
11781178
init: []
11791179
}
1180-
}
1180+
}
11811181
: { ...context, state };
11821182

11831183
const { hoisted, trimmed } = clean_nodes(
@@ -1501,9 +1501,9 @@ const template_visitors = {
15011501
b.let(
15021502
node.expression.type === 'ObjectExpression'
15031503
? // @ts-expect-error types don't match, but it can't contain spread elements and the structure is otherwise fine
1504-
b.object_pattern(node.expression.properties)
1504+
b.object_pattern(node.expression.properties)
15051505
: // @ts-expect-error types don't match, but it can't contain spread elements and the structure is otherwise fine
1506-
b.array_pattern(node.expression.elements),
1506+
b.array_pattern(node.expression.elements),
15071507
b.member(b.id('$$slotProps'), b.id(node.name))
15081508
),
15091509
b.return(b.object(bindings.map((binding) => b.init(binding.node.name, binding.node))))
@@ -1719,12 +1719,12 @@ function serialize_element_attributes(node, context) {
17191719
? b.call(
17201720
b.member(attribute.expression, b.id('includes')),
17211721
serialize_attribute_value(value_attribute.value, context)
1722-
)
1722+
)
17231723
: b.binary(
17241724
'===',
17251725
attribute.expression,
17261726
serialize_attribute_value(value_attribute.value, context)
1727-
),
1727+
),
17281728
metadata: {
17291729
contains_call_expression: false,
17301730
dynamic: false

packages/svelte/src/compiler/phases/3-transform/utils.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ export function infer_namespace(namespace, parent, nodes, path) {
198198
const parent_node =
199199
parent.type === 'Fragment'
200200
? // Messy: We know that Fragment calls create_block directly, so we can do this here
201-
path.at(-1)
201+
path.at(-1)
202202
: parent;
203203

204204
if (

0 commit comments

Comments
 (0)