Skip to content
This repository was archived by the owner on Oct 23, 2018. It is now read-only.

Commit f7855ab

Browse files
committed
Support for pug-lint v2.2.0
1 parent 14c25e9 commit f7855ab

File tree

6 files changed

+88
-116
lines changed

6 files changed

+88
-116
lines changed

Diff for: .travis.yml

-3
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,3 @@ node_js:
66
- '4'
77
- '0.12'
88
- '0.10'
9-
10-
before_script:
11-
- npm install -g grunt-cli

Diff for: Gruntfile.js

+13-23
Original file line numberDiff line numberDiff line change
@@ -1,50 +1,40 @@
1-
/*
2-
* grunt-puglint
3-
* https://github.com/mrmlnc/grunt-puglint
4-
*/
5-
61
'use strict';
72

8-
module.exports = function (grunt) {
3+
module.exports = function(grunt) {
94
grunt.initConfig({
105
puglint: {
11-
// Default test with default `clock` config
12-
clock: {
6+
default: {
137
src: ['test/fixtures/**/*.jade']
148
},
159

16-
// Custom config with the string in the options
17-
customConfigString: {
10+
extendsClock: {
1811
options: {
19-
preset: 'jadelint'
12+
extends: 'clock'
2013
},
2114
src: ['test/fixtures/**/*.jade']
2215
},
2316

24-
// Custom config with the object in the options
25-
customConfigObject: {
17+
extendsPath: {
2618
options: {
27-
preset: {
28-
disallowIdLiterals: true
29-
}
19+
extends: './test/fixtures/.pug-lintrc'
3020
},
3121
src: ['test/fixtures/**/*.jade']
3222
},
3323

34-
// Array messages
35-
arrayMessages: {
24+
customConfigObject: {
3625
options: {
37-
preset: {
38-
disallowSpacesInsideAttributeBrackets: true
26+
config: {
27+
disallowIdLiterals: true
3928
}
4029
},
4130
src: ['test/fixtures/**/*.jade']
4231
},
4332

44-
// RC file
45-
rcFile: {
33+
arrayMessages: {
4634
options: {
47-
puglintrc: 'test/fixtures/.pug-lintrc'
35+
config: {
36+
disallowSpacesInsideAttributeBrackets: true
37+
}
4838
},
4939
src: ['test/fixtures/**/*.jade']
5040
}

Diff for: README.md

+14-16
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
![image](https://cloud.githubusercontent.com/assets/7034281/12007446/c55156a8-ac15-11e5-9fda-4be1167c5709.png)
1111

1212
## Getting Started
13-
This plugin requires Grunt `~0.4.5`
13+
This plugin requires Grunt `~1.0.0`
1414

1515
If you haven't used [Grunt](http://gruntjs.com/) before, be sure to check out the [Getting Started](http://gruntjs.com/getting-started) guide, as it explains how to create a [Gruntfile](http://gruntjs.com/sample-gruntfile) as well as install and use Grunt plugins. Once you're familiar with that process, you may install this plugin with this command:
1616

@@ -26,24 +26,21 @@ grunt.loadNpmTasks('grunt-puglint');
2626

2727
## Usage
2828

29-
If you need a clean config settings, then use the object(`preset: {}`) or config file (`puglintrc: '..'`).
29+
To configure validator, use the property `config`.
3030

3131
```js
3232
puglint: {
3333
taskName: {
3434
options: {
35-
// The name of the preset: `clock` (default) or `jadelint`
36-
preset: 'clock',
37-
// If preset is an object, the standard preset is not loaded
38-
preset: {
35+
// Use preset: npm i -D pug-lint-config-clock
36+
config: {
37+
extends: 'clock'
38+
},
39+
// Or config
40+
config: {
3941
disallowHtmlText: true,
4042
validateIndentation: 4
4143
}
42-
// The path to the configuration file
43-
puglintrc: 'test/fixtures/.pug-lintrc',
44-
// Override preset settings (default: `clock`)
45-
disallowHtmlText: true,
46-
validateIndentation: 4
4744
},
4845
src: ['test/fixtures/**/*.jade']
4946
}
@@ -64,9 +61,10 @@ Plugin can read [.pug-lintrc file](https://github.com/pugjs/pug-lint#configurati
6461

6562
[List of available rules](https://github.com/pugjs/pug-lint/blob/master/docs/rules.md).
6663

67-
## History
64+
## Changelog
6865

69-
* **v0.1.3** [2016-03-09] - Fix failure when item.msg is array. Thanks [@Antiavanti](https://github.com/mrmlnc/grunt-puglint/pull/2).
70-
* **v0.1.2** [2016-02-17] - Make sure the task fails whenever an error is found in any file. Thanks **@rdevaissiere**.
71-
* **v0.1.1** [2015-12-26] - Add `xo` to test section.
72-
* **v0.1.0** [2015-12-26] - Initial release.
66+
See the [Releases section of our GitHub project](https://github.com/mrmlnc/grunt-puglint/releases) for changelogs for each release version.
67+
68+
## License
69+
70+
This software is released under the terms of the MIT license.

Diff for: package.json

+30-27
Original file line numberDiff line numberDiff line change
@@ -2,29 +2,22 @@
22
"name": "grunt-puglint",
33
"description": "Grunt plugin for pug-lint",
44
"version": "0.1.3",
5+
"license": "MIT",
6+
"repository": "mrmlnc/grunt-puglint",
57
"author": {
68
"name": "Denis Malinochkin",
7-
"email": "[email protected]"
9+
"url": "canonium.com"
810
},
9-
"repository": "mrmlnc/grunt-puglint",
10-
"license": "MIT",
1111
"engines": {
12-
"node": ">= 0.8.0"
12+
"node": ">=0.10.0"
1313
},
1414
"scripts": {
15-
"test": "xo && ava test/test.js"
16-
},
17-
"devDependencies": {
18-
"ava": "^0.8.0",
19-
"grunt": "~0.4.5",
20-
"rcloader": "^0.1.4",
21-
"xo": "^0.12.1"
22-
},
23-
"dependencies": {
24-
"chalk": "^1.1.1",
25-
"pug-lint": "^2.1.1",
26-
"text-table": "^0.2.0"
15+
"test": "xo && mocha"
2716
},
17+
"files": [
18+
"tasks",
19+
"lib"
20+
],
2821
"keywords": [
2922
"gruntplugin",
3023
"grunt",
@@ -37,21 +30,31 @@
3730
"lint",
3831
"hint"
3932
],
40-
"files": [
41-
"tasks",
42-
"lib"
43-
],
33+
"devDependencies": {
34+
"grunt": "~1.0.1",
35+
"mocha": "^2.5.3",
36+
"pug-lint-config-clock": "^1.1.1",
37+
"xo": "^0.15.1"
38+
},
39+
"dependencies": {
40+
"chalk": "^1.1.3",
41+
"pug-lint": "^2.2.0",
42+
"text-table": "^0.2.0"
43+
},
4444
"xo": {
45-
"space": true,
4645
"rules": {
47-
"object-curly-spacing": [
48-
2,
49-
"always"
50-
],
51-
"space-before-function-paren": 0
46+
"indent": [2, 2, { "SwitchCase": 1 }],
47+
"arrow-parens": [2, "always"],
48+
"object-curly-spacing": [2, "always"],
49+
"babel/object-curly-spacing": 0,
50+
"space-before-function-paren": [2, "never"]
5251
},
52+
"ignores": [
53+
"test/**"
54+
],
5355
"envs": [
54-
"node"
56+
"node",
57+
"mocha"
5558
]
5659
}
5760
}

Diff for: tasks/puglint.js

+4-15
Original file line numberDiff line numberDiff line change
@@ -10,23 +10,12 @@ var linter = new PugLint();
1010
var formatter = require('../lib/formatter');
1111

1212
module.exports = function(grunt) {
13-
grunt.registerMultiTask('puglint', 'Grunt plugin for pug-lint', function () {
13+
grunt.registerMultiTask('puglint', 'Grunt plugin for pug-lint', function() {
1414
var done = this.async();
15-
var options = this.options({
16-
preset: 'clock'
17-
});
18-
19-
if (typeof options.preset === 'object') {
20-
options = options.preset;
21-
}
15+
var options = this.options({});
2216

23-
var pugLintRc = options.puglintrc;
24-
if (pugLintRc) {
25-
if (grunt.file.exists(pugLintRc)) {
26-
options = grunt.file.readJSON(pugLintRc);
27-
} else {
28-
grunt.log.error('Configuration file not found. Used a standard config: `clock`.');
29-
}
17+
if (typeof options.config === 'object') {
18+
options = options.config;
3019
}
3120

3221
linter.configure(options);

Diff for: test/test.js

+27-32
Original file line numberDiff line numberDiff line change
@@ -1,51 +1,46 @@
11
'use strict';
22

3-
const test = require('ava');
4-
const exec = require('child_process').exec;
3+
var assert = require('assert');
4+
var exec = require('child_process').exec;
55

6-
test.cb('Default test with default `clock` config', function(t) {
7-
exec('grunt puglint:clock', function(err, stdout) {
8-
var isOneError = /ID literals must/.test(stdout.toString());
9-
var isTwoError = /REQUIRECLASSLITERALSBEFOREIDLITERALS/.test(stdout.toString());
10-
11-
t.same(isOneError && isTwoError, true);
12-
t.end();
6+
it('Should work without preferences', function(done) {
7+
exec('grunt puglint:default', function(err, stdout) {
8+
assert.equal(/Done\./.test(stdout), true);
9+
done();
1310
});
1411
});
1512

16-
test.cb('Custom config with the string in the options', function(t) {
17-
exec('grunt puglint:customConfigString', function(err, stdout) {
18-
var isOneError = /DISALLOWSPECIFICATTRIBUTES/.test(stdout.toString());
13+
it('Should work with extends from preset', function(done) {
14+
exec('grunt puglint:extendsClock', function(err, stdout) {
15+
var isOneError = /DISALLOWIDLITERALS/.test(stdout);
16+
var isTwoError = /REQUIRECLASSLITERALSBEFOREIDLI/.test(stdout);
17+
var isThreeError = /Missing line feed at file end/.test(stdout);
1918

20-
t.same(isOneError, true);
21-
t.end();
19+
assert.equal(isOneError && isTwoError && isThreeError, true);
20+
done();
2221
});
2322
});
2423

25-
test.cb('Custom config with the object in the options', function(t) {
26-
exec('grunt puglint:customConfigObject', function(err, stdout) {
27-
var isOneError = /DISALLOWIDLITERALS/.test(stdout.toString());
28-
29-
t.same(isOneError, true);
30-
t.end();
24+
it('Should work with extends from path', function(done) {
25+
exec('grunt puglint:extendsPath', function(err, stdout) {
26+
assert.equal(/REQUIRECLASSLITERALSBEFOREIDLITERALS/.test(stdout), true);
27+
done();
3128
});
3229
});
3330

34-
test.cb('Array messages', function(t) {
35-
exec('grunt puglint:arrayMessages', function(err, stdout) {
36-
var isOneError = /Illegal space after opening bracket\s+DISALLOWSPACESINSIDEATTRIBUTEBRACKETS/.test(stdout.toString());
37-
var isTwoError = /Illegal space before closing bracket\s+DISALLOWSPACESINSIDEATTRIBUTEBRACKETS/.test(stdout.toString());
38-
39-
t.same(isOneError && isTwoError, true);
40-
t.end();
31+
it('Should work with the object in the option', function(done) {
32+
exec('grunt puglint:customConfigObject', function(err, stdout) {
33+
assert.equal(/DISALLOWIDLITERALS/.test(stdout), true);
34+
done();
4135
});
4236
});
4337

44-
test.cb('RC file', function(t) {
45-
exec('grunt puglint:rcFile', function(err, stdout) {
46-
var isOneError = /REQUIRECLASSLITERALSBEFOREIDLITERALS/.test(stdout.toString());
38+
it('Should work with array messages', function(done) {
39+
exec('grunt puglint:arrayMessages', function(err, stdout) {
40+
var isOneError = /Illegal space after opening bracket/.test(stdout);
41+
var isTwoError = /Illegal space before closing bracket/.test(stdout);
4742

48-
t.same(isOneError, true);
49-
t.end();
43+
assert.equal(isOneError && isTwoError, true);
44+
done();
5045
});
5146
});

0 commit comments

Comments
 (0)