Socket
Socket
Sign inDemoInstall

babel-plugin-import-asserts

Package Overview
Dependencies
50
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    babel-plugin-import-asserts

babel plugin that adds console.asserts which check that your imports are not undefined


Version published
Weekly downloads
33
increased by6.45%
Maintainers
1
Install size
7.76 kB
Created
Weekly downloads
 

Readme

Source

babel-plugin-import-asserts

Babel plugin that does the following:

npm version Build Status Dependency Status devDependency Status peerDependency Status

For every import baz, {foo, bar} from './baz'; it adds

console.assert(typeof foo !== 'undefined', '[IMPORT]: foo from ./abz is undefined'); 
console.assert(typeof bar !== 'undefined', '[IMPORT]: bar from ./abz is undefined');
console.assert(typeof baz !== 'undefined', '[IMPORT]: baz from ./abz is undefined');

below the import statement.

Motivation:

  1. Catching typos in import can be hard and sometimes lead to cryptic errors.
  2. Using destructuring with files containing constant can lead to weird behaviors if a constant is undefined without you knowing it.

Usage

  • With Babel 5.0 use version 1.X
  • With Babel 6.0 use version 2.X

Make sure to use it only in development.

In .babelrc:

{
  "stage": 0,
    "env": {
      "development": {
        "plugins": [
          "import-asserts"
        ]
    }
}

Inspired by: https://github.com/jonathanewerner/babel-plugin-import-asserts

Keywords

FAQs

Last updated on 15 Nov 2016

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