Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@putout/plugin-declare-before-reference

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@putout/plugin-declare-before-reference

🐊Putout plugin adds ability move declarations before references

  • 1.3.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
6.5K
decreased by-1.2%
Maintainers
1
Weekly downloads
 
Created
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

Package last updated on 25 Jun 2022

Did you know?

Socket

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
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc