Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: antfu/eslint-config
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v2.15.0
Choose a base ref
...
head repository: antfu/eslint-config
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: v2.16.0
Choose a head ref
  • 4 commits
  • 7 files changed
  • 2 contributors

Commits on Apr 25, 2024

  1. chore: update deps

    antfu committed Apr 25, 2024

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    e9bcb8a View commit details
  2. fix(react): improve option for react-refresh, aware Remix and Next.js (

    …#461)
    
    Co-authored-by: Stephen Zhou <hi@hyoban.cc>
    antfu and hyoban authored Apr 25, 2024
    Copy the full SHA
    24d4f14 View commit details
  3. feat: add eslint-plugin-command

    antfu committed Apr 25, 2024
    Copy the full SHA
    20ea295 View commit details
  4. chore: release v2.16.0

    antfu committed Apr 25, 2024
    Copy the full SHA
    cc35e25 View commit details
Showing with 663 additions and 589 deletions.
  1. +27 −10 README.md
  2. +19 −18 package.json
  3. +563 −553 pnpm-lock.yaml
  4. +11 −0 src/configs/command.ts
  5. +5 −4 src/configs/index.ts
  6. +36 −4 src/configs/react.ts
  7. +2 −0 src/factory.ts
37 changes: 27 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
@@ -554,23 +554,40 @@ npm i -D @unocss/eslint-plugin

This config also provides some optional plugins/rules for extended usage.

#### `perfectionist` (sorting)
#### `command`

This plugin [`eslint-plugin-perfectionist`](https://github.com/azat-io/eslint-plugin-perfectionist) allows you to sort object keys, imports, etc, with auto-fix.
Powered by [`eslint-plugin-command`](https://github.com/antfu/eslint-plugin-command). It is not a typical rule for linting, but an on-demand micro-codemod tool that triggers by specific comments.

The plugin is installed, but no rules are enabled by default.
For a few triggers, for example:

It's recommended to opt-in on each file individually using [configuration comments](https://eslint.org/docs/latest/use/configure/rules#using-configuration-comments-1).
- `/// to-function` - converts an arrow function to a normal function
- `/// to-arrow` - converts a normal function to an arrow function
- `/// to-for-each` - converts a for-in/for-of loop to `.forEach()`
- `/// to-for-of` - converts a `.forEach()` to a for-of loop
- `/// keep-sorted` - sorts an object/array/interface
- ... etc. - refer to the [documentation](https://github.com/antfu/eslint-plugin-command#built-in-commands)

```js
/* eslint perfectionist/sort-objects: "error" */
const objectWantedToSort = {
a: 2,
b: 1,
c: 3,
You can add the trigger comment one line above the code you want to transform, for example (note the triple slash):

<!-- eslint-skip -->

```ts
/// to-function
const foo = async (msg: string): void => {
console.log(msg)
}
```

Will be transformed to this when you hit save with your editor or run `eslint . --fix`:

```ts
async function foo(msg: string): void {
console.log(msg)
}
```

The command comments are usually one-off and will be removed along with the transformation.

### Type Aware Rules

You can optionally enable the [type aware rules](https://typescript-eslint.io/linting/typed-linting/) by passing the options object to the `typescript` config:
37 changes: 19 additions & 18 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"name": "@antfu/eslint-config",
"type": "module",
"version": "2.15.0",
"packageManager": "pnpm@9.0.2",
"version": "2.16.0",
"packageManager": "pnpm@9.0.6",
"description": "Anthony's ESLint config",
"author": "Anthony Fu <anthonyfu117@hotmail.com> (https://github.com/antfu/)",
"license": "MIT",
@@ -95,24 +95,25 @@
"@antfu/install-pkg": "^0.3.2",
"@clack/prompts": "^0.7.0",
"@stylistic/eslint-plugin": "^1.7.2",
"@typescript-eslint/eslint-plugin": "^7.7.0",
"@typescript-eslint/parser": "^7.7.0",
"@typescript-eslint/eslint-plugin": "^7.7.1",
"@typescript-eslint/parser": "^7.7.1",
"eslint-config-flat-gitignore": "^0.1.5",
"eslint-flat-config-utils": "^0.2.3",
"eslint-merge-processors": "^0.1.0",
"eslint-plugin-antfu": "^2.1.2",
"eslint-plugin-command": "^0.1.2",
"eslint-plugin-eslint-comments": "^3.2.0",
"eslint-plugin-import-x": "^0.5.0",
"eslint-plugin-jsdoc": "^48.2.3",
"eslint-plugin-jsonc": "^2.15.1",
"eslint-plugin-markdown": "^4.0.1",
"eslint-plugin-n": "^17.2.1",
"eslint-plugin-n": "^17.3.1",
"eslint-plugin-no-only-tests": "^3.1.0",
"eslint-plugin-perfectionist": "^2.9.0",
"eslint-plugin-perfectionist": "^2.10.0",
"eslint-plugin-toml": "^0.11.0",
"eslint-plugin-unicorn": "^52.0.0",
"eslint-plugin-unused-imports": "^3.1.0",
"eslint-plugin-vitest": "^0.5.3",
"eslint-plugin-vitest": "^0.5.4",
"eslint-plugin-vue": "^9.25.0",
"eslint-plugin-yml": "^1.14.0",
"eslint-processor-vue-blocks": "^0.1.2",
@@ -130,26 +131,26 @@
"@antfu/eslint-config": "workspace:*",
"@antfu/eslint-plugin-prettier": "^5.0.1-1",
"@antfu/ni": "^0.21.12",
"@eslint-react/eslint-plugin": "^1.5.8",
"@eslint/config-inspector": "^0.4.6",
"@eslint-react/eslint-plugin": "^1.5.9",
"@eslint/config-inspector": "^0.4.7",
"@stylistic/eslint-plugin-migrate": "^1.7.2",
"@types/eslint": "^8.56.9",
"@types/eslint": "^8.56.10",
"@types/fs-extra": "^11.0.4",
"@types/node": "^20.12.7",
"@types/prompts": "^2.4.9",
"@types/yargs": "^17.0.32",
"@unocss/eslint-plugin": "^0.59.3",
"@unocss/eslint-plugin": "^0.59.4",
"astro-eslint-parser": "^0.17.0",
"bumpp": "^9.4.0",
"bundle-require": "^4.0.2",
"eslint": "^9.0.0",
"bundle-require": "^4.0.3",
"eslint": "^9.1.1",
"eslint-plugin-astro": "^0.34.0",
"eslint-plugin-format": "^0.1.1",
"eslint-plugin-react-hooks": "^4.6.0",
"eslint-plugin-react-hooks": "^4.6.1",
"eslint-plugin-react-refresh": "^0.4.6",
"eslint-plugin-solid": "^0.13.2",
"eslint-plugin-svelte": "2.36.0-next.13",
"eslint-typegen": "^0.2.3",
"eslint-typegen": "^0.2.4",
"esno": "^4.7.0",
"execa": "^8.0.1",
"fast-glob": "^3.3.2",
@@ -160,11 +161,11 @@
"rimraf": "^5.0.5",
"simple-git-hooks": "^2.11.1",
"svelte": "^4.2.15",
"svelte-eslint-parser": "^0.34.1",
"svelte-eslint-parser": "^0.35.0",
"tsup": "^8.0.2",
"typescript": "^5.4.5",
"vitest": "^1.5.0",
"vue": "^3.4.23"
"vitest": "^1.5.2",
"vue": "^3.4.25"
},
"simple-git-hooks": {
"pre-commit": "pnpm lint-staged"
Loading