Skip to content

feat: add eofNewLine config - #66

Merged
dsherret merged 2 commits into
mainfrom
feat/eof-new-line
Sep 13, 2026
Merged

dsherret merged 2 commits into
mainfrom
feat/eof-new-line

Conversation

@dsherret

Copy link
Copy Markdown
Member

Closes #22

Adds an eofNewLine option to control the newline at the end of the file:

  • "always" (default) - always end the file with a newline. This is the existing behaviour.
  • "maintain" - end the file with a newline only when it already ends with one.
  • "never" - never end the file with a newline.

This is useful for files like package.json, where package managers often remove the trailing newline when adding or removing packages.

{
  "json": {
    "eofNewLine": "maintain"
  }
}
  • maintain checks the text after the BOM is stripped and the package.json conventions are applied (the conventions keep what trails the root value). It counts a \n or a lone \r anywhere in the trailing whitespace.
  • The newline that's written still follows newLineKind.

@dsherret
dsherret merged commit af8bc25 into main Sep 13, 2026
2 checks passed
@dsherret
dsherret deleted the feat/eof-new-line branch September 13, 2026 17:21
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 this pull request may close these issues.

Allow disabling the new line requirement

1 participant