Socket
Book a DemoInstallSign in
Socket

babel-plugin-import-asserts

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

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

latest
Source
npmnpm
Version
3.0.0
Version published
Weekly downloads
63
173.91%
Maintainers
1
Weekly downloads
 
Created
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:

  • Catching typos in import can be hard and sometimes lead to cryptic errors.
  • 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

babel

FAQs

Package last updated on 15 Nov 2016

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