Ensures your javascript can use underscore or lodash interchangeably as a dependency.
If you maintain a codebase and are thinking of moving over to lodash, this plugin can help. It can ensure your code uses only the subset of underscore that is compatible with lodash. Once you get to that point, you can replace your underscore dependency with lodash and complete the migration.
Note: This plugin is under development, and a few more rules should be coming up (contributions welcome!). Also, due to the limitations of static analysis, this plugin can only do a best effort, and doesn't absolutely guarantee that your code will be fully compatible with both libraries.
You'll first need to install ESLint:
$ npm i eslint --save-dev
Next, install eslint-plugin-underscore-lodash-compatibility
:
$ npm install eslint-plugin-underscore-lodash-compatibility --save-dev
Note: If you installed ESLint globally (using the -g
flag) then you must also install eslint-plugin-underscore-lodash-compatibility
globally.
Add underscore-lodash-compatibility
to the plugins section of your .eslintrc
configuration file. You can omit the eslint-plugin-
prefix:
{
"plugins": [
"underscore-lodash-compatibility"
]
}
Then configure the rules you want to use under the rules section.
{
"rules": {
"underscore-lodash-compatibility/rule-name": 2
}
}
- no-uncommon-functions: Disallow functions that don't exist in lodash or underscore
$ git clone https://github.com/afahim/eslint-plugin-underscore-lodash-compatibility.git
$ cd eslint-plugin-underscore-lodash-compatibility
$ npm test
This project follows the ESLint contribution guidelines.
Copyright 2016 Afnan Fahim. All rights reserved.