fix: disallow TODO errors (#10326)

* disallow TODO errors

* replace TODO errors

* changeset

---------

Co-authored-by: Rich Harris <rich.harris@vercel.com>
pull/10333/head
Rich Harris 11 months ago committed by GitHub
parent 336d0160da
commit 5ebd9e0b45
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -0,0 +1,5 @@
---
'svelte': patch
---
fix: replace TODO errors

@ -88,7 +88,9 @@ const parse = {
'illegal-subscription': () => `Cannot reference store value inside <script context="module">`, 'illegal-subscription': () => `Cannot reference store value inside <script context="module">`,
'duplicate-style-element': () => `A component can have a single top-level <style> element`, 'duplicate-style-element': () => `A component can have a single top-level <style> element`,
'duplicate-script-element': () => 'duplicate-script-element': () =>
`A component can have a single top-level <script> element and/or a single top-level <script context="module"> element` `A component can have a single top-level <script> element and/or a single top-level <script context="module"> element`,
'invalid-render-expression': () => 'expected an identifier followed by (...)',
'invalid-render-arguments': () => 'expected at most one argument'
}; };
/** @satisfies {Errors} */ /** @satisfies {Errors} */
@ -508,7 +510,7 @@ export class CompileError extends Error {
} }
/** /**
* @template {keyof typeof errors} T * @template {Exclude<keyof typeof errors, 'TODO'>} T
* @param {NodeLike | number | null} node * @param {NodeLike | number | null} node
* @param {T} code * @param {T} code
* @param {Parameters<typeof errors[T]>} args * @param {Parameters<typeof errors[T]>} args

@ -586,11 +586,11 @@ function special(parser) {
const expression = read_expression(parser); const expression = read_expression(parser);
if (expression.type !== 'CallExpression' || expression.callee.type !== 'Identifier') { if (expression.type !== 'CallExpression' || expression.callee.type !== 'Identifier') {
error(expression, 'TODO', 'expected an identifier followed by (...)'); error(expression, 'invalid-render-expression');
} }
if (expression.arguments.length > 1) { if (expression.arguments.length > 1) {
error(expression.arguments[1], 'TODO', 'expected at most one argument'); error(expression.arguments[1], 'invalid-render-arguments');
} }
parser.allow_whitespace(); parser.allow_whitespace();

Loading…
Cancel
Save