Skip to content

jimmy-guzman/eslint-config

Repository files navigation

@jimmy.codes/eslint-config

GitHub Actions Workflow Status version downloads semantic-release code style: prettier

πŸ” another opinionated eslint config

πŸ› οΈ Usage

Note

For a better experience, make sure to use @jimmy.codes/prettier-config as well.

πŸ”¨ Getting Started

First install the package, by running the following:

pnpm add -D @jimmy.codes/eslint-config

Then all you need to in your eslint.config.js is:

import eslintConfig from "@jimmy.codes/eslint-config";

export default eslintConfig();

Which will enable rules based on your project dependencies.

πŸ”§ Configuration

This package contains rules that can be enabled or disabled as follows:

import eslintConfig from "@jimmy.codes/eslint-config";

export default eslintConfig({
  astro: false,
  jest: false,
  nextjs: false,
  playwright: false,
  react: false,
  storybook: false,
  tanstackQuery: false,
  testingLibrary: false,
  typescript: false,
  vitest: false,
});

Or you can turn off auto detection to disable rules based on a project's dependencies:

import eslintConfig from "@jimmy.codes/eslint-config";

export default eslintConfig({ autoDetect: false });

Extending/overriding the Configuration

You can also extend or override the configuration:

import eslintConfig from "@jimmy.codes/eslint-config";

export default eslintConfig({
  overrides: [
    {
      files: ["**/*.js"],
      rules: {
        "prefer-spread": "error",
      },
    },
    {
      files: ["**/*.ts"],
      rules: {
        "prefer-const": "error",
      },
    },
  ],
});

Or pass configs as additional arguments:

import eslintConfig from "@jimmy.codes/eslint-config";

export default eslintConfig(
  {},
  {
    files: ["**/*.js"],
    rules: {
      "prefer-spread": "error",
    },
  },
  {
    files: ["**/*.ts"],
    rules: {
      "prefer-const": "error",
    },
  },
);

Ignores

You can also extend what is ignored:

import eslintConfig from "@jimmy.codes/eslint-config";

export default eslintConfig({
  ignores: ["**/*.mjs"],
});

TypeScript Configuration Files

If you want to use TypeScript configuration files, you can do the following:

Add --flag unstable_ts_config to your eslint script, for example:

{
  "scripts": {
    "lint": "eslint --flag unstable_ts_config ."
  }
}

And add the following to your .vscode/settings.json:

{
  "eslint.options": {
    "flags": ["unstable_ts_config"]
  }
}

❀️ Credits