DEV Community

Krzysztof Żuraw
Krzysztof Żuraw

Posted on • Originally published at krzysztofzuraw.com on

Eslint rule to restrict imports

I recently learned that there is a way to restrict imports of certain libraries in Eslint. This is useful for example when you want to restrict the use of a certain library. For example, you might want to restrict the use of lodash.js in your codebase. You can do this by adding the following rule to your Eslint config:

rules: {
  'no-restricted-imports': [
    'error',
    {
      paths: [
        {
          name: 'lodash',
          message: 'Please use the native implementation instead.',
        },
      ],
    },
  ],
},
Enter fullscreen mode Exit fullscreen mode

Top comments (0)

Image of Docusign

🛠️ Bring your solution into Docusign. Reach over 1.6M customers.

Docusign is now extensible. Overcome challenges with disconnected products and inaccessible data by bringing your solutions into Docusign and publishing to 1.6M customers in the App Center.

Learn more