fullstacksjs / eslint-config

Fullstacks eslint config
MIT License
42 stars 3 forks source link

Add Modules API #12

Closed ASafaeirad closed 1 year ago

ASafaeirad commented 1 year ago

This PR adds a new init API let the developers have better control over the plugins and rules

The init API uses modules which defines as follows

interface Modules {
    auto?: boolean;
    react?: 'next' | 'raw';
    typescript?: { parserProject: string[] | string; resolverProject: string[] | string };
    node?: boolean;
    strict?: boolean;
    import?: boolean;
    esm?: boolean;
    graphql?: boolean;
    test?: boolean;
    cypress?: boolean;
    storybook?: boolean;
  };

And adds the init function that accepts the module's configuration. It allows the developer to have

const { init } = require('@fullstacksjs/eslint-config/init');

module.exports = init({
  modules: {
    auto: true,
    esm: true,
    graphql: true,
    typescript: {
      parserProject: ['./tsconfig.eslint.json'],
      resolverProject: ['./tsconfig.json'],
    },
  },
  rules: {
//
  },
});

instead of

module.exports = {
  extends: [
    "@fullstacksjs",
    "@fullstacksjs/eslint-config/esm",
    "@fullstacksjs/eslint-config/typecheck",
    "@fullstacksjs/eslint-config/graphql"
  ],
  "parserOptions": {
    "project": ["./tsconfig.eslint.json"]
  },
  "settings": {
    "import/resolver": {
      "typescript": {
        "project": ["./tsconfig.json"]
      },
    },
  },
  // your configuration
};