Permalink
Browse files

Code style (jscs)

  • Loading branch information...
1 parent 2f55410 commit c19d6456d9a2d7e264d5772565de295a6ff586b7 @iamvdo committed Mar 1, 2015
Showing with 491 additions and 420 deletions.
  1. +61 −0 .jscsrc
  2. +11 −0 Gulpfile.js
  3. +47 −46 lib/browsers.js
  4. +227 −231 lib/options.js
  5. +103 −103 lib/pleeease.js
  6. +8 −6 lib/preprocessor.js
  7. +1 −1 lib/processors/opacity.js
  8. +13 −13 lib/processors/pseudoElements.js
  9. +1 −0 package.json
  10. +2 −2 test/_helpers.js
  11. +1 −1 test/browsers.js
  12. +2 −2 test/features.js
  13. +3 −3 test/options.js
  14. +4 −4 test/pleeease.js
  15. +2 −2 test/preprocessor.js
  16. +5 −6 test/sourcemaps.js
View
@@ -0,0 +1,61 @@
+{
+ "requireCurlyBraces": [
+ "if",
+ "else",
+ "for",
+ "while",
+ "do",
+ "try",
+ "catch"
+ ],
+ "requireOperatorBeforeLineBreak": true,
+ "requireCamelCaseOrUpperCaseIdentifiers": true,
+ "maximumLineLength": {
+ "value": 120,
+ "allowComments": true,
+ "allowRegex": true
+ },
+ "validateIndentation": 2,
+ "validateQuoteMarks": "'",
+
+ "disallowMultipleLineStrings": true,
+ "disallowMixedSpacesAndTabs": true,
+ "disallowTrailingWhitespace": true,
+ "disallowSpaceAfterPrefixUnaryOperators": true,
+ "disallowMultipleVarDecl": "exceptUndefined",
+ "disallowKeywordsOnNewLine": ["else"],
+
+ "requireSpaceAfterKeywords": [
+ "if",
+ "else",
+ "for",
+ "while",
+ "do",
+ "switch",
+ "return",
+ "try",
+ "catch"
+ ],
+ "requireSpaceBeforeBinaryOperators": [
+ "=", "+=", "-=", "*=", "/=", "%=", "<<=", ">>=", ">>>=",
+ "&=", "|=", "^=", "+=",
+
+ "+", "-", "*", "/", "%", "<<", ">>", ">>>", "&",
+ "|", "^", "&&", "||", "===", "==", ">=",
+ "<=", "<", ">", "!=", "!=="
+ ],
+ "requireSpaceAfterBinaryOperators": true,
+ "requireSpacesInConditionalExpression": true,
+ "requireSpaceBeforeBlockStatements": true,
+ "requireSpacesInForStatement": true,
+ "requireLineFeedAtFileEnd": true,
+ "requireSpacesInFunctionExpression": {
+ "beforeOpeningCurlyBrace": true
+ },
+ "disallowSpacesInsideObjectBrackets": "all",
+ "disallowSpacesInsideArrayBrackets": "all",
+ "disallowSpacesInsideParentheses": true,
+
+ "disallowMultipleLineBreaks": true,
+ "disallowNewlineBeforeBlockStatements": true
+}
View
@@ -52,6 +52,17 @@ gulp.task('lint', function() {
/**
*
+ * Coding style
+ *
+ */
+gulp.task('jscs', function() {
+ var jscs = require('gulp-jscs');
+ gulp.src(['lib/**/*.js', 'test/**/*.js'])
+ .pipe(jscs());
+});
+
+/**
+ *
* Test spec
* `npm test` (without argv)
* `gulp test --file cli` (test only cli.js file)
View
@@ -7,27 +7,29 @@
*/
function Browsers (options) {
- var browserslist = require('autoprefixer-core/node_modules/browserslist');
+ var module = 'autoprefixer-core/node_modules/';
- options = options || {};
- options.browsers = options.browsers || browserslist.defaults;
+ var browserslist = require(module + 'browserslist');
- this.selected = browserslist(options.browsers);
- this.browsers = browserslist.data;
+ options = options || {};
+ options.browsers = options.browsers || browserslist.defaults;
- var features = {};
+ this.selected = browserslist(options.browsers);
+ this.browsers = browserslist.data;
- this.getBrowsersByFeature(require('autoprefixer-core/node_modules/caniuse-db/features-json/rem'), function(browsers) {
- features.rem = browsers;
- });
- this.getBrowsersByFeature(require('autoprefixer-core/node_modules/caniuse-db/features-json/css-opacity'), function(browsers) {
- features.opacity = browsers;
- });
- this.getBrowsersByFeature(require('autoprefixer-core/node_modules/caniuse-db/features-json/css-gencontent'), function(browsers) {
- features.pseudoElements = browsers;
- });
+ var features = {};
- this.features = features;
+ this.getBrowsersByFeature(require(module + 'caniuse-db/features-json/rem'), function(browsers) {
+ features.rem = browsers;
+ });
+ this.getBrowsersByFeature(require(module + 'caniuse-db/features-json/css-opacity'), function(browsers) {
+ features.opacity = browsers;
+ });
+ this.getBrowsersByFeature(require(module + 'caniuse-db/features-json/css-gencontent'), function(browsers) {
+ features.pseudoElements = browsers;
+ });
+
+ this.features = features;
}
@@ -38,50 +40,49 @@ function Browsers (options) {
*
*/
Browsers.prototype.getBrowsersByFeature = function(data, callback) {
- var match = /(n|a)($|\s)/;
- var need = [];
- data = data.stats;
- for (var browser in data) {
- var versions = data[browser];
- for (var interval in versions) {
- var support = versions[interval];
- var dbl = interval.split('-');
- for (var i = 0, len = dbl.length; i < len; i++) {
- var version = dbl[i];
- if (this.browsers[browser] && support.match(match)) {
- version = version.replace(/\.0$/, '');
- need.push(browser + ' ' + version);
- }
- }
+ var match = /(n|a)($|\s)/;
+ var need = [];
+ data = data.stats;
+ for (var browser in data) {
+ var versions = data[browser];
+ for (var interval in versions) {
+ var support = versions[interval];
+ var dbl = interval.split('-');
+ for (var i = 0, len = dbl.length; i < len; i++) {
+ var version = dbl[i];
+ if (this.browsers[browser] && support.match(match)) {
+ version = version.replace(/\.0$/, '');
+ need.push(browser + ' ' + version);
}
+ }
}
- var sorted = need.sort(function(a, b) {
- a = a.split(' ');
- b = b.split(' ');
- if (a[0] > b[0]) {
- return 1;
- } else if (a[0] < b[0]) {
- return -1;
- } else {
- return parseFloat(a[1]) - parseFloat(b[1]);
- }
- });
- return callback(sorted);
+ }
+ var sorted = need.sort(function(a, b) {
+ a = a.split(' ');
+ b = b.split(' ');
+ if (a[0] > b[0]) {
+ return 1;
+ } else if (a[0] < b[0]) {
+ return -1;
+ } else {
+ return parseFloat(a[1]) - parseFloat(b[1]);
+ }
+ });
+ return callback(sorted);
};
-
/**
*
* New Browsers instance
*
*/
var browsers = function(options) {
- return new Browsers(options);
+ return new Browsers(options);
};
/**
*
* Exports
*
*/
-module.exports = browsers;
+module.exports = browsers;
Oops, something went wrong.

0 comments on commit c19d645

Please sign in to comment.