Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

pug-lint

pugjs146.9kISC2.7.0

An unopinionated and configurable linter and style checker for Pug (formerly Jade)

puglint, jadelint, pug-lint, jade-lint, pug, jade, lint, code style, formatter, style guide, validate, lint pug, lint jade, pug lint, jade lint, linter, linter pug, linter jade, pug linter, jade linter, pug-linter, jade-linter, linting, linting pug, linting jade, pug linting, jade linting, pug-linting, jade-linting, hint, hint pug, hint jade, pug hint, jade hint, pug-hint, jade-hint, hinter, hinter pug, hinter jade, pug hinter, jade hinter, pug-hinter, jade-hinter, hinting, hinting pug, hinting jade, pug hinting, jade hinting, pug-hinting, jade-hinting

readme

pug-lint

An unopinionated and configurable linter and style checker for Pug (formerly Jade)

build status coverage status dependency status npm

CLI

Installation

$ npm install -g pug-lint

Usage

$ pug-lint [options] <file ...>

Options

  • -h, --help: output usage information
  • -V, --version: output the version number
  • -c, --config <path>: configuration file path
  • -r, --reporter <reporter>: error reporter; console - default, inline

Editor integration

Sublime Text 3

If you use SublimeLinter 3 with Sublime Text 3, you can install the SublimeLinter-pug-lint plugin using Package Control.

Atom

If you use Atom, you can install the linter-pug package.

VS Code

If you use VS Code, you can install the vscode-puglint extension.

Vim

pug-lint is part of syntastic.

If you are using vim-plug to manage your Vim plugins (recommended), you can do:

" In your ~/.vimrc
Plug 'scrooloose/syntastic'
" Then run these commands
:source %
:PlugInstall

Then to turn the pug linter on, you will need this line in your .vimrc.

let g:syntastic_pug_checkers = ['pug_lint']

Build system integration

Gulp

If you're using Gulp as your build system, you can use gulp-pug-linter for easier integration.

Grunt

If you're using Grunt as your build system, you can use grunt-puglint for easier integration.

Configuration file

Options and rules can be specified in a .pug-lintrc, .pug-lintrc.js, or .pug-lintrc.json file, or via adding a "pugLintConfig" option to package.json.

Options

preset deprecated

Presets have been deprecated in favour of extending configuration files.

Instructions for those wishing to continue to use the rules defined in the deprecated clock preset can be found at https://github.com/pugjs/pug-lint/issues/80#issuecomment-223283681

extends

Type: string

If you want to extend a specific configuration file, you can use the extends property and specify the path to the file. The path can be either relative or absolute

Configurations can be extended by using:

  1. JSON file
  2. JS file
  3. Shareable configuration package

The extended configuration provides base rules, which can be overridden by the configuration that references it. For example:

{
  "extends": "./node_modules/coding-standard/.pug-lintrc",
  "disallowIdLiterals": null
}

You can also extend configurations using shareable configuration packages. To do so, be sure to install the configuration package you want from npm and then use the package name, such as:

$ npm install --save-dev pug-lint-config-clock
{
  "extends": "pug-lint-config-myrules",
  "disallowIdLiterals": null
}

In this example, the pug-lint-config-myrules package will be loaded as an object and used as the parent of this configuration. You can override settings from the shareable configuration package by adding them directly into your .pug-lintrc file.

You can find config to extend on NPM using "pug-lint-config" query.

Note: You can omit pug-lint-config- and pug-lint will automatically insert it for you

excludeFiles

Type: Array

Default: ["node_modules/**"]

Disables style checking for specified paths declared with glob patterns.

additionalRules

Type: Array

Array of file path matching patterns to load additional rules from, e.g.:

{
  "additionalRules": ["project-rules/*.js"]
}

Rules

List of available rules

You can specifically disable any rule by omitting it from your .pug-lintrc config file or by assigning it to null, like so:

{
  "disallowBlockExpansion": null
}

Some rules, if enabled at the same time, would be contradictory to one another, such as:

{
  "disallowSpaceAfterCodeOperator": true,
  "requireSpaceAfterCodeOperator": true
}

In this case requireSpaceAfterCodeOperator is treated as null, and ignored.

Shareable configuration packages

Shareable configs are simply npm packages that export a configuration object. To start, create a Node.js module like you normally would. Make sure the module name begins with pug-lint-config-, such as pug-lint-config-myconfig. Create a new index.js file and export an object containing your settings:

module.exports = {
  disallowBlockExpansion: true
};

Once your shareable config is ready, you can publish to npm to share with others. We recommend using the puglint and puglintconfig keywords so others can easily find your module.

changelog

v2.7.0 / 2023-03-21

Highlights

  • Remove dependency semver-regex
  • Upgrade pug-lexer to allow ellipsis in attributes
  • Add failed test case when using ellipsis in attribute names
  • Fully qualifying URL
  • Changed URL SublimeLinter/SublimeLinter-pug-lint

Changes

v2.6.0...v2.7.0

v2.6.0 / 2019-06-24

Highlights

  • Update to pug-lexer@4 & co.
  • Fix problem with scoped config packages
  • Support Node.js versions 4 to 12

Changes

v2.5.0...v2.6.0

v2.5.0 / 2017-09-03

Highlights

  • Add disallowTrailingSpaces rule
  • docs: version 2 is already out
  • docs: link keywords to npmjs.com
  • Add maximumLineLength rule

Changes

v2.4.0...v2.5.0

v2.4.0 / 2017-02-01

Highlights

  • Merge pull request #121 from cspotcode/feature/json-schema
  • Merge pull request #117 from pandora2000/bug/my-fix-branch
  • Merge pull request #122 from cspotcode/patch-1
  • Merge pull request #113 from jackbrewer/patch-1
  • Fixes documentation
  • Adds build script to regenerate full schema from rule schemas and docs
  • Adds options schema to each rule
  • Adds JSON schema for .pug-lintrc configuration
  • Escape asterisk and other regexp reserved characters for attribute match pattern for validate-attribute-separator
  • Corrects message for requireLowerCaseAttributes
  • Update outdated dependencies (#109)

Changes

v2.3.0...v2.4.0

v2.3.0 / 2016-07-18

Highlights

  • Optimize ignoring directories
  • Add validateTemplateString rule
  • Add disallow template string rules
  • Add disallowLegacyMixinCall rule

Changes

v2.2.2...v2.3.0

v2.2.2 / 2016-06-06

Highlights

  • CLI hot-fix

Changes

v2.2.1...v2.2.2

v2.2.1 / 2016-06-06

Highlights

  • disallowAttributeInterpolation: More accurate handling
  • disallowAttributeContatentation: More accurate concatenation detection
  • Adds requireStrictExtensions rule

Changes

v2.2.0...v2.2.1

v2.2.0 / 2016-06-02

Highlights

  • Added support to extend configuration files from external resources such as files and modules
  • Deprecated preset configuration option in favour of extends
  • Updated to pug-lexer@2

Changes

v2.1.10...v2.2.0

v2.1.10 / 2016-06-01

Highlights

  • Changes priority order, and fixes naming inconsistency, of supported config files

Changes

v2.1.9...v2.1.10

v2.1.9 / 2016-06-01

Highlights

  • Adds support to disallow/require space after individual code operator types

Changes

v2.1.8...v2.1.9

v2.1.8 / 2016-05-31

Highlights

  • Validating multi-line separator now handles outdents correctly
  • All rules now report column numbers for errors where appropriate
  • Adds missing portion of rule documentation for validateIndentation
  • Add information about plugin for VS Code
  • Remove duplicate rule requireSpecificAttributes from documentation

Changes

v2.1.7...v2.1.8

v2.1.7 / 2016-04-18

Highlights

  • Minor bug fixes

Changes

v2.1.6...v2.1.7

v2.1.6 / 2016-02-25

Highlights

  • Improves disallowAttributeConcatenation and disallowStringConcatenation to remove false positives

Changes

v2.1.5...v2.1.6

v2.1.5 / 2016-02-25

Highlights

  • Improves disallowAttributeConcatenation and disallowStringConcatenation to remove false positives

Changes

v2.1.4...v2.1.5

v2.1.4 / 2016-02-25

Highlights

  • Allows commenting in config files
  • disallowMultipleLineBreaks now uses lines in source rather than tokens to allow for multi-line attribute and mixin blocks
  • disallowAttributeConcatenation now handles + characters in quotes

Changes

v2.1.3...v2.1.4

v2.1.3 / 2016-01-20

Highlights

  • Remove shrinkwrap
  • Update dependencies

Changes

v2.1.2...v2.1.3

v2.1.2 / 2016-01-02

Highlights

  • Removes unnecessary console.log

Changes

v2.1.1...v2.1.2

v2.1.1 / 2015-12-23

Highlights

  • Renamed to pug-lint

Changes

v2.1.0...v2.1.1

v2.1.0 / 2015-12-18

Highlights

  • Removed unused JSON.minify dependency

Changes

v2.0.7...v2.1.0

v2.0.7 / 2015-12-17

Highlights

  • Now requires newline characters in validateAttributeSeparator.multiLineSeparator

Changes

v2.0.6...v2.0.7

v2.0.6 / 2015-12-17

Highlights

  • validateAttributeSeparator now handles multi-line attribute blocks

Changes

v2.0.5...v2.0.6

v2.0.5 / 2015-11-23

Highlights

  • New rules:
    • disallowClassAttributeWithStaticValue
    • disallowIdAttributeWithStaticValue

Changes

v2.0.4...v2.0.5

v2.0.4 / 2015-11-23

Highlights

  • Now accounts for block expansion when using the following rules:
    • disallowDuplicateAttributes
    • validateDivTags

Changes

v2.0.3...v2.0.4

v2.0.3 / 2015-11-21

Highlights

  • Now accounts for block expansion when validating order of literals and attributes

Changes

v2.0.2...v2.0.3

v2.0.2 / 2015-11-14

Highlights

  • validateAttributeSeparator now handles unescaped attributes

Changes

v2.0.1...v2.0.2

v2.0.1 / 2015-11-13

Highlights

  • Disallow contradictory rules from being used
  • Rename disallowImplicitDiv to validateDivTags

Changes

v2.0.0...v2.0.1

v2.0.0 / 2015-11-04

Highlights

  • Refactored to use the latest version of pug-lint for improved error reporting

Changes

v1.2.13...v2.0.0

v1.2.13 / 2015-10-08

Highlights

  • Add rules to disallow attribute interpolation and concatenation

Changes

v1.2.12...v1.2.13

v1.2.12 / 2015-09-30

Highlights

  • Fix shrinkwrap

Changes

v1.2.11...v1.2.12

v1.2.11 / 2015-09-30

Highlights

  • Add rule to require strict equality operators

Changes

v1.2.10...v1.2.11

v1.2.10 / 2015-09-03

Highlights

  • Improvement to requireSpaceAfterCodeOperator
  • disallowStringConcatenation now ignores unbuffered code
  • Updates to Clock preset

Changes

v1.2.9...v1.2.10

v1.2.9 / 2015-09-01

Highlights

  • Resolve paths to additional rules correctly
  • requireSpaceAfterCodeOperator now handles more valid cases

Changes

v1.2.8...v1.2.9

v1.2.8 / 2015-08-11

Highlights

  • Files can now be excluded via excludeFiles option in config
  • Users can now define their own rules via additionalRules option in config
  • disallow/requireSpaceAfterCodeOperators how handles lines containing variable declarations
  • disallow/requireSpacesInsideAttributeBrackets now handles nested/multiple brackets

Changes

v1.2.7...v1.2.8

v1.2.7 / 2015-08-10

Highlights

  • Major bug fixing drive on existing rules

Changes

v1.2.6...v1.2.7

v1.2.6 / 2015-08-09

Highlights

  • Further fix to validateAttributeSeparators

Changes

v1.2.5...v1.2.6

v1.2.5 / 2015-08-08

Highlights

  • Further fix to validateAttributeSeparators

Changes

v1.2.4...v1.2.5

v1.2.4 / 2015-08-08

Highlights

  • New rule to disallow spaces inside attribute brackets

Changes

v1.2.3...v1.2.4

v1.2.3 / 2015-08-08

Highlights

  • Fixed bug with validateAttributeSeparator parsing the whole line rather than just the attribute values

Changes

v1.2.2...v1.2.3

v1.2.2 / 2015-08-06

Highlights

  • Fixed bug with validateAttributeSeparator handling of Array and object values

Changes

v1.2.1...v1.2.2

v1.2.1 / 2015-08-05

Highlights

  • Simplified inline reporter

Changes

v1.2.0...v1.2.1

v1.2.0 / 2015-08-06

Highlights

  • Support for built-in and custom reporters

Changes

v1.1.0...v1.2.0

v1.1.0 / 2015-08-04

Highlights

  • Support for presets

Changes

v1.0.2...v1.1.0

v1.0.2 / 2015-08-04

Highlights

  • New rules: requireSpecificAttributes
  • FIX: Attribute quote validation can now handle boolean attributes correctly

Changes

v1.0.1...v1.0.2

v1.0.1 / 2015-08-04

Highlights

  • New rules:
    • disallowSpecificAttributes
    • disallowSpecificTags

Changes

v1.0.0...v1.0.1

v1.0.0 / 2015-07-30

Highlights

  • CLI support
  • Config file support
  • Initial batch of rules