diff --git a/README.md b/README.md index 670f038..887359d 100644 --- a/README.md +++ b/README.md @@ -44,7 +44,7 @@ Finally, enable all of the rules that you would like to use. # List of supported rules -* [import](docs/rules/import.md): Prevent importing the entire lodash library. +* [import](docs/rules/import.md): Prevent importing the entire lodash (or lodash-compat) library. ## To Do diff --git a/src/rules/import.js b/src/rules/import.js index 1dc1d35..6614da4 100644 --- a/src/rules/import.js +++ b/src/rules/import.js @@ -7,7 +7,7 @@ export default function(context) { return { ImportDeclaration(node) { - if (node.source.value === 'lodash') { + if (node.source.value === 'lodash' || node.source.value === 'lodash-compat') { context.report(node.source, 'Importing the entire lodash library is not permitted, please import the specific functions you need'); } } diff --git a/test/rules/import.Spec.js b/test/rules/import.Spec.js index 77ecfb2..8ae6988 100644 --- a/test/rules/import.Spec.js +++ b/test/rules/import.Spec.js @@ -39,6 +39,13 @@ ruleTester.run('lodash/import', rule, { message: 'Importing the entire lodash library is not permitted, please import the specific functions you need' }] }, + { + code: 'import "lodash-compat"', + parser: 'babel-eslint', + errors: [{ + message: 'Importing the entire lodash library is not permitted, please import the specific functions you need' + }] + }, { code: 'import _ from "lodash"', parser: 'babel-eslint',