Skip to content

Commit aecd47e

Browse files
authored
chore: upgrade prettier to 3.1 (#10134)
1 parent 2e9e8e8 commit aecd47e

File tree

31 files changed

+130
-133
lines changed

31 files changed

+130
-133
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(
@@ -2345,7 +2345,7 @@ export const template_visitors = {
23452345
? b.arrow(
23462346
[b.id('$$anchor')],
23472347
/** @type {import('estree').BlockStatement} */ (context.visit(node.fallback))
2348-
)
2348+
)
23492349
: b.literal(null);
23502350
const key_function =
23512351
node.key && ((each_type & EACH_ITEM_REACTIVE) !== 0 || context.state.options.dev)
@@ -2356,7 +2356,7 @@ export const template_visitors = {
23562356
b.return(/** @type {import('estree').Expression} */ (context.visit(node.key)))
23572357
)
23582358
)
2359-
)
2359+
)
23602360
: b.literal(null);
23612361

23622362
if (node.index && each_node_meta.contains_group_binding) {
@@ -2418,7 +2418,7 @@ export const template_visitors = {
24182418
? b.arrow(
24192419
[b.id('$$anchor')],
24202420
/** @type {import('estree').BlockStatement} */ (context.visit(node.alternate))
2421-
)
2421+
)
24222422
: b.literal(null)
24232423
)
24242424
)
@@ -2437,29 +2437,29 @@ export const template_visitors = {
24372437
? b.arrow(
24382438
[b.id('$$anchor')],
24392439
/** @type {import('estree').BlockStatement} */ (context.visit(node.pending))
2440-
)
2440+
)
24412441
: b.literal(null),
24422442
node.then
24432443
? b.arrow(
24442444
node.value
24452445
? [
24462446
b.id('$$anchor'),
24472447
/** @type {import('estree').Pattern} */ (context.visit(node.value))
2448-
]
2448+
]
24492449
: [b.id('$$anchor')],
24502450
/** @type {import('estree').BlockStatement} */ (context.visit(node.then))
2451-
)
2451+
)
24522452
: b.literal(null),
24532453
node.catch
24542454
? b.arrow(
24552455
node.error
24562456
? [
24572457
b.id('$$anchor'),
24582458
/** @type {import('estree').Pattern} */ (context.visit(node.error))
2459-
]
2459+
]
24602460
: [b.id('$$anchor')],
24612461
/** @type {import('estree').BlockStatement} */ (context.visit(node.catch))
2462-
)
2462+
)
24632463
: b.literal(null)
24642464
)
24652465
)
@@ -2876,9 +2876,9 @@ export const template_visitors = {
28762876
/** @type {import('estree').Expression} */ (node.expression).type ===
28772877
'ObjectExpression'
28782878
? // @ts-expect-error types don't match, but it can't contain spread elements and the structure is otherwise fine
2879-
b.object_pattern(node.expression.properties)
2879+
b.object_pattern(node.expression.properties)
28802880
: // @ts-expect-error types don't match, but it can't contain spread elements and the structure is otherwise fine
2881-
b.array_pattern(node.expression.elements),
2881+
b.array_pattern(node.expression.elements),
28822882
b.member(b.id('$$slotProps'), b.id(node.name))
28832883
),
28842884
b.return(b.object(bindings.map((binding) => b.init(binding.node.name, binding.node))))
@@ -2971,7 +2971,7 @@ export const template_visitors = {
29712971
: b.arrow(
29722972
[b.id('$$anchor')],
29732973
b.block(create_block(node, 'fallback', node.fragment.nodes, context))
2974-
);
2974+
);
29752975

29762976
const expression = is_default
29772977
? 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
@@ -351,11 +351,11 @@ function get_assignment_value(node, { state, visit }) {
351351
return operator === '='
352352
? /** @type {import('estree').Expression} */ (visit(node.right))
353353
: // turn something like x += 1 into x = x + 1
354-
b.binary(
354+
b.binary(
355355
/** @type {import('estree').BinaryOperator} */ (operator.slice(0, -1)),
356356
serialize_get_binding(node.left, state),
357357
/** @type {import('estree').Expression} */ (visit(node.right))
358-
);
358+
);
359359
} else {
360360
return /** @type {import('estree').Expression} */ (visit(node.right));
361361
}
@@ -780,7 +780,7 @@ function serialize_element_spread_attributes(
780780
b.id('join')
781781
),
782782
b.literal(' ')
783-
)
783+
)
784784
: b.literal('');
785785
args.push(
786786
b.object([
@@ -933,7 +933,7 @@ function serialize_inline_component(node, component_name, context) {
933933
: b.call(
934934
'$.spread_props',
935935
b.array(props_and_spreads.map((p) => (Array.isArray(p) ? b.object(p) : p)))
936-
);
936+
);
937937

938938
/** @type {import('estree').Statement} */
939939
let statement = b.stmt(
@@ -942,7 +942,7 @@ function serialize_inline_component(node, component_name, context) {
942942
? b.call(
943943
'$.validate_component',
944944
typeof component_name === 'string' ? b.id(component_name) : component_name
945-
)
945+
)
946946
: component_name,
947947
b.id('$$payload'),
948948
props_expression
@@ -1034,7 +1034,7 @@ const javascript_visitors_legacy = {
10341034
'$.value_or_fallback',
10351035
prop,
10361036
/** @type {import('estree').Expression} */ (visit(declarator.init))
1037-
)
1037+
)
10381038
: prop;
10391039

10401040
declarations.push(b.declarator(declarator.id, init));
@@ -1179,7 +1179,7 @@ const template_visitors = {
11791179
template: [],
11801180
init: []
11811181
}
1182-
}
1182+
}
11831183
: { ...context, state };
11841184

11851185
const { hoisted, trimmed } = clean_nodes(
@@ -1503,9 +1503,9 @@ const template_visitors = {
15031503
b.let(
15041504
node.expression.type === 'ObjectExpression'
15051505
? // @ts-expect-error types don't match, but it can't contain spread elements and the structure is otherwise fine
1506-
b.object_pattern(node.expression.properties)
1506+
b.object_pattern(node.expression.properties)
15071507
: // @ts-expect-error types don't match, but it can't contain spread elements and the structure is otherwise fine
1508-
b.array_pattern(node.expression.elements),
1508+
b.array_pattern(node.expression.elements),
15091509
b.member(b.id('$$slotProps'), b.id(node.name))
15101510
),
15111511
b.return(b.object(bindings.map((binding) => b.init(binding.node.name, binding.node))))
@@ -1721,12 +1721,12 @@ function serialize_element_attributes(node, context) {
17211721
? b.call(
17221722
b.member(attribute.expression, b.id('includes')),
17231723
serialize_attribute_value(value_attribute.value, context)
1724-
)
1724+
)
17251725
: b.binary(
17261726
'===',
17271727
attribute.expression,
17281728
serialize_attribute_value(value_attribute.value, context)
1729-
),
1729+
),
17301730
metadata: {
17311731
contains_call_expression: false,
17321732
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)