mirror of https://github.com/sveltejs/svelte
warn on onrender/onteardown, replace with oncreate/ondestroy (#40)
parent
54445fa23d
commit
16e3574bfb
@ -0,0 +1,9 @@
|
||||
import usesThisOrArguments from '../utils/usesThisOrArguments.js';
|
||||
|
||||
export default function oncreate ( validator, prop ) {
|
||||
if ( prop.value.type === 'ArrowFunctionExpression' ) {
|
||||
if ( usesThisOrArguments( prop.value.body ) ) {
|
||||
validator.error( `'oncreate' should be a function expression, not an arrow function expression`, prop.start );
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,9 @@
|
||||
import usesThisOrArguments from '../utils/usesThisOrArguments.js';
|
||||
|
||||
export default function onteardown ( validator, prop ) {
|
||||
if ( prop.value.type === 'ArrowFunctionExpression' ) {
|
||||
if ( usesThisOrArguments( prop.value.body ) ) {
|
||||
validator.error( `'onteardown' should be a function expression, not an arrow function expression`, prop.start );
|
||||
}
|
||||
}
|
||||
}
|
@ -1,9 +1,6 @@
|
||||
import usesThisOrArguments from '../utils/usesThisOrArguments.js';
|
||||
import oncreate from './oncreate.js';
|
||||
|
||||
export default function onrender ( validator, prop ) {
|
||||
if ( prop.value.type === 'ArrowFunctionExpression' ) {
|
||||
if ( usesThisOrArguments( prop.value.body ) ) {
|
||||
validator.error( `'onrender' should be a function expression, not an arrow function expression`, prop.start );
|
||||
}
|
||||
}
|
||||
validator.warn( `'onrender' has been deprecated in favour of 'oncreate', and will cause an error in Svelte 2.x`, prop.start );
|
||||
oncreate( validator, prop );
|
||||
}
|
||||
|
@ -1,9 +1,6 @@
|
||||
import usesThisOrArguments from '../utils/usesThisOrArguments.js';
|
||||
import ondestroy from './ondestroy.js';
|
||||
|
||||
export default function onteardown ( validator, prop ) {
|
||||
if ( prop.value.type === 'ArrowFunctionExpression' ) {
|
||||
if ( usesThisOrArguments( prop.value.body ) ) {
|
||||
validator.error( `'onteardown' should be a function expression, not an arrow function expression`, prop.start );
|
||||
}
|
||||
}
|
||||
validator.warn( `'onteardown' has been deprecated in favour of 'ondestroy', and will cause an error in Svelte 2.x`, prop.start );
|
||||
ondestroy( validator, prop );
|
||||
}
|
||||
|
Loading…
Reference in new issue