• Stars
    star
    227
  • Rank 170,185 (Top 4 %)
  • Language
    JavaScript
  • License
    ISC License
  • Created almost 9 years ago
  • Updated about 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

An unopinionated and configurable linter and style checker for Pug

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 #80 (comment)

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.

More Repositories

1

pug

Pug – robust, elegant, feature rich template engine for Node.js
JavaScript
21,482
star
2

babel-plugin-transform-react-pug

A plugin for transpiling pug templates to jsx
JavaScript
806
star
3

react-jade

DEPRECATED, see
JavaScript
552
star
4

pug-loader

Pug loader module for Webpack
JavaScript
425
star
5

pug-cli

Pug's CLI interface
JavaScript
255
star
6

babel-walk

Lightweight Babylon AST traversal tools.
TypeScript
44
star
7

then-pug

**EXPERIMENTAL** Async promise based Jade
JavaScript
42
star
8

pug-lexer

The pug lexer (converts a string into an array of tokens)
JavaScript
41
star
9

pug-zh-cn

The Simplified Chinese documentation for Pug.
32
star
10

with

Compile time `with` for strict mode JavaScript
TypeScript
28
star
11

pug-parser

JavaScript
26
star
12

void-elements

Object of "void elements" as defined by the WHATWG HTML Standard.
JavaScript
24
star
13

js-stringify

Stringify an object so it can be safely inlined in JavaScript code
JavaScript
19
star
14

constantinople

Determine whether a JavaScript expression evaluates to a constant (using Acorn)
TypeScript
18
star
15

pug-www

The website for Pug.
CSS
14
star
16

pug-en

The English documentation for Pug.
13
star
17

token-stream

Take an array of token and produce a more useful API to give to a parser
JavaScript
11
star
18

pug-logo

Pug logo and branding materials
10
star
19

pug-walk

10
star
20

doctypes

Shorthands for commonly used doctypes
JavaScript
10
star
21

pug-runtime

The runtime for the Pug compiler
JavaScript
10
star
22

pug-ast-spec

Specification of the Pug AST
10
star
23

is-expression

Validates a string as a JavaScript expression
JavaScript
9
star
24

pug-code-gen

7
star
25

babel-plugin-transform-with

Babel plugin to convert "with" statements into strict mode-compatible JavaScript.
JavaScript
7
star
26

pug-source-gen

Generate Pug source from a Pug AST.
JavaScript
6
star
27

pug-filters

6
star
28

pug-load

The Pug loader is responsible for loading the dependencies of a given Pug file.
JavaScript
5
star
29

pug-plugin-dynamic-include

WIP, UNPUBLISHED. Pug plugin adding support for dynamic inclusion.
JavaScript
4
star
30

pug-attrs

3
star
31

pug-linker

2
star
32

pug-plugin-debug-line

WIP, UNPUBLISHED. Add location information to all tags.
JavaScript
2
star
33

brjade

Inline jade templates when browserifying
JavaScript
2
star
34

pug-fr

French documentation for Pug
1
star
35

pug-lint-config-migration-v2

pug-lint configuration to help migrate projects to Pug 2.0.0.
JavaScript
1
star
36

pug-error

Standard error objects for pug
JavaScript
1
star
37

pug-strip-comments

1
star