feat(app): Fix some obvious lint errors and warnings

This commit is contained in:
Avi Haiat 2015-07-08 15:39:02 +03:00
parent 5594eab317
commit daff7440a6
39 changed files with 67 additions and 95 deletions

View File

@ -3,13 +3,13 @@
"node": true
},
"plugins": [
"nodeca"
],
"nodeca"
],
"rules": {
"strict": 0,
"curly": 0,
"indent": [0, "tab"],
"nodeca/indent": [2, "tabs", 1 ],
"nodeca/indent": [2, "tabs", 1 ],
"eol-last": 1,
"no-shadow": 0,
"no-redeclare": 1,

View File

@ -7,8 +7,7 @@ var BasicEvaluatedExpression = require("./BasicEvaluatedExpression");
var NullFactory = require("./NullFactory");
function ConstPlugin() {
}
function ConstPlugin() {}
module.exports = ConstPlugin;
ConstPlugin.prototype.apply = function(compiler) {
@ -52,4 +51,6 @@ ConstPlugin.prototype.apply = function(compiler) {
this.state.current.addVariable("__resourceQuery", JSON.stringify(this.state.module.splitQuery(this.state.module.resource)[1]));
return true;
});
};
};

View File

@ -14,4 +14,5 @@ EvalDevToolModulePlugin.prototype.apply = function(compiler) {
compiler.plugin("compilation", function(compilation) {
compilation.moduleTemplate.apply(new EvalDevToolModuleTemplatePlugin(self.sourceUrlComment, self.moduleFilenameTemplate));
});
};
};

View File

@ -43,4 +43,4 @@ ExtendedAPIPlugin.prototype.apply = function(compiler) {
return new BasicEvaluatedExpression().setString(REPLACEMENT_TYPES[key]).setRange(expr.range);
});
});
};
};

View File

@ -15,4 +15,4 @@ FunctionModulePlugin.prototype.apply = function(compiler) {
compilation.moduleTemplate.requestShortener = this.requestShortener || new RequestShortener(compiler.context);
compilation.moduleTemplate.apply(new FunctionModuleTemplatePlugin());
}.bind(this));
};
};

View File

@ -437,4 +437,4 @@ module.exports = function() {
hotSetStatus("idle");
callback(null, outdatedModules);
}
};
};

View File

@ -22,4 +22,4 @@ HotUpdateChunkTemplate.prototype.updateHash = function(hash) {
hash.update("HotUpdateChunkTemplate");
hash.update("1");
this.applyPlugins("hash", hash);
};
};

View File

@ -29,4 +29,4 @@ IgnorePlugin.prototype.apply = function(compiler) {
return callback(null, result);
});
});
};
};

View File

@ -6,8 +6,7 @@ var JsonpMainTemplatePlugin = require("./JsonpMainTemplatePlugin");
var JsonpChunkTemplatePlugin = require("./JsonpChunkTemplatePlugin");
var JsonpHotUpdateChunkTemplatePlugin = require("./JsonpHotUpdateChunkTemplatePlugin");
function JsonpTemplatePlugin() {
}
function JsonpTemplatePlugin() {}
module.exports = JsonpTemplatePlugin;
JsonpTemplatePlugin.prototype.apply = function(compiler) {
compiler.plugin("this-compilation", function(compilation) {
@ -15,4 +14,5 @@ JsonpTemplatePlugin.prototype.apply = function(compiler) {
compilation.chunkTemplate.apply(new JsonpChunkTemplatePlugin());
compilation.hotUpdateChunkTemplate.apply(new JsonpHotUpdateChunkTemplatePlugin());
});
};
};

View File

@ -20,4 +20,4 @@ ModuleTemplate.prototype.render = function(module, dependencyTemplates, chunk) {
ModuleTemplate.prototype.updateHash = function(hash) {
hash.update("1");
this.applyPlugins("hash", hash);
};
};

View File

@ -158,4 +158,4 @@ MultiStats.prototype.toJson = function(options, forToString) {
return obj;
};
MultiStats.prototype.toString = Stats.prototype.toString;
MultiStats.prototype.toString = Stats.prototype.toString;

View File

@ -84,4 +84,4 @@ NodeStuffPlugin.prototype.apply = function(compiler) {
compiler.parser.plugin("expression module", function() {
return ModuleParserHelpers.addParsedVariable(this, "module", "require(" + JSON.stringify(path.join(__dirname, "..", "buildin", "module.js")) + ")(module)");
});
};
};

View File

@ -8,4 +8,4 @@ module.exports = OptionsApply;
OptionsApply.prototype.process = function(/* options, compiler */) {
};
};

View File

@ -2,4 +2,4 @@
MIT License http://www.opensource.org/licenses/mit-license.php
Author Tobias Koppers @sokra
*/
module.exports = require("webpack-core/lib/OriginalSource");
module.exports = require("webpack-core/lib/OriginalSource");

View File

@ -22,4 +22,4 @@ PrefetchPlugin.prototype.apply = function(compiler) {
compiler.plugin("make", function(compilation, callback) {
compilation.prefetch(this.context || compiler.context, new PrefetchDependency(this.request), callback);
}.bind(this));
};
};

View File

@ -43,4 +43,4 @@ ProvidePlugin.prototype.apply = function(compiler) {
return true;
});
}, this);
};
};

View File

@ -2,4 +2,4 @@
MIT License http://www.opensource.org/licenses/mit-license.php
Author Tobias Koppers @sokra
*/
module.exports = require("webpack-core/lib/RawSource");
module.exports = require("webpack-core/lib/RawSource");

View File

@ -35,4 +35,4 @@ RequireJsStuffPlugin.prototype.apply = function(compiler) {
this.state.current.addDependency(dep);
return true;
});
};
};

View File

@ -24,8 +24,8 @@ SetVarMainTemplatePlugin.prototype.apply = function(compilation) {
return new ConcatSource(prefix, source);
}
}.bind(this));
mainTemplate.plugin("global-hash-paths", function (paths) {
if (this.varExpression) paths.push(this.varExpression);
mainTemplate.plugin("global-hash-paths", function(paths) {
if(this.varExpression) paths.push(this.varExpression);
return paths;
});
mainTemplate.plugin("hash", function(hash) {
@ -34,3 +34,4 @@ SetVarMainTemplatePlugin.prototype.apply = function(compilation) {
hash.update(this.copyObject + "");
}.bind(this));
};

View File

@ -2,4 +2,5 @@
MIT License http://www.opensource.org/licenses/mit-license.php
Author Tobias Koppers @sokra
*/
module.exports = require("webpack-core/lib/Source");
module.exports = require("webpack-core/lib/Source");

View File

@ -2,4 +2,5 @@
MIT License http://www.opensource.org/licenses/mit-license.php
Author Tobias Koppers @sokra
*/
module.exports = require("webpack-core/lib/SourceMapSource");
module.exports = require("webpack-core/lib/SourceMapSource");

View File

@ -32,7 +32,7 @@ function TemplatedPathPlugin() {}
module.exports = TemplatedPathPlugin;
function withHashLength(replacer, handlerFn) {
return function (_, hashLength) {
return function(_, hashLength) {
var length = hashLength && parseInt(hashLength, 10);
if(length && handlerFn) {
return handlerFn(length);
@ -43,11 +43,11 @@ function withHashLength(replacer, handlerFn) {
}
function getReplacer(value, allowEmpty) {
return function (match) {
return function(match) {
// last argument in replacer is the entire input string
var input = arguments[arguments.length - 1];
if (value == null) {
if (!allowEmpty) throw new Error("Path variable " + match + " not implemented in this context: " + input);
if(value == null) {
if(!allowEmpty) throw new Error("Path variable " + match + " not implemented in this context: " + input);
return "";
} else {
return "" + value;
@ -109,3 +109,4 @@ TemplatedPathPlugin.prototype.apply = function(compiler) {
});
});
};

View File

@ -4,8 +4,7 @@
*/
var CaseSensitiveModulesWarning = require("./CaseSensitiveModulesWarning");
function WarnCaseSensitiveModulesPlugin() {
}
function WarnCaseSensitiveModulesPlugin() {}
module.exports = WarnCaseSensitiveModulesPlugin;
WarnCaseSensitiveModulesPlugin.prototype.apply = function(compiler) {
@ -25,4 +24,5 @@ WarnCaseSensitiveModulesPlugin.prototype.apply = function(compiler) {
}, this);
});
});
};
};

View File

@ -4,8 +4,8 @@ function WatchIgnorePlugin(paths) {
module.exports = WatchIgnorePlugin;
WatchIgnorePlugin.prototype.apply = function (compiler) {
compiler.plugin("after-environment", function () {
WatchIgnorePlugin.prototype.apply = function(compiler) {
compiler.plugin("after-environment", function() {
compiler.watchFileSystem = new IgnoringWatchFileSystem(compiler.watchFileSystem, this.paths);
}.bind(this));
};
@ -15,28 +15,31 @@ function IgnoringWatchFileSystem(wfs, paths) {
this.paths = paths;
}
IgnoringWatchFileSystem.prototype.watch = function (files, dirs, missing, startTime, delay, callback, callbackUndelayed) {
var ignored = function (path) {
return this.paths.some(function (p) {
IgnoringWatchFileSystem.prototype.watch = function(files, dirs, missing, startTime, delay, callback, callbackUndelayed) {
var ignored = function(path) {
return this.paths.some(function(p) {
return ((p instanceof RegExp) ? p.test(path) : path.indexOf(p) === 0);
});
}.bind(this);
var notIgnored = function (path) { return !ignored(path); };
var notIgnored = function(path) {
return !ignored(path);
};
var ignoredFiles = files.filter(ignored);
var ignoredDirs = dirs.filter(ignored);
this.wfs.watch(files.filter(notIgnored), dirs.filter(notIgnored), missing, startTime, delay, function (err, filesModified, dirsModified, fileTimestamps, dirTimestamps) {
this.wfs.watch(files.filter(notIgnored), dirs.filter(notIgnored), missing, startTime, delay, function(err, filesModified, dirsModified, fileTimestamps, dirTimestamps) {
if(err) return callback(err);
ignoredFiles.forEach(function (path) {
ignoredFiles.forEach(function(path) {
fileTimestamps[path] = 1;
});
ignoredDirs.forEach(function (path) {
ignoredDirs.forEach(function(path) {
dirTimestamps[path] = 1;
});
callback(err, filesModified, dirsModified, fileTimestamps, dirTimestamps);
}, callbackUndelayed);
};

View File

@ -111,4 +111,4 @@ AMDPlugin.prototype.apply = function(compiler) {
"webpack amd define": path.join(__dirname, "..", "..", "buildin", "amd-define.js")
})
);
};
};

View File

@ -90,4 +90,4 @@ CommonJsPlugin.prototype.apply = function(compiler) {
new CommonJsRequireDependencyParserPlugin(this.options),
new RequireResolveDependencyParserPlugin(this.options)
);
};
};

View File

@ -24,4 +24,4 @@ LabeledModulesPlugin.prototype.apply = function(compiler) {
compilation.dependencyTemplates.set(LabeledExportsDependency, new LabeledExportsDependency.Template());
});
compiler.parser.apply(new LabeledModuleDependencyParserPlugin());
};
};

View File

@ -16,4 +16,4 @@ LocalModule.prototype.flagUsed = function() {
LocalModule.prototype.variableName = function() {
return "__WEBPACK_LOCAL_MODULE_" + this.idx + "__";
};
};

View File

@ -61,4 +61,4 @@ RequireContextPlugin.prototype.apply = function(compiler) {
});
});
new RequireContextDependencyParserPlugin().apply(compiler.parser);
};
};

View File

@ -36,4 +36,4 @@ RequireEnsurePlugin.prototype.apply = function(compiler) {
this.state.current.addDependency(dep);
return true;
});
};
};

View File

@ -29,4 +29,4 @@ RequireIncludePlugin.prototype.apply = function(compiler) {
this.state.current.addDependency(dep);
return true;
});
};
};

View File

@ -23,4 +23,4 @@ NodeEnvironmentPlugin.prototype.apply = function(compiler) {
inputFileSystem.purge();
callback();
});
};
};

View File

@ -10,4 +10,4 @@ function NodeTargetPlugin() {
module.exports = NodeTargetPlugin;
NodeTargetPlugin.prototype.apply = function(compiler) {
new ExternalsPlugin("commonjs", Object.keys(process.binding("natives"))).apply(compiler);
};
};

View File

@ -3,3 +3,4 @@
Author Tobias Koppers @sokra
*/
module.exports = require("./OccurrenceOrderPlugin");

View File

@ -81,4 +81,4 @@ OccurrenceOrderPlugin.prototype.apply = function(compiler) {
});
});
});
};
};

View File

@ -10,4 +10,4 @@ module.exports = function removeAndDo(collection, thing, action) {
return true;
}
return false;
};
};

View File

@ -13,4 +13,4 @@ WebEnvironmentPlugin.prototype.apply = function(compiler) {
compiler.resolvers.context.fileSystem = inputFileSystem;
compiler.resolvers.loader.fileSystem = inputFileSystem;
compiler.outputFileSystem = this.outputFileSystem;
};
};

View File

@ -13,4 +13,4 @@ WebWorkerTemplatePlugin.prototype.apply = function(compiler) {
compilation.mainTemplate.apply(new WebWorkerMainTemplatePlugin());
compilation.chunkTemplate.apply(new WebWorkerChunkTemplatePlugin());
});
};
};

View File

@ -1,38 +0,0 @@
0 info it worked if it ends with ok
1 verbose cli [ '/Users/thaiat/.nvm/versions/node/v0.12.4/bin/node',
1 verbose cli '/Users/thaiat/.nvm/versions/node/v0.12.4/bin/npm',
1 verbose cli 'run',
1 verbose cli 'lint' ]
2 info using npm@2.10.1
3 info using node@v0.12.4
4 verbose run-script [ 'prelint', 'lint', 'postlint' ]
5 info prelint webpack@1.10.1
6 info lint webpack@1.10.1
7 verbose unsafe-perm in lifecycle true
8 info webpack@1.10.1 Failed to exec lint script
9 verbose stack Error: webpack@1.10.1 lint: `eslint lib`
9 verbose stack Exit status 1
9 verbose stack at EventEmitter.<anonymous> (/Users/thaiat/.nvm/versions/node/v0.12.4/lib/node_modules/npm/lib/utils/lifecycle.js:213:16)
9 verbose stack at EventEmitter.emit (events.js:110: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)
9 verbose stack at ChildProcess.emit (events.js:110:17)
9 verbose stack at maybeClose (child_process.js:1015:16)
9 verbose stack at Process.ChildProcess._handle.onexit (child_process.js:1087:5)
10 verbose pkgid webpack@1.10.1
11 verbose cwd /Users/thaiat/Documents/Phonegap/webpack
12 error Darwin 14.4.0
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"
14 error node v0.12.4
15 error npm v2.10.1
16 error code ELIFECYCLE
17 error webpack@1.10.1 lint: `eslint lib`
17 error Exit status 1
18 error Failed at the webpack@1.10.1 lint script 'eslint lib'.
18 error This is most likely a problem with the webpack package,
18 error not with npm itself.
18 error Tell the author that this fails on your system:
18 error eslint lib
18 error You can get their info via:
18 error npm owner ls webpack
18 error There is likely additional logging output above.
19 verbose exit [ 1, true ]