[Pkg-javascript-commits] [less.js] 06/14: Require parenthesis

Jonas Smedegaard dr at jones.dk
Mon Oct 26 23:29:16 UTC 2015


This is an automated email from the git hooks/post-receive script.

js pushed a commit to annotated tag v2.3.1
in repository less.js.

commit 28de1cf788548284c0118d25a70a4cfcffa4971a
Author: Luke Page <luke.a.page at gmail.com>
Date:   Tue Jan 27 21:57:07 2015 +0000

    Require parenthesis
---
 .jscsrc                             | 12 +++++++++++-
 lib/less-node/file-manager.js       | 10 +++++++---
 lib/less/parser/parser.js           |  3 ++-
 lib/less/tree/directive.js          | 18 +++++++++++++++---
 lib/less/tree/media.js              |  5 +++--
 lib/less/tree/ruleset.js            |  9 ++++++---
 lib/less/tree/selector.js           |  3 ++-
 lib/less/visitors/to-css-visitor.js |  3 ++-
 test/copy-bom.js                    | 22 ++++++++++++++--------
 test/modify-vars.js                 | 10 ++++++----
 10 files changed, 68 insertions(+), 27 deletions(-)

diff --git a/.jscsrc b/.jscsrc
index 99b33ae..0634ec2 100644
--- a/.jscsrc
+++ b/.jscsrc
@@ -12,5 +12,15 @@
     },
     "disallowTrailingComma": true,
     "disallowTrailingWhitespace": true,
-    "maximumLineLength": 160
+    "maximumLineLength": 160,
+    "requireCommaBeforeLineBreak": true,
+    "requireCurlyBraces": [
+                              "if",
+                              "else",
+                              "for",
+                              "while",
+                              "do",
+                              "try",
+                              "catch"
+                          ]
 }
\ No newline at end of file
diff --git a/lib/less-node/file-manager.js b/lib/less-node/file-manager.js
index 7609289..242632b 100644
--- a/lib/less-node/file-manager.js
+++ b/lib/less-node/file-manager.js
@@ -30,7 +30,7 @@ FileManager.prototype.loadFile = function(filename, currentDirectory, options, e
     }
 
     var paths = isAbsoluteFilename ? [""] : [currentDirectory];
-    if (options.paths) paths.push.apply(paths, options.paths);
+    if (options.paths) { paths.push.apply(paths, options.paths); }
     if (!isAbsoluteFilename && paths.indexOf('.') === -1) { paths.push('.'); }
 
     // promise is guarenteed to be asyncronous
@@ -67,8 +67,12 @@ FileManager.prototype.loadFileSync = function(filename, currentDirectory, option
     options = options || {};
 
     paths = isAbsoluteFilename ? [""] : [currentDirectory];
-    if (options.paths) paths.push.apply(paths, options.paths);
-    if (!isAbsoluteFilename && paths.indexOf('.') === -1) { paths.push('.'); }
+    if (options.paths) {
+        paths.push.apply(paths, options.paths);
+    }
+    if (!isAbsoluteFilename && paths.indexOf('.') === -1) {
+        paths.push('.');
+    }
 
     var err, result;
     for (var i = 0; i < paths.length; i++) {
diff --git a/lib/less/parser/parser.js b/lib/less/parser/parser.js
index 5a30e55..4364916 100644
--- a/lib/less/parser/parser.js
+++ b/lib/less/parser/parser.js
@@ -552,8 +552,9 @@ var Parser = function Parser(context, imports, fileInfo) {
                     }
 
                     option = option && option[1];
-                    if (!elements)
+                    if (!elements) {
                         error("Missing target selector for :extend().");
+                    }
                     extend = new(tree.Extend)(new(tree.Selector)(elements), option, index);
                     if (extendList) { extendList.push(extend); } else { extendList = [ extend ]; }
 
diff --git a/lib/less/tree/directive.js b/lib/less/tree/directive.js
index 20c0eb3..d73268c 100644
--- a/lib/less/tree/directive.js
+++ b/lib/less/tree/directive.js
@@ -59,9 +59,21 @@ Directive.prototype.eval = function (context) {
     return new Directive(this.name, value, rules,
         this.index, this.currentFileInfo, this.debugInfo, this.isReferenced);
 };
-Directive.prototype.variable = function (name) { if (this.rules) return Ruleset.prototype.variable.call(this.rules, name); };
-Directive.prototype.find = function () { if (this.rules) return Ruleset.prototype.find.apply(this.rules, arguments); };
-Directive.prototype.rulesets = function () { if (this.rules) return Ruleset.prototype.rulesets.apply(this.rules); };
+Directive.prototype.variable = function (name) {
+    if (this.rules) {
+        return Ruleset.prototype.variable.call(this.rules, name);
+    }
+};
+Directive.prototype.find = function () {
+    if (this.rules) {
+        return Ruleset.prototype.find.apply(this.rules, arguments);
+    }
+};
+Directive.prototype.rulesets = function () {
+    if (this.rules) {
+        return Ruleset.prototype.rulesets.apply(this.rules);
+    }
+};
 Directive.prototype.markReferenced = function () {
     var i, rules;
     this.isReferenced = true;
diff --git a/lib/less/tree/media.js b/lib/less/tree/media.js
index e1436c1..cd30b9c 100644
--- a/lib/less/tree/media.js
+++ b/lib/less/tree/media.js
@@ -154,8 +154,9 @@ Media.prototype.permute = function (arr) {
   }
 };
 Media.prototype.bubbleSelectors = function (selectors) {
-  if (!selectors)
-    return;
+  if (!selectors) {
+      return;
+  }
   this.rules = [new Ruleset(selectors.slice(0), [this.rules[0]])];
 };
 module.exports = Media;
diff --git a/lib/less/tree/ruleset.js b/lib/less/tree/ruleset.js
index cd63e85..09239f3 100644
--- a/lib/less/tree/ruleset.js
+++ b/lib/less/tree/ruleset.js
@@ -423,8 +423,9 @@ Ruleset.prototype.markReferenced = function () {
 
     if (this.rules) {
         for (s = 0; s < this.rules.length; s++) {
-            if (this.rules[s].markReferenced)
+            if (this.rules[s].markReferenced) {
                 this.rules[s].markReferenced();
+            }
         }
     }
 };
@@ -435,8 +436,9 @@ Ruleset.prototype.getIsReferenced = function() {
         for (i=0; i<this.paths.length; i++) {
             path = this.paths[i];
             for (j=0; j<path.length; j++) {
-                if (path[j].getIsReferenced && path[j].getIsReferenced())
+                if (path[j].getIsReferenced && path[j].getIsReferenced()) {
                     return true;
+                }
             }
         }
     }
@@ -444,8 +446,9 @@ Ruleset.prototype.getIsReferenced = function() {
     if (this.selectors) {
         for (i=0;i<this.selectors.length;i++) {
             selector = this.selectors[i];
-            if (selector.getIsReferenced && selector.getIsReferenced())
+            if (selector.getIsReferenced && selector.getIsReferenced()) {
                 return true;
+            }
         }
     }
     return false;
diff --git a/lib/less/tree/selector.js b/lib/less/tree/selector.js
index 406130b..42c3a3c 100644
--- a/lib/less/tree/selector.js
+++ b/lib/less/tree/selector.js
@@ -51,8 +51,9 @@ Selector.prototype.match = function (other) {
     return olen; // return number of matched elements
 };
 Selector.prototype.CacheElements = function() {
-    if (this._elements)
+    if (this._elements) {
         return;
+    }
 
     var elements = this.elements.map( function(v) {
         return v.combinator.value + (v.value.value || v.value);
diff --git a/lib/less/visitors/to-css-visitor.js b/lib/less/visitors/to-css-visitor.js
index 93cb6d6..3b51ff9 100644
--- a/lib/less/visitors/to-css-visitor.js
+++ b/lib/less/visitors/to-css-visitor.js
@@ -94,8 +94,9 @@ ToCSSVisitor.prototype = {
             //was referenced. Therefore it must not be shown in output.
             return ;
         } else {
-            if (!directiveNode.getIsReferenced())
+            if (!directiveNode.getIsReferenced()) {
                 return;
+            }
         }
         return directiveNode;
     },
diff --git a/test/copy-bom.js b/test/copy-bom.js
index d1d3887..89a04ce 100644
--- a/test/copy-bom.js
+++ b/test/copy-bom.js
@@ -17,29 +17,35 @@ module.exports = function() {
       var performCopy = false;
 
       if (stats.isFile()) {
-        if (!destFolderExists)
+        if (!destFolderExists) {
             fs.mkdirSync(destFolder);
-        if (src.match(/\.(css|less)$/))
+        }
+        if (src.match(/\.(css|less)$/)) {
             copyFileAddingBomSync(src, dest);
-        else
-          copyFileSync(src, dest)
+        } else {
+            copyFileSync(src, dest);
+        }
       }
       else if (stats.isDirectory()) {
-        if (!fs.existsSync(destFolder))
+        if (!fs.existsSync(destFolder)) {
             fs.mkdirSync(destFolder);
-        if (!fs.existsSync(dest))
+        }
+        if (!fs.existsSync(dest)) {
             fs.mkdirSync(dest);
+        }
         fs.readdirSync(src).forEach(function(d) {
-            if (d !== 'bom')
+            if (d !== 'bom') {
                 copyFolderWithBom(path.join(src, d), path.join(dest, d));
+            }
         });
       }
     }
 
     function copyFileAddingBomSync(srcFile, destFile) {
         var contents = fs.readFileSync(srcFile, { encoding: 'utf8' });
-        if (!contents.length || contents.charCodeAt(0) !== 0xFEFF)
+        if (!contents.length || contents.charCodeAt(0) !== 0xFEFF) {
             contents = '\ufeff' + contents;
+        }
         fs.writeFileSync(destFile, contents, { encoding: 'utf8' });
     }
 
diff --git a/test/modify-vars.js b/test/modify-vars.js
index 2aa324f..802228b 100644
--- a/test/modify-vars.js
+++ b/test/modify-vars.js
@@ -8,10 +8,12 @@ var options = {
 }
 
 less.render(input, options, function (err, result) {
-  if (err) console.log(err);
+  if (err) {
+      console.log(err);
+  }
   if (result.css === expectedCss) {
-    console.log("PASS")
+    console.log("PASS");
   } else {
-    console.log("FAIL")
+    console.log("FAIL");
   }
-})
+});

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/less.js.git



More information about the Pkg-javascript-commits mailing list