# svelte/no-inner-declarations
disallow variable or
function
declarations in nested blocks
- βοΈ This rule is included in
"plugin:svelte/recommended"
.
# π Rule Details
This rule requires that function declarations and, optionally, variable declarations be in the root of a program or the body of a function.
This rule extends the base ESLintβs no-inner-declarations rule. The AST generated by svelte-eslint-parser will false positives in no-inner-declarations rule because the root node of the script is not the Program
.
This rule supports svelte-eslint-parserβs AST.
<script>
/* eslint svelte/no-inner-declarations: "error" */
/* β GOOD */
function doSomething() {}
function doSomethingElse() {
function doAnotherThing() {}
}
/* β BAD */
if (test) {
function doSomethingBad() {}
}
</script>
# π§ Options
{
"svelte/no-inner-declarations": [
"error",
"functions" // or "both"
]
}
Same as no-inner-declarations rule option. See here for details.
# π« Related rules
# π Version
This rule was introduced in eslint-plugin-svelte v0.0.8
# π Implementation
Taken with β€οΈ from ESLint core