0.0.3 • Published 7 years ago

eslint-plugin-undef-init v0.0.3

Weekly downloads
13
License
ISC
Repository
github
Last release
7 years ago

eslint-plugin-undef-init

NpmVersion Travis: Travis (.org) branch Appveyor: AppVeyor branch

Always initialize variables during declaration. Set it explicitly to undefined, if required.

Installation

You'll first need to install ESLint:

$ npm i eslint --save-dev

Next, install eslint-plugin-undef-init:

$ npm install eslint-plugin-undef-init --save-dev

Note: If you installed ESLint globally (using the -g flag) then you must also install eslint-plugin-undef-init globally.

Usage

Either extend from the plugin or add the rules explicitly.

A. Extend from plugin

{
    "extends": [
        // ... other extends here (like airbnb)
        "plugin:undef-init/recommended"
    ]
}

OR

B. Use rule directly

Add undef-init to the plugins section of your .eslintrc configuration file. You can omit the eslint-plugin- prefix:

{
    "plugins": [
        "undef-init"
    ]
}

Then configure the rules you want to use under the rules section.

{
    "rules": {
        "no-undef-init": 0, // Disable conflicting rule
        "undef-init/undef-init": 1,
    }
}

Supported Rules

There is only one rule, for now -

  • undef-init - Disallow variable declaration without initialization.

There is a built-in conflicting rule no-undef-init in eslint, so you'll need to disable it if you are using this rule