prettier-plugin-padding-lines
v0.1.1
Published
Prettier plugin to enforce a blank line after block-like statements. ๐๏ธ
Readme
Usage
First install this package as a dev dependency in your package manager of choice:
npm i prettier-plugin-padding-lines -DYou'll then be able to list it as a Prettier plugin in your Prettier config:
{
"plugins": ["prettier-plugin-padding-lines"]
}As a result, Prettier will add a blank line after block-like statements such as for, if, and while:
if (abc) {
def;
}
+
ghi();Function declarations and functions assigned to variables are padded too.
Class declarations and calls that take a function argument, such as describe(...), are left alone.
But Why?
Prettier intentionally does not add empty lines and declined to add an option for this.
That leaves the concern to ESLint's padding-line-between-statements rule: a formatting concern enforced by a linter.
This plugin enforces the equivalent of that rule's { blankLine: "always", prev: "block-like", next: "*" } option at the Prettier level.
See The Blurry Line Between Formatting and Style for more details.
Compatibility
Prettier resolves each parser to exactly one plugin: the last one listed that claims it.
This plugin claims the babel, babel-ts, and typescript parsers, so it cannot be combined with other plugins that claim those same parsers.
That includes prettier-plugin-organize-imports and @ianvs/prettier-plugin-sort-imports.
See prettier#12807 for the upstream issue.
Development
See .github/CONTRIBUTING.md, then .github/DEVELOPMENT.md.
Thanks! ๐๏ธ
Contributors
๐ This package was templated with
create-typescript-appusing the Bingo framework.
