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

[Bug]: Missing final newline in generated files #2718

Open
malek-benazzouz opened this issue Jan 22, 2025 · 1 comment
Open

[Bug]: Missing final newline in generated files #2718

malek-benazzouz opened this issue Jan 22, 2025 · 1 comment
Labels
bug Something isn't working priority:low question Further information is requested quick

Comments

@malek-benazzouz
Copy link

Package name

core

Package version

11.6.0-rc.2

Reproduction steps

Create a project with @o3r/create, then generate an app and a lib using version 11.6.0-rc.2:

npm create @[email protected] project
ng g application app
ng g library lib

Add the estlint config using the o3r schematics:

ng add @o3r/[email protected]

Environment: Windows Terminal with Git bash profile.

Current result

The following generated files have a missing final newline:

.vscode/settings.json # This one is generated by the `ng add @o3r/eslint-config` command
apps/app/package.json # The rest of the files were generated by the `npm create` of the `ng g app/lib` commands
apps/app/tsconfig.app.json
apps/app/tsconfig.spec.json
lerna.json
libs/lib/ng-package.json
libs/lib/package.json
libs/lib/tsconfig.lib.json
.vscode/extensions.json
angular.json
tsconfig.json

Expected result

It would be nice if we could generate the files with the final newline.

Additional comments

No response

@malek-benazzouz malek-benazzouz added bug Something isn't working triage labels Jan 22, 2025
@kpanot
Copy link
Contributor

kpanot commented Jan 24, 2025

This is actually a common issue we have in the code in different places, it is due to a code similar to:

tree.overwrite('path/to/file.json', JSON.stringify(object, null, 2));
// or
tree.create('path/to/file.json', JSON.stringify(object, null, 2));

A possible fix is to simply add + \\n but it will lead to the following issues:

  • Will not be aligned with editorconfig if insert_final_newline = false
  • Will enforce to add manually \\n in the code after every json.stringify

As process with the EsLint, I think that relying on the execution of the editorconfig-checker with fix option would make more sense.

@kpanot kpanot added the question Further information is requested label Jan 24, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working priority:low question Further information is requested quick
Projects
None yet
Development

No branches or pull requests

3 participants