Skip to content

Commit

Permalink
Updated lint rules & src files
Browse files Browse the repository at this point in the history
  • Loading branch information
Vitaly Puzrin committed Jan 3, 2014
1 parent 1f1d888 commit 400e1bc
Show file tree
Hide file tree
Showing 43 changed files with 249 additions and 242 deletions.
31 changes: 16 additions & 15 deletions .jshintrc
Original file line number Diff line number Diff line change
Expand Up @@ -2,33 +2,35 @@
// Enforcing Options /////////////////////////////////////////////////////////

"bitwise" : true, // Prohibit bitwise operators (&, |, ^, etc.).
"camelcase" : false, // Require variable names to be camelCase style or UPPER_CASE
"camelcase" : false, // true: Identifiers must be in camelCase
"curly" : true, // Require {} for every new block or scope.
"eqeqeq" : true, // Require triple equals i.e. `===`.
"forin" : false, // Tolerate `for in` loops without `hasOwnPrototype`.
"immed" : true, // Require immediate invocations to be wrapped in parens e.g. `( function(){}() );`
"indent" : 2, // This option enforces specific tab width for your code
"indent" : 2, // Specify indentation spacing
"latedef" : true, // Prohibit hariable use before definition.
"newcap" : true, // Require capitalization of all constructor functions e.g. `new F()`.
"noarg" : true, // Prohibit use of `arguments.caller` and `arguments.callee`.
"noempty" : true, // Prohibit use of empty blocks.
"nonew" : true, // Prohibit use of constructors for side-effects.
"plusplus" : false, // Prohibit use of `++` & `--`.
"quotmark" : false, // Enforces the consistency of quotation marks used throughout your code.
"regexp" : false, // Prohibit `.` and `[^...]` in regular expressions.
"quotmark" : "single", // Quotation mark consistency:
// false : do nothing (default)
// true : ensure whatever is used is consistent
// "single" : require single quotes
// "double" : require double quotes
"undef" : true, // Require all non-global variables be declared before they are used.
"unused" : true, // This option warns when you define and never use your variables.
"unused" : true, // Warns when you define and never use your variables
"strict" : true, // Require `use strict` pragma in every file.
"trailing" : true, // Prohibit trailing whitespaces.
"maxstatements" : false, // Enforce max amount of statements per function
"maxcomplexity" : false, // Enforce cyclomatic complexity level

// Relaxing Options //////////////////////////////////////////////////////////

"asi" : false, // Tolerate Automatic Semicolon Insertion (no semicolons).
"boss" : false, // Tolerate assignments inside if, for & while. Usually conditions & loops are for comparison, not assignments.
"debug" : false, // Allow debugger statements e.g. browser breakpoints.
"eqnull" : false, // Tolerate use of `== null`.
//"es5" : true, // Allow ECMAScript 5 syntax.
"esnext" : false, // Allow ES.next specific features such as const and let
"evil" : false, // Tolerate use of `eval`.
"expr" : false, // Tolerate `ExpressionStatement` as Programs.
Expand All @@ -40,14 +42,13 @@
"laxcomma" : true, // This option suppresses warnings about comma-first coding style
"loopfunc" : false, // Allow functions to be defined within loops.
"multistr" : false, // Tolerate multi-line strings.
"onecase" : false, // Tolerate swithes with only one case.
"proto" : false, // Allow usage of __proto__ property.
"regexdash" : false, // Tolerate unescaped last dash i.e. `[-...]`.
"scripturl" : true, // Tolerate script-targeted URLs.
"scripturl" : false, // Tolerate script-targeted URLs.
"smarttabs" : false, // Allow mixed tabs and spaces when the latter are used for alignmnent only.
"shadow" : false, // Allows re-define variables later in code e.g. `var x=1; x=2;`.
"sub" : true, // Tolerate all forms of subscript notation besides dot notation e.g. `dict['key']` instead of `dict.key`.
"supernew" : true, // Tolerate `new function () { ... };` and `new Object;`.
"sub" : false, // Tolerate all forms of subscript notation besides dot notation e.g. `dict['key']` instead of `dict.key`.
"supernew" : false, // Tolerate `new function () { ... };` and `new Object;`.
"validthis" : false, // true: Tolerate using this in a non-constructor function

// Environments //////////////////////////////////////////////////////////////

Expand All @@ -61,8 +62,8 @@
"nonstandard" : false, // Defines non-standard but widely adopted globals such as escape and unescape
"prototypejs" : false, // Defines globals exposed by the Prototype
"rhino" : false, // Defines globals exposed when running under Rhino
"worker" : false, // Defines globals exposed when running Web Worker
"wsh" : false, // Defines globals exposed when running under WSH
"yui" : false, // Yahoo User Interface

// Legacy ////////////////////////////////////////////////////////////////////

Expand All @@ -71,7 +72,7 @@
"passfail" : false, // Stop on first error.
"white" : false, // Check against strict whitespace and indentation rules.

// Other /////////////////////////////////////////////////////////////////////
// Custom globals ///////////////////////////////////////////////////////////

"maxerr" : 100 // Maximum error before stopping.
"globals" : { }
}
4 changes: 2 additions & 2 deletions bin/mincer.js
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ if (1 === filenames.length) {
var asset = environment.findAsset(filenames[0]);

if (!asset) {
console.error("Cannot find logical path: " + filenames[0]);
console.error('Cannot find logical path: ' + filenames[0]);
process.exit(1);
}

Expand All @@ -130,5 +130,5 @@ if (1 === filenames.length) {
}


console.error("Only one file can be compiled to stdout at a time");
console.error('Only one file can be compiled to stdout at a time');
process.exit(1);
3 changes: 3 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
'use strict';


module.exports = require('./lib/mincer');
12 changes: 6 additions & 6 deletions lib/mincer.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@


// Node < 0.8 shims
var fs = require("fs");
var path = require("path");
var fs = require('fs');
var path = require('path');

fs.exists = fs.exists || path.exists;
fs.existsSync = fs.existsSync || path.existsSync;
Expand Down Expand Up @@ -228,7 +228,7 @@ prop(Mincer, 'logger', require('./mincer/logger'));

// main internal properties.
// each new environment clone these properties for initial states,
// so they can be used to set "defaults" for all environment instances.
// so they can be used to set 'defaults' for all environment instances.
prop(Mincer, '__trail__', new Trail(__dirname));
prop(Mincer, '__engines__', {});
prop(Mincer, '__mimeTypes__', new Mimoza());
Expand Down Expand Up @@ -303,11 +303,11 @@ Mincer.registerEngine('.jade', Mincer.JadeEngine);
// Configurations //////////////////////////////////////////////////////////////


Mincer.registerConfiguration("autoprefixer", {
Mincer.registerConfiguration('autoprefixer', {
enable: function (self) {
self.registerPostProcessor("text/css", Mincer.Autoprefixer);
self.registerPostProcessor('text/css', Mincer.Autoprefixer);
},
disable: function (self) {
self.unregisterPostProcessor("text/css", Mincer.Autoprefixer);
self.unregisterPostProcessor('text/css', Mincer.Autoprefixer);
}
});
18 changes: 9 additions & 9 deletions lib/mincer/asset_attributes.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ var AssetAttributes = module.exports = function AssetAttributes(environment, pat
**/
getter(AssetAttributes.prototype, 'searchPaths', function () {
var paths = [this.pathname],
exts = this.extensions.join(""),
exts = this.extensions.join(''),
path_without_extensions;

path_without_extensions = this.extensions.reduce(function (p, ext) {
Expand All @@ -52,13 +52,13 @@ getter(AssetAttributes.prototype, 'searchPaths', function () {

// optimization: component.json can only be nested one level deep
if (-1 === path_without_extensions.indexOf(path.sep)) {
paths.push(path.join(path_without_extensions, "bower.json"));
paths.push(path.join(path_without_extensions, 'bower.json'));
// DEPRECATED bower configuration file
paths.push(path.join(path_without_extensions, "component.json"));
paths.push(path.join(path_without_extensions, 'component.json'));
}

if ('index' !== path.basename(this.pathname, exts)) {
paths.push(path.join(path_without_extensions, "index" + exts));
paths.push(path.join(path_without_extensions, 'index' + exts));
}

return paths;
Expand All @@ -83,14 +83,14 @@ getter(AssetAttributes.prototype, 'logicalPath', function () {
});

if (!root_path) {
throw new Error("File outside paths: " + pathname + " isn't in paths: " +
paths.join(", "));
throw new Error('File outside paths: ' + pathname + ' isn\'t in paths: ' +
paths.join(', '));
}

pathname = pathname.replace(root_path + path.sep, "");
pathname = pathname.replace(root_path + path.sep, '');
pathname = pathname.replace(/\\/g, '/');
pathname = this.engineExtensions.reduce(function (p, ext) {
return p.replace(ext, "");
return p.replace(ext, '');
}, pathname);

if (!this.formatExtension) {
Expand All @@ -115,7 +115,7 @@ getter(AssetAttributes.prototype, 'extensions', function () {
if (!this.__extensions__) {
extensions = path.basename(this.pathname).split('.').slice(1);
prop(this, '__extensions__', extensions.map(function (ext) {
return "." + ext;
return '.' + ext;
}));
}

Expand Down
40 changes: 20 additions & 20 deletions lib/mincer/assets/asset.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ function stub_getter(name) {
getter(Asset.prototype, name, function () {
// this should never happen, as Asset is an abstract class and not
// supposed to be used directly. subclasses must override this getters
throw new Error(this.constructor.name + "#" + name + " getter is not implemented.");
throw new Error(this.constructor.name + '#' + name + ' getter is not implemented.');
});
}

Expand Down Expand Up @@ -234,7 +234,7 @@ var copier = {
Asset.prototype.writeTo = function (filename, options, callback) {
var self = this,
mtime = this.mtime,
tempname = filename + "+",
tempname = filename + '+',
copy_fn;

options = options || {};
Expand Down Expand Up @@ -268,8 +268,8 @@ function escapeRegexp(str) {


Asset.prototype.relativizeRootPath = function (pathname) {
var re = new RegExp("^" + escapeRegexp(this.root));
return String(pathname).replace(re, "$root");
var re = new RegExp('^' + escapeRegexp(this.root));
return String(pathname).replace(re, '$root');
};


Expand All @@ -280,25 +280,25 @@ Asset.prototype.expandRootPath = function (pathname) {


Asset.prototype.encodeWith = function (hash) {
hash['type'] = this.type;
hash['logicalPath'] = this.logicalPath;
hash['pathname'] = this.relativizeRootPath(this.pathname);
hash['contentType'] = this.contentType;
hash['mtime'] = this.mtime.getTime();
hash['length'] = this.length;
hash['digest'] = this.digest;
hash.type = this.type;
hash.logicalPath = this.logicalPath;
hash.pathname = this.relativizeRootPath(this.pathname);
hash.contentType = this.contentType;
hash.mtime = this.mtime.getTime();
hash.length = this.length;
hash.digest = this.digest;
};


Asset.prototype.initWith = function (environment, hash) {
prop(this, 'root', environment.root);
prop(this, 'environment', environment);
prop(this, 'logicalPath', hash['logicalPath']);
prop(this, 'pathname', this.expandRootPath(hash['pathname']));
prop(this, 'contentType', hash['contentType']);
prop(this, 'mtime', new Date(hash['mtime']), {writable: true});
prop(this, 'length', hash['length'], {writable: true});
prop(this, 'digest', hash['digest'], {writable: true});
prop(this, 'logicalPath', hash.logicalPath);
prop(this, 'pathname', this.expandRootPath(hash.pathname));
prop(this, 'contentType', hash.contentType);
prop(this, 'mtime', new Date(hash.mtime), {writable: true});
prop(this, 'length', hash.length, {writable: true});
prop(this, 'digest', hash.digest, {writable: true});

prop(this, '__requiredAssets__', [], {writable: true});
prop(this, '__dependencyPaths__', [], {writable: true});
Expand All @@ -310,18 +310,18 @@ Asset.fromHash = function (environment, hash) {
var asset, klass;

if (_.isPlainObject(hash)) {
klass = typeToClass(hash['type']);
klass = typeToClass(hash.type);

if (klass) {
asset = Object.create(klass.prototype);
prop(asset, 'type', hash['type']); // KLUDGE: Use constructor.name
prop(asset, 'type', hash.type); // KLUDGE: Use constructor.name
asset.initWith(environment, hash);
}
}

return asset;
} catch (e) {
if ("unserialize_error" === e.code) {
if ('unserialize_error' === e.code) {
// do nothing
return;
}
Expand Down
14 changes: 7 additions & 7 deletions lib/mincer/assets/bundled.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ var Asset = require('./asset');
* See [[Asset.new]] for details.
**/
var BundledAsset = module.exports = function BundledAsset() {
var processedAsset, Klass, context, processors, options, source = "";
var processedAsset, Klass, context, processors, options, source = '';

Asset.apply(this, arguments);
prop(this, 'type', 'bundled');
Expand Down Expand Up @@ -118,23 +118,23 @@ BundledAsset.prototype.isFresh = function (environment) {
BundledAsset.prototype.encodeWith = function (hash) {
Asset.prototype.encodeWith.call(this, hash);

hash['source'] = this.__source__;
hash['requiredAssetsDigest'] = this.__processedAsset__.dependencyDigest;
hash.source = this.__source__;
hash.requiredAssetsDigest = this.__processedAsset__.dependencyDigest;
};


BundledAsset.prototype.initWith = function (environment, hash) {
Asset.prototype.initWith.call(this, environment, hash);

this.__source__ = hash['source'];
this.__source__ = hash.source;

prop(this, '__processedAsset__', environment.findAsset(this.pathname, { bundle: false }));
prop(this, '__requiredAssets__', this.__processedAsset__.__requiredAssets__);

if (this.__processedAsset__.dependencyDigest !== hash['requiredAssetsDigest']) {
if (this.__processedAsset__.dependencyDigest !== hash.requiredAssetsDigest) {
throw {
code: "unserialize_error",
message: "processed asset belongs to a stale environment"
code: 'unserialize_error',
message: 'processed asset belongs to a stale environment'
};
}
};
20 changes: 10 additions & 10 deletions lib/mincer/assets/processed.js
Original file line number Diff line number Diff line change
Expand Up @@ -179,15 +179,15 @@ getter(ProcessedAsset.prototype, 'source', function () {
ProcessedAsset.prototype.encodeWith = function (hash) {
Asset.prototype.encodeWith.call(this, hash);

hash['source'] = this.__source__;
hash['dependencyDigest'] = this.dependencyDigest;
hash.source = this.__source__;
hash.dependencyDigest = this.dependencyDigest;

hash['requiredPaths'] = this.__requiredAssets__.map(function (asset) {
hash.requiredPaths = this.__requiredAssets__.map(function (asset) {
return this.relativizeRootPath(asset.pathname);
}, this);


hash['dependencyPaths'] = this.__dependencyPaths__.map(function (dep) {
hash.dependencyPaths = this.__dependencyPaths__.map(function (dep) {
return {
path: this.relativizeRootPath(dep.pathname),
mtime: dep.mtime.getTime(),
Expand All @@ -201,11 +201,11 @@ ProcessedAsset.prototype.encodeWith = function (hash) {
ProcessedAsset.prototype.initWith = function (environment, hash) {
Asset.prototype.initWith.call(this, environment, hash);

this.__source__ = hash['source'];
this.__source__ = hash.source;

prop(this, 'dependencyDigest', hash['dependencyDigest']);
prop(this, 'dependencyDigest', hash.dependencyDigest);

prop(this, '__requiredAssets__', hash['requiredPaths'].map(function (p) {
prop(this, '__requiredAssets__', hash.requiredPaths.map(function (p) {
var root;

p = this.expandRootPath(p);
Expand All @@ -215,15 +215,15 @@ ProcessedAsset.prototype.initWith = function (environment, hash) {

if (!root) {
throw {
code: "unserialize_error",
message: p + " isn't in paths"
code: 'unserialize_error',
message: p + ' isn\'t in paths'
};
}

return p === this.pathname ? this : environment.findAsset(p, { bundle: false });
}, this));

prop(this, '__dependencyPaths__', hash['dependencyPaths'].map(function (h) {
prop(this, '__dependencyPaths__', hash.dependencyPaths.map(function (h) {
return new DependencyFile(this.expandRootPath(h.path), new Date(h.mtime), h.digest);
}, this));
};
Loading

0 comments on commit 400e1bc

Please sign in to comment.