Skip to content

Commit a6ae756

Browse files
authored
Merge pull request #74 from d3viant0ne/d3viant0ne-TravisConsistancy
chore(ci): Bring validation tooling inline with Webpack
2 parents 2debb22 + 41a9cf8 commit a6ae756

File tree

9 files changed

+120
-34
lines changed

9 files changed

+120
-34
lines changed

.editorconfig

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
root = true
2+
3+
[*.js]
4+
indent_style=tab
5+
trim_trailing_whitespace=true

.eslintrc

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
{
2+
"env": {
3+
"node": true
4+
},
5+
"rules": {
6+
"strict": 0,
7+
"camelcase": 0,
8+
"curly": 0,
9+
"indent": [2, "tab", { "SwitchCase": 1 }],
10+
"eol-last": 1,
11+
"no-shadow": 0,
12+
"no-redeclare": 2,
13+
"no-extra-bind": 1,
14+
"no-empty": 0,
15+
"no-process-exit": 1,
16+
"no-underscore-dangle": 0,
17+
"no-use-before-define": 0,
18+
"no-unused-vars": 0,
19+
"consistent-return": 0,
20+
"no-inner-declarations": 1,
21+
"no-loop-func": 1,
22+
"space-before-function-paren": [2, "never"]
23+
}
24+
}

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,6 @@
11
node_modules
2+
coverage
3+
24
*.sw*
5+
6+
npm-debug.log

.jsbeautifyrc

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
2+
{
3+
"js": {
4+
"allowed_file_extensions": ["js", "json", "jshintrc", "jsbeautifyrc"],
5+
"brace_style": "collapse",
6+
"break_chained_methods": false,
7+
"e4x": true,
8+
"eval_code": false,
9+
"end_with_newline": true,
10+
"indent_char": "\t",
11+
"indent_level": 0,
12+
"indent_size": 1,
13+
"indent_with_tabs": true,
14+
"jslint_happy": false,
15+
"jslint_happy_align_switch_case": true,
16+
"space_after_anon_function": false,
17+
"keep_array_indentation": false,
18+
"keep_function_indentation": false,
19+
"max_preserve_newlines": 2,
20+
"preserve_newlines": true,
21+
"space_before_conditional": false,
22+
"space_in_paren": false,
23+
"unescape_strings": false,
24+
"wrap_line_length": 0
25+
}
26+
}

.travis.yml

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,16 @@
1+
sudo: false
12
language: node_js
3+
os:
4+
- linux
5+
- osx
26
node_js:
3-
- 0.6
4-
- 0.8
5-
- 0.10
7+
- node
8+
- "6"
9+
- "5"
10+
- "4"
11+
12+
script: npm run travis
13+
14+
after_success:
15+
- cat ./coverage/coverage.json | node_modules/codecov.io/bin/codecov.io.js
16+
- rm -rf ./coverage

lib/attributesParser.js

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,12 @@
55
var Parser = require("fastparse");
66

77
var processMatch = function(match, strUntilValue, name, value, index) {
8-
if(!this.isRelevantTagAttr(this.currentTag, name)) return;
9-
this.results.push({
10-
start: index + strUntilValue.length,
11-
length: value.length,
12-
value: value
13-
});
8+
if(!this.isRelevantTagAttr(this.currentTag, name)) return;
9+
this.results.push({
10+
start: index + strUntilValue.length,
11+
length: value.length,
12+
value: value
13+
});
1414
};
1515

1616
var parser = new Parser({
@@ -33,7 +33,6 @@ var parser = new Parser({
3333
}
3434
});
3535

36-
3736
module.exports = function parse(html, isRelevantTagAttr) {
3837
return parser.parse("outside", html, {
3938
currentTag: null,

package.json

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,30 @@
55
"description": "html loader module for webpack",
66
"dependencies": {
77
"es6-templates": "^0.2.2",
8-
"fastparse": "^1.0.0",
9-
"html-minifier": "^1.0.0",
10-
"loader-utils": "~0.2.2",
11-
"object-assign": "^4.0.1"
8+
"fastparse": "^1.1.1",
9+
"html-minifier": "^3.0.1",
10+
"loader-utils": "^0.2.15",
11+
"object-assign": "^4.1.0"
1212
},
1313
"devDependencies": {
14-
"mocha": "^2.3.4",
15-
"should": "^7.1.1"
14+
"beautify-lint": "^1.0.4",
15+
"codecov.io": "^0.1.6",
16+
"eslint": "^3.1.1",
17+
"istanbul": "^0.4.4",
18+
"js-beautify": "^1.6.3",
19+
"mocha": "^2.5.3",
20+
"should": "^10.0.0"
1621
},
1722
"scripts": {
18-
"test": "mocha --reporter spec"
23+
"pretest": "npm run lint && npm run beautify-lint",
24+
"test": "mocha --harmony --full-trace --check-leaks",
25+
"travis": "npm run cover -- --report lcovonly",
26+
"lint": "eslint lib bin hot",
27+
"beautify-lint": "beautify-lint lib/**/*.js hot/**/*.js bin/**/*.js benchmark/*.js test/*.js",
28+
"beautify": "beautify-rewrite lib/**/*.js hot/**/*.js bin/**/*.js benchmark/*.js test/*.js",
29+
"postcover": "npm run lint && npm run beautify-lint",
30+
"cover": "istanbul cover -x *.runtime.js node_modules/mocha/bin/_mocha",
31+
"publish-patch": "npm run lint && npm run beautify-lint && mocha && npm version patch && git push && git push --tags && npm publish"
1932
},
2033
"repository": {
2134
"type": "git",

test/loaderTest.js

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -38,31 +38,31 @@ describe("loader", function() {
3838
loader.call({
3939
minimize: true
4040
}, '<!-- comment --><h3 customAttr="">#{number} {customer}</h3>\n<p> {title} </p>\n\t <!-- comment --> <img src="image.png" />').should.be.eql(
41-
'module.exports = "<h3 customattr=\\"\\">#{number} {customer}</h3> <p> {title} </p> <img src=\\"\" + require("./image.png") + "\\\"/>";'
41+
'module.exports = "<h3 customattr=\\"\\">#{number} {customer}</h3> <p> {title} </p> <img src=\" + require("./image.png") + \" />";'
4242
);
4343
});
4444
// https://github.com/webpack/webpack/issues/752
4545
it("should not remove attributes by default", function() {
4646
loader.call({
4747
minimize: true
4848
}, '<input type="text" />').should.be.eql(
49-
'module.exports = "<input type=\\"text\\"/>";'
49+
'module.exports = "<input type=text />";'
5050
);
5151
});
5252
it("should preserve comments", function() {
5353
loader.call({
5454
minimize: true,
5555
query: "?-removeComments"
5656
}, '<!-- comment --><h3 customAttr="">#{number} {customer}</h3><p>{title}</p><!-- comment --><img src="image.png" />').should.be.eql(
57-
'module.exports = "<!-- comment --><h3 customattr=\\"\\">#{number} {customer}</h3><p>{title}</p><!-- comment --><img src=\\"\" + require("./image.png") + "\\\"/>";'
57+
'module.exports = "<!-- comment --><h3 customattr=\\"\\">#{number} {customer}</h3><p>{title}</p><!-- comment --><img src=\" + require("./image.png") + \" />";'
5858
);
5959
});
6060
it("should treat attributes as case sensitive", function() {
6161
loader.call({
6262
minimize: true,
6363
query: "?caseSensitive"
6464
}, '<!-- comment --><h3 customAttr="">#{number} {customer}</h3><p>{title}</p><!-- comment --><img src="image.png" />').should.be.eql(
65-
'module.exports = "<h3 customAttr=\\"\\">#{number} {customer}</h3><p>{title}</p><img src=\\"\" + require("./image.png") + "\\\"/>";'
65+
'module.exports = "<h3 customAttr=\\"\\">#{number} {customer}</h3><p>{title}</p><img src=\" + require("./image.png") + \" />";'
6666
);
6767
});
6868
it("should accept complex options via a webpack config property", function() {
@@ -103,20 +103,20 @@ describe("loader", function() {
103103
);
104104
});
105105
it("should ignore hash fragments in URLs", function() {
106-
loader.call({}, '<img src="icons.svg#hash">').should.be.eql(
107-
'module.exports = "<img src=\\"" + require("./icons.svg") + "#hash\\">";'
108-
);
106+
loader.call({}, '<img src="icons.svg#hash">').should.be.eql(
107+
'module.exports = "<img src=\\"" + require("./icons.svg") + "#hash\\">";'
108+
);
109109
});
110110
it("should ignore interpolations by default", function() {
111-
loader.call({}, '<img src="${"Hello " + (1+1)}">').should.be.eql(
112-
'module.exports = "<img src=\\"${\\"Hello \\" + (1+1)}\\">";'
113-
);
111+
loader.call({}, '<img src="${"Hello " + (1+1)}">').should.be.eql(
112+
'module.exports = "<img src=\\"${\\"Hello \\" + (1+1)}\\">";'
113+
);
114114
});
115115
it("should enable interpolations when using interpolate flag", function() {
116-
loader.call({
117-
query: "?interpolate"
118-
}, '<img src="${"Hello " + (1+1)}">').should.be.eql(
119-
'module.exports = "<img src=\\"" + ("Hello " + (1 + 1)) + "\\">";'
120-
);
116+
loader.call({
117+
query: "?interpolate"
118+
}, '<img src="${"Hello " + (1+1)}">').should.be.eql(
119+
'module.exports = "<img src=\\"" + ("Hello " + (1 + 1)) + "\\">";'
120+
);
121121
});
122122
});

test/parserTest.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,9 @@ function test(name, html, result) {
1010
if(tag === "div" && attr === "data-videomp4") return true;
1111
if(tag === "use" && attr === "xlink:href") return true;
1212
return false;
13-
}).map(function(match) { return match.value }).should.be.eql(result);
13+
}).map(function(match) {
14+
return match.value
15+
}).should.be.eql(result);
1416
});
1517
}
1618

@@ -36,7 +38,9 @@ describe("parser", function() {
3638

3739
describe("locations", function() {
3840
it("should report correct locations", function() {
39-
attrParse('<img src= "image.png">', function() { return true }).should.be.eql([{
41+
attrParse('<img src= "image.png">', function() {
42+
return true
43+
}).should.be.eql([{
4044
start: 12,
4145
length: 9,
4246
value: "image.png"

0 commit comments

Comments
 (0)