Skip to content

ESLint plugin setup wizard #1253

@matejchalk

Description

@matejchalk

User story

Our setup wizard should be able to configure a basic working version of each of our official plugins. Each plugin may prompt for its own specific configuration options and infer smart defaults from the user's repo. The resulting configuration code adds the plugin to the user's config and sets up some basic categories.

This issue is about @code-pushup/eslint-plugin specifically.

Output example

import eslintPlugin from '@code-pushup/eslint-plugin';
import type { CoreConfig } from '@code-pushup/models';

const config: CoreConfig = {
  plugins: [
    await eslintPlugin({
      config: 'eslint.config.js',
      patterns: ['src/**/*.ts', 'src/**/*.html'],
    }),
  ],
  categories: [
    {
      slug: 'bug-prevention',
      title: 'Bug prevention',
      description: 'Lint rules that find **potential bugs** in your code.',
      refs: [
        { type: 'group', plugin: 'eslint', slug: 'problems', weight: 1 },
      ],
    },
    {
      slug: 'code-style',
      title: 'Code style',
      description:
        'Lint rules that promote **good practices** and consistency in your code.',
      refs: [
        { type: 'group', plugin: 'eslint', slug: 'suggestions', weight: 1 },
      ],
    },
  ],
};

export default config;

Acceptance criteria

  • The ESLint plugin is auto-selected if eslint is installed or an eslint.config.js file exists in the root directory. Otherwise, it is unselected by default.
  • The user is prompted (or provides a CLI argument) for their ESLint config file.
    • Any eslint.config.js file in the project directory is suggested as the default option.
  • The user is prompted (or provides a CLI argument) for the file patterns to be linted.
    • The default pattern is src if this folder exists in the project directory. Otherwise, the default is . (everything in CWD).
  • The user should confirm (via prompt or CLI argument) if they want to also generate basic categories.
    • The default answer is yes (create the categories).
    • If confirmed, 2 categories are created - Bug prevention (from problems group) and Code style (from suggestions group).
    • If denied, no categories are created.
  • All of the above logic lives in @code-pushup/eslint-plugin. The core of the setup wizard in @code-pushup/create-cli orchestrates plugin selection and generation, but doesn't know any specifics about individual plugins.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions