8.2.0 β€’ Published 5 months ago

@putout/plugin-declare-before-reference v8.2.0

Weekly downloads
-
License
MIT
Repository
github
Last release
5 months ago

@putout/plugin-declare-before-reference NPM version

The ReferenceError object represents an error when a variable hasn't yet been initialized in the current scope is referenced.

(c) MDN

🐊Putout plugin adds ability to apply declare before reference to avoid ReferenceError.

The rule is similar to ESLint's no-use-before-define, but it's auto fixable, and ignores:

  • βœ… Function declarations
  • βœ… Class declarations
  • βœ… Different scopes

Also it works only on top level and helps to @operator/declare with a bunch of nested declarations.

Install

npm i @putout/plugin-declare-before-reference

Rule

{
    "rules": {
        "declare-before-reference": "on"
    }
}

❌ Example of incorrect code

const {remove} = operator;

const {types, operator} = require('putout');

βœ… Example of correct code

const {types, operator} = require('putout');

const {remove} = operator;

Comparison

LinterRuleFix
🐊 Putoutdeclare-before-referenceβœ…
⏣ ESLintno-use-before-define❌

License

MIT

5.2.0

10 months ago

5.1.0

10 months ago

5.0.0

10 months ago

8.1.0

6 months ago

8.0.0

6 months ago

6.1.0

8 months ago

8.2.0

5 months ago

6.0.0

8 months ago

6.2.0

8 months ago

7.0.0

6 months ago

4.0.0

1 year ago

3.0.0

2 years ago

2.0.0

3 years ago

1.2.0

3 years ago

1.3.0

3 years ago

1.1.1

3 years ago

1.1.0

4 years ago

1.0.0

4 years ago