Skip to content

In package.json files section, ignores are moved before includes #763

@IlyaSemenov

Description

@IlyaSemenov

Describe the bug

With the latest versions (@antfu/eslint-config 5.4.1), and the default config with no overrides at all, it breaks order of elements under package.json files section:

{
  "files": ["dist", "src", "!**/*.test*.*"]
}

The code above triggers error on eslint .:

/home/projects/unjs-h3-4qj5wbsd/package.json
  5:28  error  Expected array values to be in ascending order. '!**/*.test*.*' should be before 'dist'  jsonc/sort-array-values

✖ 1 problem (1 error, 0 warnings)
  1 error and 0 warnings potentially fixable with the `--fix` option.

When "fixed" with --fix, it becomes:

{
  "files": ["!**/*.test*.*", "dist", "src"]
}

This is broken order, the ignores are supposed to go after the includes, or they won't work. In the reproduction, you can run pnpm lint --fix then pnpm pack and see that tests become included in the distribution archive.

Reproduction

https://stackblitz.com/edit/unjs-h3-4qj5wbsd

System Info

System:
    OS: Linux 5.0 undefined
    CPU: (8) x64 Intel(R) Core(TM) i9-9880H CPU @ 2.30GHz
    Memory: 0 Bytes / 0 Bytes
    Shell: 1.0 - /bin/jsh
  Binaries:
    Node: 20.19.1 - /usr/local/bin/node
    Yarn: 1.22.19 - /usr/local/bin/yarn
    npm: 10.8.2 - /usr/local/bin/npm
    pnpm: 8.15.6 - /usr/local/bin/pnpm

Used Package Manager

pnpm

Validations

  • Follow our Code of Conduct
  • Read the Contributing Guide.
  • Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
  • Check that this is a concrete bug. For Q&A, please open a GitHub Discussion instead.
  • The provided reproduction is a minimal reproducible of the bug.

Contributions

  • I am willing to submit a PR to fix this issue
  • I am willing to submit a PR with failing tests (actually just go ahead and do it, thanks!)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions