@putout/plugin-declare-before-reference
🐊Putout plugin adds ability move declarations before references
Last updated 7 months ago by coderaiser .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ npm install @putout/plugin-declare-before-reference 
SYNC missed versions from official npm registry.

@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

Linter Rule Fix
🐊 Putout declare-before-reference βœ…
⏣ ESLint no-use-before-define ❌

License

MIT

Current Tags

  • 10.5.0                                ...           latest (7 months ago)

29 Versions

  • 10.5.0                                ...           7 months ago
  • 10.4.0                                ...           8 months ago
  • 10.3.2                                ...           9 months ago
  • 10.3.1                                ...           9 months ago
  • 10.3.0                                ...           9 months ago
  • 10.2.0                                ...           9 months ago
  • 10.1.0                                ...           9 months ago
  • 10.0.0                                ...           9 months ago
  • 9.0.1                                ...           a year ago
  • 9.0.0                                ...           a year ago
  • 8.3.0                                ...           a year ago
  • 8.2.0                                ...           a year ago
  • 8.1.0                                ...           2 years ago
  • 8.0.0                                ...           2 years ago
  • 7.0.0                                ...           2 years ago
  • 6.2.0                                ...           2 years ago
  • 6.1.0                                ...           2 years ago
  • 6.0.0                                ...           2 years ago
  • 5.2.0                                ...           2 years ago
  • 5.1.0                                ...           2 years ago
  • 5.0.0                                ...           2 years ago
  • 4.0.0                                ...           3 years ago
  • 3.0.0                                ...           3 years ago
  • 2.0.0                                ...           4 years ago
  • 1.3.0                                ...           4 years ago
  • 1.2.0                                ...           4 years ago
  • 1.1.1                                ...           4 years ago
  • 1.1.0                                ...           5 years ago
  • 1.0.0                                ...           5 years ago
Maintainers (1)
Downloads
Total 61
Today 0
This Week 0
This Month 61
Last Day 0
Last Week 16
Last Month 0
Dependencies (0)
None
Dependents (2)

© 2010 - cnpmjs.org x YWFE | Home | YWFE