Skip to content

Commit 97261bf

Browse files
committed
fix tests
1 parent a3f74b7 commit 97261bf

File tree

5 files changed

+15
-15
lines changed

5 files changed

+15
-15
lines changed

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

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -950,16 +950,6 @@ export const validation_runes = merge(validation, a11y_validators, {
950950

951951
const args = /** @type {import('estree').CallExpression} */ (init).arguments;
952952

953-
if (rune === '$derived') {
954-
const arg = args[0];
955-
if (
956-
arg.type === 'CallExpression' &&
957-
(arg.callee.type === 'ArrowFunctionExpression' || arg.callee.type === 'FunctionExpression')
958-
) {
959-
warn(state.analysis.warnings, node, path, 'derived-iife');
960-
}
961-
}
962-
963953
// TODO some of this is duplicated with above, seems off
964954
if ((rune === '$derived' || rune === '$derived.call') && args.length !== 1) {
965955
error(node, 'invalid-rune-args-length', rune, [1]);
@@ -999,6 +989,16 @@ export const validation_runes = merge(validation, a11y_validators, {
999989
}
1000990
}
1001991
}
992+
993+
if (rune === '$derived') {
994+
const arg = args[0];
995+
if (
996+
arg.type === 'CallExpression' &&
997+
(arg.callee.type === 'ArrowFunctionExpression' || arg.callee.type === 'FunctionExpression')
998+
) {
999+
warn(state.analysis.warnings, node, path, 'derived-iife');
1000+
}
1001+
}
10021002
},
10031003
// TODO this is a code smell. need to refactor this stuff
10041004
ClassBody: validation_runes_js.ClassBody,

packages/svelte/tests/compiler-errors/samples/class-state-field-static/_config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { test } from '../../test';
33
export default test({
44
error: {
55
code: 'invalid-state-location',
6-
message: '$state() can only be used as a variable declaration initializer or a class field',
6+
message: '$state(...) can only be used as a variable declaration initializer or a class field',
77
position: [33, 41]
88
}
99
});

packages/svelte/tests/compiler-errors/samples/runes-no-rune-each/_config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@ import { test } from '../../test';
33
export default test({
44
error: {
55
code: 'invalid-state-location',
6-
message: '$state() can only be used as a variable declaration initializer or a class field'
6+
message: '$state(...) can only be used as a variable declaration initializer or a class field'
77
}
88
});

packages/svelte/tests/compiler-errors/samples/runes-wrong-derived-placement/_config.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { test } from '../../test';
22

33
export default test({
44
error: {
5-
code: 'invalid-derived-location',
6-
message: '$derived() can only be used as a variable declaration initializer or a class field'
5+
code: 'invalid-state-location',
6+
message: '$derived(...) can only be used as a variable declaration initializer or a class field'
77
}
88
});

packages/svelte/tests/compiler-errors/samples/runes-wrong-state-placement/_config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@ import { test } from '../../test';
33
export default test({
44
error: {
55
code: 'invalid-state-location',
6-
message: '$state() can only be used as a variable declaration initializer or a class field'
6+
message: '$state(...) can only be used as a variable declaration initializer or a class field'
77
}
88
});

0 commit comments

Comments
 (0)