Skip to content

Commit 5594eab

Browse files
committed
feat(app): Improve eslint and jsbeautify
1 parent 07c9852 commit 5594eab

9 files changed

Lines changed: 122 additions & 46 deletions

File tree

‎.eslintrc‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,14 @@
22
"env": {
33
"node": true
44
},
5+
"plugins": [
6+
"nodeca"
7+
],
58
"rules": {
69
"strict": 0,
710
"curly": 0,
11+
"indent": [0, "tab"],
12+
"nodeca/indent": [2, "tabs", 1 ],
813
"eol-last": 1,
914
"no-shadow": 0,
1015
"no-redeclare": 1,
@@ -13,6 +18,7 @@
1318
"no-use-before-define": 0,
1419
"consistent-return": 0,
1520
"no-inner-declarations": 1,
16-
"no-loop-func": 1
21+
"no-loop-func": 1,
22+
"space-before-function-paren": [2, "never"]
1723
}
1824
}

‎.gitignore‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@
55
/benchmark/fixtures
66
/examples/*/js
77
/coverage
8-
.DS_Store
8+
.DS_Store

‎.jsbeautifyrc‎

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

‎lib/APIPlugin.js‎

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,7 @@ var BasicEvaluatedExpression = require("./BasicEvaluatedExpression");
77

88
var NullFactory = require("./NullFactory");
99

10-
function APIPlugin() {
11-
}
10+
function APIPlugin() {}
1211
module.exports = APIPlugin;
1312

1413
var REPLACEMENTS = {
@@ -25,8 +24,7 @@ var REPLACEMENT_TYPES = {
2524
__webpack_modules__: "object", // eslint-disable-line camelcase
2625
__webpack_chunk_load__: "function" // eslint-disable-line camelcase
2726
};
28-
var IGNORES = [
29-
];
27+
var IGNORES = [];
3028
APIPlugin.prototype.apply = function(compiler) {
3129
compiler.plugin("compilation", function(compilation) {
3230
compilation.dependencyFactories.set(ConstDependency, new NullFactory());
@@ -48,4 +46,5 @@ APIPlugin.prototype.apply = function(compiler) {
4846
return true;
4947
});
5048
});
51-
};
49+
};
50+

‎lib/CachePlugin.js‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,4 +40,4 @@ CachePlugin.prototype.apply = function(compiler) {
4040
callback();
4141
});
4242
}
43-
};
43+
};

‎lib/Compilation.js‎

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,7 @@ Compilation.prototype.buildModule = function(module, thisCallback) {
114114
this.applyPlugins("build-module", module);
115115
if(module.building) return module.building.push(thisCallback);
116116
var building = module.building = [thisCallback];
117+
117118
function callback(err) {
118119
module.building = undefined;
119120
building.forEach(function(cb) {
@@ -140,6 +141,7 @@ Compilation.prototype.buildModule = function(module, thisCallback) {
140141

141142
Compilation.prototype.processModuleDependencies = function(module, callback) {
142143
var dependencies = [];
144+
143145
function addDependency(dep) {
144146
for(var i = 0; i < dependencies.length; i++) {
145147
if(dep.isEqualResource(dependencies[i][0])) {
@@ -148,6 +150,7 @@ Compilation.prototype.processModuleDependencies = function(module, callback) {
148150
}
149151
dependencies.push([dep]);
150152
}
153+
151154
function addDependenciesBlock(block) {
152155
if(block.dependencies) {
153156
block.dependencies.forEach(addDependency);
@@ -211,6 +214,7 @@ Compilation.prototype.addModuleDependencies = function(module, dependencies, bai
211214
return !d.optional;
212215
}).length === 0;
213216
}
217+
214218
function errorOrWarningAndCallback(err) {
215219
if(isOptional()) {
216220
return warningAndCallback(err);
@@ -455,6 +459,7 @@ Compilation.prototype.rebuildModule = function(module, thisCallback) {
455459
return module.rebuilding.push(thisCallback);
456460
}
457461
var rebuilding = module.rebuilding = [thisCallback];
462+
458463
function callback(err) {
459464
module.rebuilding = undefined;
460465
rebuilding.forEach(function(cb) {
@@ -624,6 +629,7 @@ Compilation.prototype.processDependenciesBlockForChunk = function processDepende
624629
this.processDependenciesBlockForChunk(b, c);
625630
}, this);
626631
}
632+
627633
function iteratorDependency(d) {
628634
if(!d.module) {
629635
return;
@@ -656,6 +662,7 @@ Compilation.prototype.removeChunkFromDependencies = function removeChunkFromDepe
656662
this.removeChunkFromDependencies(b, c);
657663
}, this);
658664
}, this);
665+
659666
function iteratorDependency(d) {
660667
if(!d.module) {
661668
return;
@@ -814,7 +821,7 @@ Compilation.prototype.createChunkAssets = function createChunkAssets() {
814821
var chunkHash = chunk.hash;
815822
var source;
816823
var file;
817-
var filenameTemplate = chunk.filenameTemplate ? chunk.filenameTemplate :
824+
var filenameTemplate = chunk.filenameTemplate ? chunk.filenameTemplate :
818825
chunk.initial ? filename :
819826
chunkFilename;
820827
try {
@@ -860,7 +867,7 @@ Compilation.prototype.createChunkAssets = function createChunkAssets() {
860867
}
861868
};
862869

863-
Compilation.prototype.getPath = function (filename, data) {
870+
Compilation.prototype.getPath = function(filename, data) {
864871
data = data || {};
865872
data.hash = data.hash || this.hash;
866873
return this.mainTemplate.applyPluginsWaterfall("asset-path", filename, data);

‎lib/ExternalModule.js‎

Lines changed: 35 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -41,41 +41,41 @@ ExternalModule.prototype.source = function() {
4141
var request = this.request;
4242
if(typeof request === "object") request = request[this.type];
4343
switch(this.type) {
44-
case "this":
45-
case "window":
46-
case "global":
47-
if(Array.isArray(request)) {
48-
str = "(function() { module.exports = " + this.type + request.map(function(r) {
49-
return "[" + JSON.stringify(r) + "]";
50-
}).join("") + "; }());";
51-
} else
52-
str = "(function() { module.exports = " + this.type + "[" + JSON.stringify(request) + "]; }());";
53-
break;
54-
case "commonjs":
55-
case "commonjs2":
56-
if(Array.isArray(request)) {
57-
str = "module.exports = require(" + JSON.stringify(request[0]) + ")" + request.slice(1).map(function(r) {
58-
return "[" + JSON.stringify(r) + "]";
59-
}).join("") + ";";
60-
} else
61-
str = "module.exports = require(" + JSON.stringify(request) + ");";
62-
break;
63-
case "amd":
64-
case "umd":
65-
case "umd2":
66-
str = "";
67-
if(this.optional) {
68-
str += "if(typeof __WEBPACK_EXTERNAL_MODULE_" + this.id + "__ === 'undefined') {" + WebpackMissingModule.moduleCode(request) + "}\n";
69-
}
70-
str += "module.exports = __WEBPACK_EXTERNAL_MODULE_" + this.id + "__;";
71-
break;
72-
default:
73-
str = "";
74-
if(this.optional) {
75-
str += "if(typeof " + request + " === 'undefined') {" + WebpackMissingModule.moduleCode(request) + "}\n";
76-
}
77-
str += "module.exports = " + request + ";";
78-
break;
44+
case "this":
45+
case "window":
46+
case "global":
47+
if(Array.isArray(request)) {
48+
str = "(function() { module.exports = " + this.type + request.map(function(r) {
49+
return "[" + JSON.stringify(r) + "]";
50+
}).join("") + "; }());";
51+
} else
52+
str = "(function() { module.exports = " + this.type + "[" + JSON.stringify(request) + "]; }());";
53+
break;
54+
case "commonjs":
55+
case "commonjs2":
56+
if(Array.isArray(request)) {
57+
str = "module.exports = require(" + JSON.stringify(request[0]) + ")" + request.slice(1).map(function(r) {
58+
return "[" + JSON.stringify(r) + "]";
59+
}).join("") + ";";
60+
} else
61+
str = "module.exports = require(" + JSON.stringify(request) + ");";
62+
break;
63+
case "amd":
64+
case "umd":
65+
case "umd2":
66+
str = "";
67+
if(this.optional) {
68+
str += "if(typeof __WEBPACK_EXTERNAL_MODULE_" + this.id + "__ === 'undefined') {" + WebpackMissingModule.moduleCode(request) + "}\n";
69+
}
70+
str += "module.exports = __WEBPACK_EXTERNAL_MODULE_" + this.id + "__;";
71+
break;
72+
default:
73+
str = "";
74+
if(this.optional) {
75+
str += "if(typeof " + request + " === 'undefined') {" + WebpackMissingModule.moduleCode(request) + "}\n";
76+
}
77+
str += "module.exports = " + request + ";";
78+
break;
7979
}
8080
if(this.useSourceMap) {
8181
return new OriginalSource(str, this.identifier());

‎npm-debug.log‎

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
0 info it worked if it ends with ok
2+
1 verbose cli [ '/Users/thaiat/.nvm/versions/node/v0.12.4/bin/node',
3+
1 verbose cli '/Users/thaiat/.nvm/versions/node/v0.12.4/bin/npm',
4+
1 verbose cli 'run',
5+
1 verbose cli 'lint' ]
6+
2 info using npm@2.10.1
7+
3 info using node@v0.12.4
8+
4 verbose run-script [ 'prelint', 'lint', 'postlint' ]
9+
5 info prelint webpack@1.10.1
10+
6 info lint webpack@1.10.1
11+
7 verbose unsafe-perm in lifecycle true
12+
8 info webpack@1.10.1 Failed to exec lint script
13+
9 verbose stack Error: webpack@1.10.1 lint: `eslint lib`
14+
9 verbose stack Exit status 1
15+
9 verbose stack at EventEmitter.<anonymous> (/Users/thaiat/.nvm/versions/node/v0.12.4/lib/node_modules/npm/lib/utils/lifecycle.js:213:16)
16+
9 verbose stack at EventEmitter.emit (events.js:110:17)
17+
9 verbose stack at ChildProcess.<anonymous> (/Users/thaiat/.nvm/versions/node/v0.12.4/lib/node_modules/npm/lib/utils/spawn.js:24:14)
18+
9 verbose stack at ChildProcess.emit (events.js:110:17)
19+
9 verbose stack at maybeClose (child_process.js:1015:16)
20+
9 verbose stack at Process.ChildProcess._handle.onexit (child_process.js:1087:5)
21+
10 verbose pkgid webpack@1.10.1
22+
11 verbose cwd /Users/thaiat/Documents/Phonegap/webpack
23+
12 error Darwin 14.4.0
24+
13 error argv "/Users/thaiat/.nvm/versions/node/v0.12.4/bin/node" "/Users/thaiat/.nvm/versions/node/v0.12.4/bin/npm" "run" "lint"
25+
14 error node v0.12.4
26+
15 error npm v2.10.1
27+
16 error code ELIFECYCLE
28+
17 error webpack@1.10.1 lint: `eslint lib`
29+
17 error Exit status 1
30+
18 error Failed at the webpack@1.10.1 lint script 'eslint lib'.
31+
18 error This is most likely a problem with the webpack package,
32+
18 error not with npm itself.
33+
18 error Tell the author that this fails on your system:
34+
18 error eslint lib
35+
18 error You can get their info via:
36+
18 error npm owner ls webpack
37+
18 error There is likely additional logging output above.
38+
19 verbose exit [ 1, true ]

‎package.json‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
"async": "~0.9.0",
88
"clone": "~1.0.2",
99
"enhanced-resolve": "~0.8.2",
10+
"eslint-plugin-nodeca": "^1.0.3",
1011
"esprima": "~1.2.0",
1112
"interpret": "^0.5.2",
1213
"memory-fs": "~0.2.0",
@@ -30,7 +31,7 @@
3031
"component-webpack-plugin": "~0.2.0",
3132
"coveralls": "^2.11.2",
3233
"css-loader": "~0.14.0",
33-
"eslint": "^0.21.0",
34+
"eslint": "^0.24.0",
3435
"express": "~3.4.8",
3536
"extract-text-webpack-plugin": "~0.8.0",
3637
"file-loader": "~0.8.0",

0 commit comments

Comments
 (0)