Change import source
You'll first need to install ESLint:
npm i eslint --save-dev
Next, install eslint-plugin-import-replace
:
npm install eslint-plugin-import-replace --save-dev
Add import-replace
to the plugins section of your .eslintrc
configuration file. You can omit the eslint-plugin-
prefix:
{
"plugins": [
"import-replace"
]
}
Then configure the rules you want to use under the rules section.
{
"rules": {
"import-replace/import-replace": ["error", [
{
"from": "lodash",
"to": "lodash-es"
}
]]
}
}
then run eslint on your project.
if your code is
import { get } from 'lodash';
then it will be autofixed to
import { get } from 'lodash-es';
TODO: Run eslint-doc-generator to generate the configs list (or delete this section if no configs are offered).
🔧 Automatically fixable by the --fix
CLI option.
Name | 🔧 |
---|---|
import-replace | 🔧 |