run prettier and format your code.
be in a nodejs project.
npm i --save-dev @magic/format
edit package.json:
{
"scripts": {
"format": "f -w",
"format:check": "f"
}
}
npm run format
will format and overwrite your source files,
npm run format:check
will list the files that would be changed.
you can install this library globally, but the recommendation is to add the dependency and scripts to the package.json file.
this both explains to everyone that your app has this dependencies as well as keeping your bash free of clutter
npm i -g @magic/format
// check formatting using prettier but do not write
f
// format and overwrite files using prettier
f -w
@magic/format supports a number of prettier plugins out of the box as optional peerDependencies. Just install any of the following and prettier will start checking the appropriate files:
- haml: @prettier/plugin-haml
- lua: @prettier/plugin-lua
- php: @prettier/plugin-php
- pug: @prettier/plugin-pug
- py: @prettier/plugin-python
- rb: @prettier/plugin-ruby
- gemspec: @prettier/plugin-ruby
- xml: @prettier/plugin-xml
- toml: @voltiso/prettier-plugin-toml
- astro: prettier-plugin-astro
- java: prettier-plugin-java
- svelte: prettier-plugin-svelte
first commit
- change error output
- node version is strict
update deps
update info messages
update dependencies
messages now being logged from bin.mjs, making src/index.mjs return a list of changedFiles instead.
- cli script awaits format before displaying information
- add --silent option to suppress info if nothing got changed
update dependencies
update prettier
update dependencies
bump required node version to 14.2.0
- do not error if .gitignore does not exist
- npm i -g @magic/format now is actually usable.
update dependencies
update dependencies
update dependencies
update dependencies
update dependencies
update dependencies
update dependencies
- bump required node version to 14.15.4
- update dependencies
update dependencies (@magic/fs)
update dependencies
update dependencies
- update dependencies (@magic/fs)
- ** broken npm cache **
release to refresh npm cache
update @magic/types and intermediate deps to avoid circular dependency
update depdendencies
update dependencies
update dependencies
update dependencies
- format .js files by default
- update dependencies
- update dependencies
- less runtime errors
- more tests
- update dependencies
update dependencies
update dependencies
update dependencies
update dependencies
- update dependencies
- make sure errors happening whilst formatting files do not lead to data loss in other files that are being written at that same point in time
update dependencies
update dependencies
update dependencies
update dependencies
- add svelte and astro support (prettier-plugin-svelte and prettier-plugin-astro)
- support more filetypes as default:
mjs, js, ts, json, jsx, tsx, svelte, astro, markdown, md
add css, scss, sass
filetypes
catch SIGINT and wait for files to write before executing process.exit()
- add pug and gltf to default --file-types
- update dependencies
actually distribute @prettier/plugin-pug
- update dependencies
- move all prettier plugins to optionalDependencies, we can install them where needed
- update dependencies
- add various prettier plugins as optional peerDependencies, and check for them in the cli. if they exist, add their extensions to the prettier fileTypes
- catch SIGTERM in addition to SIGINT. SIGKILL is uncatchable.
update dependencies
update dependencies
- manually import preinstalled optional prettier plugins
- update dependencies
- expose format and formatString as javascript api
- update dependencies
- peerDependencies allow newer versions
- peerDependencies allow any version
- fix peerDependency resolution
- readd plugins: [] to defaultConfig, allowing us to expand them with installed peerDependencies
- update dependencies
- add glsl shader support (plugin-prettier-glsl)
- update deps
- add htmlWhitespaceSensitivity: ignore
- update deps
...