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

package.json conflicting with eol-last eslint rule #170

Closed
NamesMT opened this issue Jan 21, 2024 · 7 comments
Closed

package.json conflicting with eol-last eslint rule #170

NamesMT opened this issue Jan 21, 2024 · 7 comments

Comments

@NamesMT
Copy link

NamesMT commented Jan 21, 2024

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

> [email protected] 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/[email protected]/node_modules/execa/lib/error.js:60:11)
  at handlePromise (/root/.local/share/pnpm/store/v3/tmp/dlx-26728/node_modules/.pnpm/[email protected]/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/[email protected]/node_modules/changelogen/dist/chunks/default.mjs:98:7)
  at async main (/root/.local/share/pnpm/store/v3/tmp/dlx-26728/node_modules/.pnpm/[email protected]/node_modules/changelogen/dist/cli.mjs:22:3)
@NamesMT
Copy link
Author

NamesMT commented Jan 22, 2024

This seems to be a long-known issue with multiple PRs already :(.

@Barbapapazes
Copy link
Member

This seems to be a long-known issue with multiple PRs already :(.

Hey! Where do you see PRs about this issue?

@NamesMT
Copy link
Author

NamesMT commented Jul 18, 2024

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

@Barbapapazes
Copy link
Member

Barbapapazes commented Jul 18, 2024

3 months ago, Pooya merged a PR related to this in pkg-types. Maybe an update could solve this. Will see

@Barbapapazes
Copy link
Member

Indeed, #201 resolve the issue

@pi0
Copy link
Member

pi0 commented Jul 18, 2024

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 🙏🏼

@pi0 pi0 closed this as completed Jul 18, 2024
@NamesMT
Copy link
Author

NamesMT commented Jul 18, 2024

Oh yeah right I haven't encounter this issue in a while but I just answered @Barbapapazes's question without thinking hahaha 😂😂

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants