Skip to content

Commit

Permalink
Merge pull request #143 from d3viant0ne/d3viant0ne-CodeQualityTooling
Browse files Browse the repository at this point in the history
chore(style): Bring code quality tooling inline with Webpack
  • Loading branch information
MikaAK authored Jul 23, 2016
2 parents db8e3f8 + d3adfc5 commit 2b18d78
Show file tree
Hide file tree
Showing 6 changed files with 81 additions and 19 deletions.
5 changes: 5 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
root = true

[*.js]
indent_style=tab
trim_trailing_whitespace=true
24 changes: 24 additions & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"env": {
"node": true
},
"rules": {
"strict": 0,
"camelcase": 0,
"curly": 0,
"indent": [2, "tab", { "SwitchCase": 1 }],
"eol-last": 1,
"no-shadow": 0,
"no-redeclare": 2,
"no-extra-bind": 1,
"no-empty": 0,
"no-process-exit": 1,
"no-underscore-dangle": 0,
"no-use-before-define": 0,
"no-unused-vars": 0,
"consistent-return": 0,
"no-inner-declarations": 1,
"no-loop-func": 1,
"space-before-function-paren": [2, "never"]
}
}
25 changes: 25 additions & 0 deletions .jsbeautifyrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"js": {
"allowed_file_extensions": ["js", "json", "jshintrc", "jsbeautifyrc"],
"brace_style": "collapse",
"break_chained_methods": false,
"e4x": true,
"eval_code": false,
"end_with_newline": true,
"indent_char": "\t",
"indent_level": 0,
"indent_size": 1,
"indent_with_tabs": true,
"jslint_happy": false,
"jslint_happy_align_switch_case": true,
"space_after_anon_function": false,
"keep_array_indentation": false,
"keep_function_indentation": false,
"max_preserve_newlines": 2,
"preserve_newlines": true,
"space_before_conditional": false,
"space_in_paren": false,
"unescape_strings": false,
"wrap_line_length": 0
}
}
30 changes: 15 additions & 15 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@ var webpack = require("webpack");
var SingleEntryDependency = require("webpack/lib/dependencies/SingleEntryDependency");

function Plugin(
/* config.webpack */webpackOptions,
/* config.webpackServer */webpackServerOptions,
/* config.webpackMiddleware */webpackMiddlewareOptions,
/* config.basePath */basePath,
/* config.files */files,
/* config.frameworks */frameworks,
customFileHandlers,
emitter) {
webpackOptions, /* config.webpack */
webpackServerOptions, /* config.webpackServer */
webpackMiddlewareOptions, /* config.webpackMiddleware */
basePath, /* config.basePath */
files, /* config.files */
frameworks, /* config.frameworks */
customFileHandlers,
emitter) {
webpackOptions = _.clone(webpackOptions) || {};
webpackMiddlewareOptions = _.clone(webpackMiddlewareOptions || webpackServerOptions) || {};

Expand Down Expand Up @@ -97,7 +97,7 @@ function Plugin(
}
});

emitter.on("exit", function (done) {
emitter.on("exit", function(done) {
middleware.close();
done();
});
Expand All @@ -117,7 +117,7 @@ Plugin.prototype.addFile = function(entry) {
Plugin.prototype.make = function(compilation, callback) {
async.forEach(this.files.slice(), function(file, callback) {
var entry = file;
if (this.wrapMocha) {
if(this.wrapMocha) {
entry = require.resolve("./mocha-env-loader") + "!" + entry;
}

Expand Down Expand Up @@ -159,22 +159,22 @@ Plugin.prototype.readFile = function(file, callback) {
if(!this.waiting)
doRead();
else
// Retry to read once a build is finished
// do it on process.nextTick to catch changes while building
// Retry to read once a build is finished
// do it on process.nextTick to catch changes while building
this.waiting.push(process.nextTick.bind(process, this.readFile.bind(this, file, callback)));
};

function createPreprocesor(/* config.basePath */basePath, webpackPlugin) {
function createPreprocesor( /* config.basePath */ basePath, webpackPlugin) {
return function(content, file, done) {

if (webpackPlugin.addFile(file.path)) {
if(webpackPlugin.addFile(file.path)) {
// recompile as we have an asset that we have not seen before
webpackPlugin.middleware.invalidate();
}

// read blocks until bundle is done
webpackPlugin.readFile(path.relative(basePath, file.path), function(err, content) {
if (err) {
if(err) {
throw err;
}

Expand Down
2 changes: 1 addition & 1 deletion mocha-env-loader.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ module.exports = function(content, map) {

var concatSrc = new SourceNode();
concatSrc.add([
"describe(" + JSON.stringify(id) + ", function() {\n",
"describe(" + JSON.stringify(id) + ", function() {\n",
sourceNode,
"\n});"
]);
Expand Down
14 changes: 11 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,19 @@
"webpack-dev-middleware": "^1.0.11"
},
"devDependencies": {
"beautify-lint": "^1.0.4",
"coffee-loader": "~0.7.2",
"eslint": "^3.1.1",
"jsbeautify": "^0.3.6",
"karma": ">=0.13.2 < 1",
"karma-mocha": "~0.1.9",
"karma-chrome-launcher": "~0.1.5",
"karma-spec-reporter": "~0.0.16",
"coffee-loader": "~0.7.2"
"karma-mocha": "~0.1.9",
"karma-spec-reporter": "~0.0.16"
},
"scripts": {
"pretest": "npm run lint && npm run beautify-lint",
"lint": "eslint lib",
"beautify-lint": "beautify-lint *.js"
},
"license": "MIT",
"homepage": "http://github.com/webpack/karma-webpack",
Expand Down

0 comments on commit 2b18d78

Please sign in to comment.