New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

babel-plugin-import-editor

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

babel-plugin-import-editor

Edit import declarations on Babel.

  • 1.0.0
  • unpublished
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
0
Maintainers
1
Weekly downloads
 
Created
Source

To use this plugin, add config to your .babelrc as below:

{
  "plugins": [["import-editor",
    // this option object will be passed to your function too
    {
      // module's name or path that can be required
      // and the module should export a function
      "config": "./path/to/my/editor/function.js",
      // visit these props!
      "other-props": "will be passed to your own editor function"
  	}
  ]]
}

You're totally free to do everything with this plugin. Your function will be like:

function factory(option/* the option written in babelrc */) {
   // do something with the option

  /** return your editor, the plugin will invoke it
    * @param [source] {string} - the package or path that is imported
    * @param [specifiers] {array<specifier>} - the collection of specifiers
    * @param [specifier.type] {string} - could be
      * `importSpecifier`: // import 'my-package'
      * `importDefaultSpecifier`: // import MyPkg from 'my-package'
      * `importNamespaceSpecifier`: // import * as MyPkg from 'my-package'
    * @param [specifier.local] {string} - the variable/property name
    * @param [specifier.imported] {string} - the imported variable name
    * @param [filename] {string} - the file's name in which codes are written
  */
  return function editor({ source, specifiers, filename }) {
    // if return `false`, the declatation will be removed
    
    // else if return an array of objects or exactly an object
    // the declaration will be replaced
    // the structure should be the same as the argument
    
    // else nothing happens
  };
}

Keywords

FAQs

Package last updated on 28 Dec 2017

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