code-pushup / cli

A CLI to run all kinds of code quality measurements to align your team with company goals
https://code-pushup.dev
MIT License
208 stars 12 forks source link

feat(plugin-eslint): add smart defaults to plugin #602

Open BioPhoton opened 5 months ago

BioPhoton commented 5 months ago

User story

As a developer I want to have as less setup and configuration cost as possible.

At the moment when I'm have the plugin imported i still need to understand how to configure it. Smart defaults could help here.

   import eslintPlugin from '@code-pushup/eslint-plugin';

   export default {
     // ...
     plugins: [
       // ...
       await eslintPlugin(
         // šŸ‘‡ required => šŸ§  šŸ“– šŸžā±ļø
         { eslintrc: '.eslintrc.js', patterns: ['src/**/*.js'] })
     ],
   };

Acceptance criteria

throw new Error(`${ESLINT_PLUGIN_SLUG} needs configuration to work properly. Please read up the configuration section. ${eslintConfigLink}`)

The optional criteria should go into a followup PR šŸ“.

Implementation details

It would be cool to use the plugin like this:

   import eslintPlugin from '@code-pushup/eslint-plugin';

   export default {
     // ...
     plugins: [
       // ...
       await eslintPlugin(),  // šŸ‘ˆ optional => ā¤ļø šŸ˜
     ],
   };
matejchalk commented 5 months ago

The file patterns are probably needed, but we could enable configuring only patterns as string | string[]:

await eslintPlugin('src/**/*.js')
await eslintPlugin(['src/**/*.js', 'src/**/*.ts'])