Eslint: use only on rule from plugin

I want to use a rule from an eslint plugin.
I want this to be the only rule to be used from that plugin. In my concrete case it’s about eslint-plugin-import and the ‘import/named’ rule. How can I achieve this with the minimum amount of custom config?
In my eslintrc I have

{
  extends: ['plugin:import/errors'],
  plugins: ['import'],
  rules: { 'import/named': 2 },
  // ... other settings
}

I know I could manually add 'import/no-unresolved': 0 and all the other rules from the plugin to the rules section but it would be nice to have an easier solution.

>Solution :

You are extending rules from the plugin with the extends setting. Just skip that part. To have no predefined rules, just add the plugin to the plugins array and define the rule(s) by yourself:

{
  plugins: ['import'],
  rules: { 'import/named': 2 },
  // ... other settings
}

Leave a Reply