
Research
Malicious npm Packages Impersonate Flashbots SDKs, Targeting Ethereum Wallet Credentials
Four npm packages disguised as cryptographic tools steal developer credentials and send them to attacker-controlled Telegram infrastructure.
eslint-plugin-auto-import-ts
Advanced tools
This is an ESLint plugin that will automatically add (ES6) imports to your modules, when there are undefined references that can be resolved to existing modules in your defined paths, when ESLint is run in --fix
mode.
You'll first need to install ESLint:
$ npm i eslint --save-dev
Next, install eslint-plugin-auto-import
:
$ npm install eslint-plugin-auto-import --save-dev
Note: If you installed ESLint globally (using the -g
flag) then you must also install eslint-plugin-auto-import
globally.
Add auto-import
to the plugins section of your .eslintrc
configuration file, and then add an auto-import
rule with the configuration of your modules. Here is an example:
{
"plugins": [
"auto-import"
],
"rules": {
"auto-import/auto-import": [2, {
"rootPath": "./src",
"packages": {
"d3": "d3",
"bloodhound": "Bloodhound",
"moment": "moment",
"alkali": {
"hasExports": "module-path/to/alkali"
},
"dgrid": {
"modulesIn": "./bower_components/dgrid"
},
"dstore": {
"modulesIn": "./bower_components/dstore"
}
}
}]
}
}
To use auto-import, simply write some code with undefined variables named after modules, and then run eslint in fix mode (it must be run in fix mode to modify your code), and the plugin will search through your paths to find any modules or module exports that match your variables, and add corresponding imports for them. The import will look like:
import MyVariable from '../path/to/MyVariable'
If no module is found, the undefined variable (and warning) will be left in place.
There are several parts of configuration that can be used to define the lookup of modules to satisfy undefined referneces:
rootPath
- This defines the root path of where your modules that you are writing reside. The first thing this plugin will do to try to resolve a module, is it will search through the current directory, then the parent directory, then the children of the parent directory, then the grandparent directory, and so forth. If it finds a module with the same name as your undefined variable, it will import it using a relative path.packages
- These are packages and package modules that can be referenced. There are several types of packages that can be listed for resolution of undefined variables:
"lodash": "_"
, and an undefined variable _
is found in your code, auto-import will add import _ from 'lodash'
modulesIn
- In this case it will search the given directory for modules that match the undefined variable name. This will result in an import like import List from 'dgrid/List'
exports
- In this case it will load the module given by the value of the property, and look at all the exports of module for a match for the undefined variable name. This will result in an import like import { Div } from 'alkali'
FAQs
Automatically update imports
The npm package eslint-plugin-auto-import-ts receives a total of 3 weekly downloads. As such, eslint-plugin-auto-import-ts popularity was classified as not popular.
We found that eslint-plugin-auto-import-ts demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
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.
Research
Four npm packages disguised as cryptographic tools steal developer credentials and send them to attacker-controlled Telegram infrastructure.
Security News
Ruby maintainers from Bundler and rbenv teams are building rv to bring Python uv's speed and unified tooling approach to Ruby development.
Security News
Following last week’s supply chain attack, Nx published findings on the GitHub Actions exploit and moved npm publishing to Trusted Publishers.