Socket
Socket
Sign inDemoInstall

@putout/plugin-declare-before-reference

Package Overview
Dependencies
387
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    @putout/plugin-declare-before-reference

🐊Putout plugin adds ability move declarations before references


Version published
Weekly downloads
4.4K
increased by1.71%
Maintainers
1
Install size
6.95 kB
Created
Weekly downloads
 

Readme

Source

@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

Keywords

FAQs

Last updated on 21 Aug 2023

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc