Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: ✨ support eslint v9 #31

Merged
merged 4 commits into from
Oct 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .lefthook.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"commands": {
"lint": {
"glob": "*.ts",
"run": "pnpm exec eslint --fix {staged_files}",
"run": "pnpm exec eslint --flag unstable_ts_config --fix {staged_files}",
"stage_fixed": true
},
"format": {
Expand Down
7 changes: 5 additions & 2 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
{
"editor.defaultFormatter": "esbenp.prettier-vscode",
"editor.formatOnSave": true,
"eslint.experimental.useFlatConfig": true,
"eslint.useFlatConfig": true,
"eslint.validate": [
"javascript",
"javascriptreact",
"typescript",
"typescriptreact",
"astro"
]
],
"eslint.options": {
"flags": ["unstable_ts_config"]
}
}
58 changes: 35 additions & 23 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@

> 🔍 another opinionated [eslint](https://eslint.org) config

_This is an evolution of [eslint-config-jimmy-guzman](https://github.com/jimmy-guzman/eslint-config-jimmy-guzman)_

## 🛠️ Usage

_For a better experience, make sure to use [@jimmy.codes/prettier-config](https://github.com/jimmy-guzman/prettier-config) as well_
Expand All @@ -36,47 +34,49 @@ And if you're using [VS Code](https://code.visualstudio.com), make sure to enabl
```jsonc
// .vscode/settings.json
{
"eslint.experimental.useFlatConfig": true,
"eslint.useFlatConfig": true,
}
```

### 🔧 Configuration

**By default all rules are enabled based on the project's dependencies.**

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

```js
import jimmyDotCodes from "@jimmy.codes/eslint-config";

export default jimmyDotCodes({
/**
* Are TypeScript rules are enabled?
* Are TypeScript rules enabled?
* @default false
*/
typescript: true,
/**
* Are React rules are enabled?
* Are React rules enabled?
* @default false
*/
react: true,
/**
* Are Astro rules are enabled?
* Are Astro rules enabled?
* @default false
*/
astro: true,
/**
* Are testing rules are enabled?
* Are testing rules enabled?
* @default false
*/
testing: true,
});
```

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

```js
import jimmyDotCodes from "@jimmy.codes/eslint-config";

export default jimmyDotCodes({ autoDetect: true });
export default jimmyDotCodes({ autoDetect: false });
```

#### TypeScript
Expand Down Expand Up @@ -122,27 +122,39 @@ export default jimmyDotCodes({
});
```

#### Overrides
#### Extending the Configuration

You can also extend or override the configuration:
You can also extend the configuration:

```js
import jimmyDotCodes from "@jimmy.codes/eslint-config";

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

You can also extend what is ignored:

```ts
import jimmyDotCodes from "@jimmy.codes/eslint-config";

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

Expand Down
12 changes: 0 additions & 12 deletions eslint.config.mjs

This file was deleted.

3 changes: 3 additions & 0 deletions eslint.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import jimmyDotCodes from "./src";

export default jimmyDotCodes();
14 changes: 7 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
"docs:view": "npx @eslint/config-inspector --open=false",
"format": "prettier --check --cache .",
"format:fix": "prettier --write --cache .",
"lint": "eslint .",
"lint": "eslint --flag unstable_ts_config .",
"lint:fix": "pnpm lint --fix",
"prepack": "pnpm build && clean-pkg-json",
"prepare": "is-ci || lefthook install",
Expand All @@ -48,9 +48,9 @@
},
"prettier": "@jimmy.codes/prettier-config",
"dependencies": {
"@eslint/js": "^8.57.0",
"@eslint/js": "^9.13.0",
"@tanstack/eslint-plugin-query": "^5.59.7",
"@types/eslint": "8.56.10",
"@types/eslint": "9.6.1",
"@types/eslint__js": "8.42.3",
"@typescript-eslint/parser": "^8.12.2",
"@typescript-eslint/utils": "^8.12.2",
Expand All @@ -67,7 +67,7 @@
"eslint-plugin-react-hooks": "^5.0.0",
"eslint-plugin-react-refresh": "0.4.14",
"eslint-plugin-simple-import-sort": "^12.1.1",
"eslint-plugin-testing-library": "^6.4.0",
"eslint-plugin-testing-library": "7.0.0-beta.4",
"globals": "^15.11.0",
"local-pkg": "0.5.0",
"typescript-eslint": "^8.12.2"
Expand All @@ -90,8 +90,8 @@
"astro": "4.16.7",
"clean-pkg-json": "1.2.0",
"commitlint": "19.5.0",
"eslint": "8.57.0",
"eslint-typegen": "0.2.4",
"eslint": "9.13.0",
"eslint-typegen": "0.3.2",
"gitzy": "5.4.0",
"is-ci": "3.0.1",
"jiti": "2.3.3",
Expand All @@ -106,7 +106,7 @@
"vitest": "2.1.4"
},
"peerDependencies": {
"eslint": "^8.57.0"
"eslint": "^9.10.0"
},
"packageManager": "[email protected]",
"engines": {
Expand Down
Loading