π another opinionated eslint config
Note
For a better experience, make sure to use @jimmy.codes/prettier-config as well.
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.
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 });
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",
},
},
);
You can also extend what is ignored:
import eslintConfig from "@jimmy.codes/eslint-config";
export default eslintConfig({
ignores: ["**/*.mjs"],
});
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"]
}
}