Eslint rule to restrict imports
Krzysztof Żuraw

Krzysztof Żuraw @kzuraw

About: TypeScript & React + V60

Location:
Wrocław
Joined:
Oct 20, 2017

Eslint rule to restrict imports

Publish Date: Dec 18 '22
2 0

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

Comments 0 total

    Add comment