Research
Security News
Malicious npm Package Targets Solana Developers and Hijacks Funds
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
@prettier/plugin-pug
Advanced tools
Please note that the plugin ecosystem in Prettier is still beta, which may make @prettier/plugin-pug
not ready for production use yet.
Plugin for Prettier to format pug code
You can disable code formatting for a particular code block by adding <!-- prettier-ignore -->
before ```pug
.
Pug code with custom formatting:
<!-- prettier-ignore -->
```pug
div.text( color = "primary", disabled ="true" )
```
Prettified code:
```pug
.text(color="primary", disabled)
```
Simply install prettier
and @prettier/plugin-pug
as your project’s npm devDependencies:
cd /path/to/project
## initialise an npm project if you haven’t done it yet
npm init
## or
yarn init
## add Prettier and its Pug plugin to project’s dev dependencies
npm install --dev prettier @prettier/plugin-pug
## or
yarn add --dev prettier @prettier/plugin-pug
## format all pug files in your project
./node_modules/.bin/prettier --write "**/*.pug"
## or
yarn prettier --write "**/*.pug"
printWidth
semi
{
"semi": true,
"overrides": [
{
"files": "*.pug",
"options": {
"parser": "pug",
"singleQuote": false
}
}
]
}
singleQuote
{
"singleQuote": true,
"overrides": [
{
"files": "*.pug",
"options": {
"parser": "pug",
"singleQuote": true
}
}
]
}
tabWidth
useTabs
tabWidth
These are specific options only for prettier-pug
They should be set via Prettier
's overrides
option
attributeSeparator
Change when attributes are separated by commas in tags.
Choices:
'always'
-> Always separate attributes with commas.button(type="submit", (click)="play()", disabled)
'as-needed'
-> Only add commas between attributes where required.button(type="submit", (click)="play()" disabled)
commentPreserveSpaces
Change behavior of spaces within comments.
Choices:
'keep-all'
-> Keep all spaces within comments.// ___this _is __a __comment_
'keep-leading'
-> Keep leading spaces within comments.// ___this is a comment
'trim-all'
-> Trim all spaces within comments.// this is a comment
The definitions for these options can be found in src/options.ts
If you are using a text editor that supports Prettier integration (e.g. Atom), you can have all Prettier perks for your Pug code too!
Use VSCode extension to get support for VSCode.
In order to get @prettier/plugin-pug
working in projects that do not have local npm dependencies, you can install this plugin globally:
npm install --global prettier @prettier/plugin-pug
In this case, you might need to check the settings of your editor’s Prettier extension to make sure that a globally installed Prettier is used when it is not found in project dependencies (i.e. package.json
).
Nevertheless, it is recommended to rely on local copies of prettier
and @prettier/plugin-pug
as this reduces the chance of formatting conflicts between project collaborators.
This may happen if different global versions of Prettier or its Pug plugin are used.
Installing @prettier/plugin-pug
either locally or globally may require you to restart the editor if formatting does not work right away.
This plugin is written in TypeScript and its quality is maintained using Prettier and Jest.
If you’re interested in contributing to the development of Prettier for Pug, you can follow the CONTRIBUTING guide from Prettier, as it all applies to this repository too.
To run @prettier/plugin-pug
locally:
yarn install
.yarn lint
to make sure that the code passes formatting and linting.yarn test
to make sure that TypeScript successfully compiles into JavaScript and and all unit tests pass.This project was inspired by https://github.com/gicentre/prettier-plugin-elm.
Many thanks also to @j-f1, @lipis and @azz for the help in transferring this repos to the prettier orga.
FAQs
Prettier Pug Plugin
The npm package @prettier/plugin-pug receives a total of 15,472 weekly downloads. As such, @prettier/plugin-pug popularity was classified as popular.
We found that @prettier/plugin-pug demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 14 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
Security News
Research
Socket researchers have discovered malicious npm packages targeting crypto developers, stealing credentials and wallet data using spyware delivered through typosquats of popular cryptographic libraries.
Security News
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.