`package.json` conflicting with `eol-last` eslint rule
NamesMT opened this issue · 7 comments
Environment
Node 18
Full dependencies tree:
"devDependencies": {
"@antfu/eslint-config": "^2.6.3",
"@types/node": "^20.11.5",
"@unocss/eslint-plugin": "^0.58.3",
"@vitest/coverage-v8": "^1.2.1",
"eslint": "^8.56.0",
"lint-staged": "^15.2.0",
"simple-git-hooks": "^2.9.0",
"tsx": "^4.7.0",
"typescript": "^5.3.3",
"unbuild": "^2.0.0",
"vitest": "^1.2.1"
},
Reproduction
Just simply run changelogen
with any flag that bumps the version, example:
npx changelogen@latest --bump
Describe the bug
package.json
after getting bumped by changelogen
doesn't have a final new line (removed if previously existing).
In projects with eslint
, or even some IDE built-in feature will flags the file with eol-last
/Final newline missing
.
Not really a bug, but since eol-last
is a very common rule could be seen as a tedious issue, especially with flags that automatically commit like --release
.
Additional context
No response
Logs
➜ nr release -r 1.0.0
> kontroll@0.1.4 release /home/node/kontroll
> pnpm dlx changelogen@latest --release --push --publish "-r" "1.0.0"
Packages: +94
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Progress: resolved 95, reused 94, downloaded 0, added 94, done
ℹ Generating changelog for v0.1.4...main 11:08:38 PM
ℹ Bumping npm package version from 0.1.4 to 1.0.0 (patch) 11:08:38 PM
ℹ Updating /home/node/kontroll/CHANGELOG.md 11:08:39 PM
ERROR Command failed with exit code 1: git commit -m chore(release): v1.0.0 11:08:43 PM
[STARTED] Preparing lint-staged...
[COMPLETED] Preparing lint-staged...
[STARTED] Running tasks for staged files...
[STARTED] package.json — 2 files
[STARTED] * — 2 files
[STARTED] eslint
[FAILED] eslint [FAILED]
[FAILED] eslint [FAILED]
[COMPLETED] Running tasks for staged files...
[STARTED] Applying modifications from tasks...
[SKIPPED] Skipped because of errors from tasks.
[STARTED] Reverting to original state because of errors...
[COMPLETED] Reverting to original state because of errors...
[STARTED] Cleaning up temporary files...
[COMPLETED] Cleaning up temporary files...
✖ eslint:
/home/node/kontroll/CHANGELOG.md
0:0 warning File ignored because of a matching ignore pattern. Use "--no-ignore" to disable file ignore settings or use "--no-warn-ignored" to suppress this warning
/home/node/kontroll/package.json
84:2 error Newline required at end of file but not found style/eol-last
✖ 2 problems (1 error, 1 warning)
1 error and 0 warnings potentially fixable with the --fix option.
[STARTED] Preparing lint-staged...
[COMPLETED] Preparing lint-staged...
[STARTED] Running tasks for staged files...
[STARTED] package.json — 2 files
[STARTED] * — 2 files
[STARTED] eslint
[FAILED] eslint [FAILED]
[FAILED] eslint [FAILED]
[COMPLETED] Running tasks for staged files...
[STARTED] Applying modifications from tasks...
[SKIPPED] Skipped because of errors from tasks.
[STARTED] Reverting to original state because of errors...
[COMPLETED] Reverting to original state because of errors...
[STARTED] Cleaning up temporary files...
[COMPLETED] Cleaning up temporary files...
✖ eslint:
CHANGELOG.md
0:0 warning File ignored because of a matching ignore pattern. Use "--no-ignore" to disable file ignore settings or use "--no-warn-ignored" to suppress this warning
package.json
84:2 error Newline required at end of file but not found style/eol-last
✖ 2 problems (1 error, 1 warning)
1 error and 0 warnings potentially fixable with the --fix option.
at makeError (/root/.local/share/pnpm/store/v3/tmp/dlx-26728/node_modules/.pnpm/execa@8.0.1/node_modules/execa/lib/error.js:60:11)
at handlePromise (/root/.local/share/pnpm/store/v3/tmp/dlx-26728/node_modules/.pnpm/execa@8.0.1/node_modules/execa/index.js:124:26)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async Module.defaultMain (/root/.local/share/pnpm/store/v3/tmp/dlx-26728/node_modules/.pnpm/changelogen@0.5.5/node_modules/changelogen/dist/chunks/default.mjs:98:7)
at async main (/root/.local/share/pnpm/store/v3/tmp/dlx-26728/node_modules/.pnpm/changelogen@0.5.5/node_modules/changelogen/dist/cli.mjs:22:3)
This seems to be a long-known issue with multiple PRs already :(.
This seems to be a long-known issue with multiple PRs already :(.
Hey! Where do you see PRs about this issue?
Hi @Barbapapazes, I did remember finding multiple PRs for it,
But it's been a while so I'm not sure which exactly did I see but this is one of them after a quick search: #129
3 months ago, Pooya merged a PR related to this in pkg-types. Maybe an update could solve this. Will see
Indeed, #201 resolve the issue
As @Barbapapazes pointed out, unjs/pkg-types#175 should have fixed this issue.
Please upgrade your lock file to get the fix.
In case you have similar issues, please feel free to create a new issue with reproduction 🙏🏼
Oh yeah right I haven't encounter this issue in a while but I just answered @Barbapapazes's question without thinking hahaha 😂😂