Gathering detailed insights and metrics for @seletskiy/plugin-pug
Gathering detailed insights and metrics for @seletskiy/plugin-pug
Gathering detailed insights and metrics for @seletskiy/plugin-pug
Gathering detailed insights and metrics for @seletskiy/plugin-pug
npm install @seletskiy/plugin-pug
Typescript
Module System
Node Version
NPM Version
71.8
Supply Chain
99
Quality
74.5
Maintenance
100
Vulnerability
99.6
License
TypeScript (62.78%)
Pug (35.62%)
Vue (1.41%)
JavaScript (0.19%)
Total Downloads
0
Last Day
0
Last Week
0
Last Month
0
Last Year
0
MIT License
206 Stars
1,159 Commits
44 Forks
2 Watchers
18 Branches
56 Contributors
Updated on May 23, 2025
Latest Version
1.4.1
Package Id
@seletskiy/plugin-pug@1.4.1
Unpacked Size
173.89 kB
Size
39.85 kB
File Count
22
NPM Version
6.14.5
Node Version
14.2.0
Cumulative downloads
Total Downloads
Last Day
0%
NaN
Compared to previous day
Last Week
0%
NaN
Compared to previous week
Last Month
0%
NaN
Compared to previous month
Last Year
0%
NaN
Compared to previous year
Please note that the plugin ecosystem in Prettier is still beta, which may make @prettier/plugin-pug
Plugin for Prettier to format pug code
You can disable code formatting for a particular code block by adding <!-- prettier-ignore -->
```pug
.
1Pug code with custom formatting:
2
3<!-- prettier-ignore -->
4```pug
5div.text( color = "primary", disabled ="true" )
6```
7
8Prettified code:
9
10```pug
11.text(color="primary", disabled)
12```
Simply install prettier
and @prettier/plugin-pug
as your project’s npm devDependencies:
1cd /path/to/project 2 3## initialise an npm project if you haven’t done it yet 4npm init 5## or 6yarn init 7 8## add Prettier and its Pug plugin to project’s dev dependencies 9npm install --dev prettier @prettier/plugin-pug 10## or 11yarn add --dev prettier @prettier/plugin-pug
1## format all pug files in your project 2./node_modules/.bin/prettier --write "**/*.pug" 3## or 4yarn prettier --write "**/*.pug"
printWidth
semi
1{ 2 "semi": false, 3 "overrides": [ 4 { 5 "files": "*.pug", 6 "options": { 7 "parser": "pug", 8 "semi": true 9 } 10 } 11 ] 12}
singleQuote
1{ 2 "singleQuote": true, 3 "overrides": [ 4 { 5 "files": "*.pug", 6 "options": { 7 "parser": "pug", 8 "singleQuote": false 9 } 10 } 11 ] 12}
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'
default -> 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)
closingBracketPosition
Position of closing bracket of attributes.
Choices:
'new-line'
default -> Closing bracket ends with a new line.
Example:
1input( 2 type="text", 3 value="my_value", 4 name="my_name", 5 alt="my_alt", 6 autocomplete="on" 7)
'last-line'
-> Closing bracket remains with last attribute's line.
Example:
1input( 2 type="text", 3 value="my_value", 4 name="my_name", 5 alt="my_alt", 6 autocomplete="on")
commentPreserveSpaces
Change behavior of spaces within comments.
Choices:
'keep-all'
default -> 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/index.ts
There are some code examples that are not formatted well with this plugin and can damage your code.
But there are workarounds for it. These generate even better pug code!
1input(onClick="methodname(\"" + variable + "\", this)") 2// transforms to 3input(onClick="methodname(\"\" + variable + \"\", this)") 4 5// In most cases ES6 template strings are a good solution 6input(onClick=`methodname("${variable}", this)`)
As mentioned in pugjs.org Attribute Interpolation (2.), you should prefere ES2015 template strings to simplify your attributes.
1- const id = 42 2- const collapsed = true 3 4div(id=id, class='collapse' + (collapsed ? '' : ' show') + ' cardcontent') 5// transforms to 6.cardcontent(id=id, class="collapse' + (collapsed ? '' : ' show') + '") 7 8// better write 9.cardcontent.collapse(id=id, class=collapsed ? '' : 'show') 10// Now your js logic is extracted from the plain logic
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:
1npm 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.
Thanks to @Peilonrayz, who gave me the idea to rewrite the printer into a class and thus make the code a lot more maintainable.
No vulnerabilities found.
Reason
18 commit(s) and 1 issue activity found in the last 90 days -- score normalized to 10
Reason
no dangerous workflow patterns detected
Reason
no binaries found in the repo
Reason
all dependencies are pinned
Details
Reason
license file detected
Details
Reason
security policy file detected
Details
Reason
3 existing vulnerabilities detected
Details
Reason
Found 2/9 approved changesets -- score normalized to 2
Reason
detected GitHub workflow tokens with excessive permissions
Details
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
project is not fuzzed
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Score
Last Scanned on 2025-07-07
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More