Skip to content
This repository has been archived by the owner on Sep 23, 2022. It is now read-only.

Latest commit

 

History

History
54 lines (38 loc) · 821 Bytes

no-top-level-variables.md

File metadata and controls

54 lines (38 loc) · 821 Bytes

No top level variables (no-top-level-variables)

Based on eslint-plugin-toplevel.

Rule Details

Lets you disallow top level variables.

Examples of incorrect code for this rule:

var foo = 42;
const bar = 1337;
let baz = 0;

// Rest of your code

Examples of correct code for this rule:

export default function () {
  var foo = 42;
  const bar = 1337;
  let baz = 0;

  // Rest of your code
}

Options

{
  "rules": {
    "nosideeffect-top/no-top-level-variables": [
      "error",
      {
        "kind": ["const", "let", "var"]
      }
    ]
  }
}

kind

Allows to only forbid specific kinds of variables.

Default is ["const", "let", "var"]

When Not To Use It

If you want to allow top level variables