Skip to content

Latest commit

 

History

History
72 lines (49 loc) · 1.98 KB

no-inner-declarations.md

File metadata and controls

72 lines (49 loc) · 1.98 KB
pageClass sidebarDepth title description since
rule-details
0
svelte/no-inner-declarations
disallow variable or `function` declarations in nested blocks
v0.0.8

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