Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 534
v-moe Avatar asked Nov 30 '25 17:11

v-moe


1 Answers

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
}
like image 75
JSON Derulo Avatar answered Dec 02 '25 07:12

JSON Derulo



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!