mirror of https://github.com/sveltejs/svelte
parent
59d01f737d
commit
ba74297a19
@ -1,14 +1,12 @@
|
|||||||
import usesThisOrArguments from '../utils/usesThisOrArguments';
|
|
||||||
import { Validator } from '../../';
|
import { Validator } from '../../';
|
||||||
import { Node } from '../../../interfaces';
|
import { Node } from '../../../interfaces';
|
||||||
|
|
||||||
|
const disallowed = new Set(['Literal', 'ObjectExpression', 'ArrayExpression']);
|
||||||
|
|
||||||
export default function setup(validator: Validator, prop: Node) {
|
export default function setup(validator: Validator, prop: Node) {
|
||||||
if (prop.value.type === 'ArrowFunctionExpression') {
|
while (prop.type === 'ParenthesizedExpression') prop = prop.expression;
|
||||||
if (usesThisOrArguments(prop.value.body)) {
|
|
||||||
validator.error(
|
if (disallowed.has(prop.value.type)) {
|
||||||
`'setup' should be a function expression, not an arrow function expression`,
|
validator.error(`'setup' must be a function`, prop.value.start);
|
||||||
prop.start
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in new issue