From 7a80a822839b70b55e6e2813a28dd97f46aafd14 Mon Sep 17 00:00:00 2001 From: rjgotten Date: Fri, 20 Mar 2015 12:46:19 +0100 Subject: [PATCH 1/9] Add missing null check --- bin/lessc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/lessc b/bin/lessc index fbefddf4d..8be1fe32e 100755 --- a/bin/lessc +++ b/bin/lessc @@ -275,7 +275,7 @@ function printUsage() { var filenames = [args[1], args[2]].map(function (arg) { var match; - match = arg.match(/^'(.+)'$/); + match = arg && arg.match(/^'(.+)'$/); if (match) { return match[1]; } else { From 4d17c8b35d9726da226a57d6a3c9ddd51034b19e Mon Sep 17 00:00:00 2001 From: rjgotten Date: Fri, 20 Mar 2015 16:41:05 +0100 Subject: [PATCH 2/9] Fix plugin scope for mixins, directives and detached rulesets Fixed scope for plugins to apply correctly for mixins, directives and detached rulesets. Updated plugin unit tests to be more comprehensive --- lib/less/tree/import.js | 18 ++++-- lib/less/tree/media.js | 1 + lib/less/tree/mixin-definition.js | 2 +- lib/less/tree/ruleset.js | 13 +++- lib/less/visitors/import-visitor.js | 12 +++- test/css/import-plugin-scoped.css | 6 -- test/css/import-plugin-tiered.css | 6 -- test/css/import-plugin.css | 3 - test/css/plugin.css | 44 +++++++++++++ test/less/import-plugin-scoped.less | 9 --- test/less/import-plugin-tiered.less | 5 -- test/less/import-plugin.less | 5 -- test/less/plugin.less | 85 +++++++++++++++++++++++++ test/less/plugin/plugin-global.js | 9 +++ test/less/plugin/plugin-local.js | 8 +++ test/less/plugin/plugin-transitive.js | 5 ++ test/less/plugin/plugin-transitive.less | 5 ++ test/less/plugins/test.js | 4 -- 18 files changed, 190 insertions(+), 50 deletions(-) delete mode 100644 test/css/import-plugin-scoped.css delete mode 100644 test/css/import-plugin-tiered.css delete mode 100644 test/css/import-plugin.css create mode 100644 test/css/plugin.css delete mode 100644 test/less/import-plugin-scoped.less delete mode 100644 test/less/import-plugin-tiered.less delete mode 100644 test/less/import-plugin.less create mode 100644 test/less/plugin.less create mode 100644 test/less/plugin/plugin-global.js create mode 100644 test/less/plugin/plugin-local.js create mode 100644 test/less/plugin/plugin-transitive.js create mode 100644 test/less/plugin/plugin-transitive.less delete mode 100644 test/less/plugins/test.js diff --git a/lib/less/tree/import.js b/lib/less/tree/import.js index 4279852ed..9c14fb1f5 100644 --- a/lib/less/tree/import.js +++ b/lib/less/tree/import.js @@ -86,9 +86,11 @@ Import.prototype.isVariableImport = function () { }; Import.prototype.evalForImport = function (context) { var path = this.path; + if (path instanceof URL) { path = path.value; } + return new Import(path.eval(context), this.features, this.options, this.index, this.currentFileInfo); }; Import.prototype.evalPath = function (context) { @@ -112,6 +114,14 @@ Import.prototype.eval = function (context) { var ruleset, registry, features = this.features && this.features.eval(context); + if (this.options.plugin) { + registry = context.frames[0] && context.frames[0].functionRegistry; + if ( registry && this.root && this.root.functions ) { + registry.addMultiple( this.root.functions ); + } + return []; + } + if (this.skip) { if (typeof this.skip === "function") { this.skip = this.skip(); @@ -121,13 +131,7 @@ Import.prototype.eval = function (context) { } } - if (this.options.plugin) { - registry = context.frames[0] && context.frames[0].functionRegistry; - if ( registry && this.root.functions ) { - registry.addMultiple( this.root.functions ); - } - return []; - } else if (this.options.inline) { + if (this.options.inline) { var contents = new Anonymous(this.root, 0, {filename: this.importedFilename}, true, true); return this.features ? new Media([contents], this.features.value) : [contents]; } else if (this.css) { diff --git a/lib/less/tree/media.js b/lib/less/tree/media.js index 1514f0b53..054d7715e 100644 --- a/lib/less/tree/media.js +++ b/lib/less/tree/media.js @@ -59,6 +59,7 @@ Media.prototype.eval = function (context) { context.mediaPath.push(media); context.mediaBlocks.push(media); + this.rules[0].functionRegistry = context.frames[0].functionRegistry.inherit(); context.frames.unshift(this.rules[0]); media.rules = [this.rules[0].eval(context)]; context.frames.shift(); diff --git a/lib/less/tree/mixin-definition.js b/lib/less/tree/mixin-definition.js index 9a92ed01b..20dfd6119 100644 --- a/lib/less/tree/mixin-definition.js +++ b/lib/less/tree/mixin-definition.js @@ -44,7 +44,7 @@ Definition.prototype.evalParams = function (context, mixinEnv, args, evaldArgume i, j, val, name, isNamedFound, argIndex, argsLength = 0; mixinEnv = new contexts.Eval(mixinEnv, [frame].concat(mixinEnv.frames)); - frame.functionRegistry = context.frames[0].functionRegistry.inherit(); + //frame.functionRegistry = context.frames[0].functionRegistry.inherit(); if (args) { args = args.slice(0); diff --git a/lib/less/tree/ruleset.js b/lib/less/tree/ruleset.js index ea2948f5b..4217b5ff4 100644 --- a/lib/less/tree/ruleset.js +++ b/lib/less/tree/ruleset.js @@ -69,7 +69,16 @@ Ruleset.prototype.eval = function (context) { // inherit a function registry from the frames stack when possible; // otherwise from the global registry - ruleset.functionRegistry = ((context.frames[0] && context.frames[0].functionRegistry) || globalFunctionRegistry).inherit(); + ruleset.functionRegistry = (function (frames) { + var i = 0, + n = frames.length, + found; + for ( ; i !== n ; ++i ) { + found = frames[ i ].functionRegistry; + if ( found ) return found; + } + return globalFunctionRegistry; + }(context.frames)).inherit(); // push the current ruleset to the frames stack var ctxFrames = context.frames; @@ -181,7 +190,7 @@ Ruleset.prototype.evalImports = function(context) { rules.splice.apply(rules, [i, 1].concat(importRules)); i+= importRules.length - 1; } else { - rules.splice(i, 1, importRules); + rules.splice(i, 1); } this.resetCache(); } diff --git a/lib/less/visitors/import-visitor.js b/lib/less/visitors/import-visitor.js index 8ddddb6b3..b8f2598bd 100644 --- a/lib/less/visitors/import-visitor.js +++ b/lib/less/visitors/import-visitor.js @@ -103,6 +103,7 @@ ImportVisitor.prototype = { var importVisitor = this, inlineCSS = importNode.options.inline, + isPlugin = importNode.options.plugin, duplicateImport = importedAtRoot || fullPath in importVisitor.recursionDetector; if (!context.importMultiple) { @@ -123,7 +124,7 @@ ImportVisitor.prototype = { importNode.root = root; importNode.importedFilename = fullPath; - if (!inlineCSS && (context.importMultiple || !duplicateImport)) { + if (!inlineCSS && !isPlugin && (context.importMultiple || !duplicateImport)) { importVisitor.recursionDetector[fullPath] = true; var oldContext = this.context; @@ -144,7 +145,14 @@ ImportVisitor.prototype = { } }, visitRule: function (ruleNode, visitArgs) { - visitArgs.visitDeeper = false; + if (ruleNode.value.type === "DetachedRuleset") { + this.context.frames.unshift(ruleNode); + } else { + visitArgs.visitDeeper = false; + } + }, + visitRuleOut : function(ruleNode) { + this.context.frames.shift(); }, visitDirective: function (directiveNode, visitArgs) { this.context.frames.unshift(directiveNode); diff --git a/test/css/import-plugin-scoped.css b/test/css/import-plugin-scoped.css deleted file mode 100644 index e42ec6478..000000000 --- a/test/css/import-plugin-scoped.css +++ /dev/null @@ -1,6 +0,0 @@ -.in-scope { - result: PASS; -} -.out-of-scope { - result: test(); -} diff --git a/test/css/import-plugin-tiered.css b/test/css/import-plugin-tiered.css deleted file mode 100644 index 7960b9f3f..000000000 --- a/test/css/import-plugin-tiered.css +++ /dev/null @@ -1,6 +0,0 @@ -.test { - result: PASS; -} -.test-again { - result: PASS; -} diff --git a/test/css/import-plugin.css b/test/css/import-plugin.css deleted file mode 100644 index 1c337756a..000000000 --- a/test/css/import-plugin.css +++ /dev/null @@ -1,3 +0,0 @@ -.test { - result: PASS; -} diff --git a/test/css/plugin.css b/test/css/plugin.css new file mode 100644 index 000000000..b837dc63e --- /dev/null +++ b/test/css/plugin.css @@ -0,0 +1,44 @@ +.other { + trans: transitive; +} +.class { + trans: transitive; + global: global; + local: test-local(); + shadow: global; +} +.class .local { + global: global; + local: local; + shadow: local; +} +.class { + ns-mixin-global: global; + ns-mixin-local: local; + ns-mixin-shadow: local; + mixin-local: local; + mixin-global: global; + mixin-shadow: local; + ruleset-local: local; + ruleset-global: global; + ruleset-shadow: local; + class-local: test-local(); +} +@media screen { + .test { + result: global; + } +} +@font-face { + result: global; +} +@media screen and (min-width: 100px) and (max-width: 400px) { + .test { + result: global; + } +} +@media screen { + .test { + result: local; + } +} diff --git a/test/less/import-plugin-scoped.less b/test/less/import-plugin-scoped.less deleted file mode 100644 index 7c0fa7825..000000000 --- a/test/less/import-plugin-scoped.less +++ /dev/null @@ -1,9 +0,0 @@ -.in-scope { - @plugin "./plugins/test"; - result : test(); -} - -.out-of-scope { - result : test(); -} - diff --git a/test/less/import-plugin-tiered.less b/test/less/import-plugin-tiered.less deleted file mode 100644 index eb487738b..000000000 --- a/test/less/import-plugin-tiered.less +++ /dev/null @@ -1,5 +0,0 @@ -@import "import-plugin"; - -.test-again { - result : test(); -} \ No newline at end of file diff --git a/test/less/import-plugin.less b/test/less/import-plugin.less deleted file mode 100644 index 7ee43e30a..000000000 --- a/test/less/import-plugin.less +++ /dev/null @@ -1,5 +0,0 @@ -@plugin "./plugins/test"; - -.test { - result : test(); -} \ No newline at end of file diff --git a/test/less/plugin.less b/test/less/plugin.less new file mode 100644 index 000000000..17524a400 --- /dev/null +++ b/test/less/plugin.less @@ -0,0 +1,85 @@ +// importing plugin globally +@plugin "./plugin/plugin-global"; + +// transitively include plugins from importing another sheet +@import "./plugin/plugin-transitive"; + + +// `test-global` function should be reachable +// `test-local` function should not be reachable +// `test-shadow` function should return global version +.class { + trans : test-transitive(); + global : test-global(); + local : test-local(); + shadow : test-shadow(); + + // `test-global` function should propagate and be reachable + // `test-local` function should be reachable + // `test-shadow` function should return local version, shadowing global version + .local { + @plugin "./plugin/plugin-local"; + global : test-global(); + local : test-local(); + shadow : test-shadow(); + } +} + +// calling a mixin or detached ruleset should not bubble local plugins +// imported inside either into the parent scope. +.mixin() { + @plugin "./plugin/plugin-local"; + mixin-local : test-local(); + mixin-global : test-global(); + mixin-shadow : test-shadow(); +} +@ruleset : { + @plugin "./plugin/plugin-local"; + ruleset-local : test-local(); + ruleset-global : test-global(); + ruleset-shadow : test-shadow(); +}; +#ns { + @plugin "./plugin/plugin-local"; + .mixin() { + ns-mixin-global : test-global(); + ns-mixin-local : test-local(); + ns-mixin-shadow : test-shadow(); + } +} +.class { + #ns > .mixin(); + .mixin(); + @ruleset(); + class-local : test-local(); +} + + +// `test-global` function should propagate into directive scope +@media screen { + .test { + result : test-global(); + } +} +@font-face { + result : test-global(); +} + +// `test-global` function should propagate into nested directive scopes +@media screen and (min-width:100px) { + @media (max-width:400px) { + .test { + result : test-global(); + } + } +} + +.test { + @media screen { + @plugin "./plugin/plugin-local"; + result : test-local(); + } +} + + + diff --git a/test/less/plugin/plugin-global.js b/test/less/plugin/plugin-global.js new file mode 100644 index 000000000..adc828c49 --- /dev/null +++ b/test/less/plugin/plugin-global.js @@ -0,0 +1,9 @@ + +functions.addMultiple({ + "test-shadow" : function() { + return new tree.Anonymous( "global" ); + }, + "test-global" : function() { + return new tree.Anonymous( "global" ); + } +}); diff --git a/test/less/plugin/plugin-local.js b/test/less/plugin/plugin-local.js new file mode 100644 index 000000000..b54ca97a8 --- /dev/null +++ b/test/less/plugin/plugin-local.js @@ -0,0 +1,8 @@ +functions.addMultiple({ + "test-shadow" : function() { + return new tree.Anonymous( "local" ); + }, + "test-local" : function() { + return new tree.Anonymous( "local" ); + } +}); diff --git a/test/less/plugin/plugin-transitive.js b/test/less/plugin/plugin-transitive.js new file mode 100644 index 000000000..1da1864c4 --- /dev/null +++ b/test/less/plugin/plugin-transitive.js @@ -0,0 +1,5 @@ +functions.addMultiple({ + "test-transitive" : function() { + return new tree.Anonymous( "transitive" ); + } +}); diff --git a/test/less/plugin/plugin-transitive.less b/test/less/plugin/plugin-transitive.less new file mode 100644 index 000000000..8e4ca00bb --- /dev/null +++ b/test/less/plugin/plugin-transitive.less @@ -0,0 +1,5 @@ +@plugin "plugin-transitive"; + +.other { + trans : test-transitive(); +} \ No newline at end of file diff --git a/test/less/plugins/test.js b/test/less/plugins/test.js deleted file mode 100644 index f54ee82b1..000000000 --- a/test/less/plugins/test.js +++ /dev/null @@ -1,4 +0,0 @@ - -functions.add("test", function() { - return new tree.Anonymous( "PASS" ); -}); From 56f5db83624c51811d9ad98d858051a4568fc458 Mon Sep 17 00:00:00 2001 From: rjgotten Date: Fri, 20 Mar 2015 17:15:31 +0100 Subject: [PATCH 3/9] Mend failing unit tests --- lib/less/tree/import.js | 2 +- lib/less/tree/mixin-definition.js | 2 +- lib/less/tree/ruleset.js | 17 ++++------------- 3 files changed, 6 insertions(+), 15 deletions(-) diff --git a/lib/less/tree/import.js b/lib/less/tree/import.js index 9c14fb1f5..3acd3f2e1 100644 --- a/lib/less/tree/import.js +++ b/lib/less/tree/import.js @@ -120,7 +120,7 @@ Import.prototype.eval = function (context) { registry.addMultiple( this.root.functions ); } return []; - } + } if (this.skip) { if (typeof this.skip === "function") { diff --git a/lib/less/tree/mixin-definition.js b/lib/less/tree/mixin-definition.js index 20dfd6119..9a92ed01b 100644 --- a/lib/less/tree/mixin-definition.js +++ b/lib/less/tree/mixin-definition.js @@ -44,7 +44,7 @@ Definition.prototype.evalParams = function (context, mixinEnv, args, evaldArgume i, j, val, name, isNamedFound, argIndex, argsLength = 0; mixinEnv = new contexts.Eval(mixinEnv, [frame].concat(mixinEnv.frames)); - //frame.functionRegistry = context.frames[0].functionRegistry.inherit(); + frame.functionRegistry = context.frames[0].functionRegistry.inherit(); if (args) { args = args.slice(0); diff --git a/lib/less/tree/ruleset.js b/lib/less/tree/ruleset.js index 4217b5ff4..d5f932d52 100644 --- a/lib/less/tree/ruleset.js +++ b/lib/less/tree/ruleset.js @@ -67,18 +67,9 @@ Ruleset.prototype.eval = function (context) { rules.length = 0; } - // inherit a function registry from the frames stack when possible; - // otherwise from the global registry - ruleset.functionRegistry = (function (frames) { - var i = 0, - n = frames.length, - found; - for ( ; i !== n ; ++i ) { - found = frames[ i ].functionRegistry; - if ( found ) return found; - } - return globalFunctionRegistry; - }(context.frames)).inherit(); + // inherit a function registry from the top frame on the stack, when possible. + // Otherwise from the global registry. + ruleset.functionRegistry = ((context.frames[0] && context.frames[0].functionRegistry) || globalFunctionRegistry).inherit(); // push the current ruleset to the frames stack var ctxFrames = context.frames; @@ -190,7 +181,7 @@ Ruleset.prototype.evalImports = function(context) { rules.splice.apply(rules, [i, 1].concat(importRules)); i+= importRules.length - 1; } else { - rules.splice(i, 1); + rules.splice(i, 1, importRules); } this.resetCache(); } From 56687b9d027755b31c28fc2e23afdddeb9e8826b Mon Sep 17 00:00:00 2001 From: rjgotten Date: Mon, 23 Mar 2015 11:01:51 +0100 Subject: [PATCH 4/9] Make functionRegistry in mxin definition inherit from mixinEnv functionRegistry was mistakingly inheriting from the top frame of the caller context, which was incorrect. It should inherit from definition scope. --- bin/test.less | 11 +++++++++++ lib/less/tree/mixin-definition.js | 4 +++- 2 files changed, 14 insertions(+), 1 deletion(-) create mode 100644 bin/test.less diff --git a/bin/test.less b/bin/test.less new file mode 100644 index 000000000..ec397922e --- /dev/null +++ b/bin/test.less @@ -0,0 +1,11 @@ +#ns { + @plugin "../test/less/plugin/plugin-local"; + + .mixin() { + result : test-local(); + } +} + +.test { + #ns > .mixin(); +} \ No newline at end of file diff --git a/lib/less/tree/mixin-definition.js b/lib/less/tree/mixin-definition.js index 9a92ed01b..2f2b9dc1b 100644 --- a/lib/less/tree/mixin-definition.js +++ b/lib/less/tree/mixin-definition.js @@ -43,8 +43,10 @@ Definition.prototype.evalParams = function (context, mixinEnv, args, evaldArgume params = this.params.slice(0), i, j, val, name, isNamedFound, argIndex, argsLength = 0; + if (mixinEnv.frames && mixinEnv.frames[0] && mixinEnv.frames[0].functionRegistry) { + frame.functionRegistry = mixinEnv.frames[0].functionRegistry.inherit(); + } mixinEnv = new contexts.Eval(mixinEnv, [frame].concat(mixinEnv.frames)); - frame.functionRegistry = context.frames[0].functionRegistry.inherit(); if (args) { args = args.slice(0); From aa66271dd3a917a151a301d6237b531f8a1dbcae Mon Sep 17 00:00:00 2001 From: rjgotten Date: Mon, 23 Mar 2015 22:50:50 +0100 Subject: [PATCH 5/9] Deletes an accidentally committed dev file --- bin/test.less | 11 ----------- 1 file changed, 11 deletions(-) delete mode 100644 bin/test.less diff --git a/bin/test.less b/bin/test.less deleted file mode 100644 index ec397922e..000000000 --- a/bin/test.less +++ /dev/null @@ -1,11 +0,0 @@ -#ns { - @plugin "../test/less/plugin/plugin-local"; - - .mixin() { - result : test-local(); - } -} - -.test { - #ns > .mixin(); -} \ No newline at end of file From 7cc986e361456ea2ed26589425077b22d7d0442a Mon Sep 17 00:00:00 2001 From: Alex Date: Sat, 28 Mar 2015 14:50:51 +0500 Subject: [PATCH 6/9] Add browser field to support browserfy and other loaders that use `browser` field for resolving browser version https://github.com/substack/node-browserify#packagejson --- package.json | 1 + 1 file changed, 1 insertion(+) diff --git a/package.json b/package.json index a91e66c98..1112590eb 100644 --- a/package.json +++ b/package.json @@ -33,6 +33,7 @@ "jam": { "main": "./dist/less.js" }, + "browser": "./dist/less.js", "engines": { "node": ">=0.10.0" }, From ff55171dc8ac51d4a4cd4ff2efeef29868f2593e Mon Sep 17 00:00:00 2001 From: seven-phases-max Date: Mon, 30 Mar 2015 04:38:36 +0400 Subject: [PATCH 7/9] fix grunt shell:benchmark command --- Gruntfile.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gruntfile.js b/Gruntfile.js index d3e78155a..68b0a6b94 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -36,7 +36,7 @@ module.exports = function (grunt) { command: 'node test' }, benchmark: { - command: 'node benchmark/less-benchmark.js' + command: 'node benchmark/index.js' }, "sourcemap-test": { command: [ From c1bccbec32f29f29338ba012a1efc38ed5c1fd8a Mon Sep 17 00:00:00 2001 From: Luke Page Date: Wed, 1 Apr 2015 13:01:28 +0100 Subject: [PATCH 8/9] Do not use the latest jscs as it breaks since it does extra checking on indentation that doesn't pass. --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index a91e66c98..0afa2c3bf 100644 --- a/package.json +++ b/package.json @@ -58,7 +58,7 @@ "grunt-contrib-jasmine": "^0.8.2", "grunt-contrib-jshint": "^0.11.0", "grunt-contrib-uglify": "^0.8.0", - "grunt-jscs": "^1.2.0", + "grunt-jscs": "~1.5.0", "grunt-shell": "^1.1.1", "grunt-browserify": "~3.5.0", "jit-grunt": "^0.9.1", From 1950248a8707b6259090cfd18147f4bef973bd6c Mon Sep 17 00:00:00 2001 From: seven-phases-max Date: Wed, 1 Apr 2015 21:26:14 +0400 Subject: [PATCH 9/9] fix formatting to meet jscs settings --- lib/less-rhino/index.js | 5 +++-- lib/less/parser/parser-input.js | 3 +-- lib/less/parser/parser.js | 9 +++------ lib/less/source-map-output.js | 3 +-- lib/less/tree/dimension.js | 2 +- lib/less/visitors/extend-visitor.js | 3 +-- package.json | 2 +- test/browser/runner-global-vars-options.js | 3 ++- test/browser/runner-main-options.js | 22 +++++++++++----------- test/plugins/visitor/index.js | 22 ++++++++++------------ 10 files changed, 34 insertions(+), 40 deletions(-) diff --git a/lib/less-rhino/index.js b/lib/less-rhino/index.js index 3d2aa8bc8..186022467 100644 --- a/lib/less-rhino/index.js +++ b/lib/less-rhino/index.js @@ -1,5 +1,6 @@ -/*jshint rhino:true, unused: false */ -/*global name:true, less, loadStyleSheet, os */ +/* jshint rhino:true, unused: false */ +/* jscs:disable validateIndentation */ +/* global name:true, less, loadStyleSheet, os */ function formatError(ctx, options) { options = options || {}; diff --git a/lib/less/parser/parser-input.js b/lib/less/parser/parser-input.js index b986d15bc..f31f057db 100644 --- a/lib/less/parser/parser-input.js +++ b/lib/less/parser/parser-input.js @@ -166,8 +166,7 @@ module.exports = function() { currentPos = parserInput.i; if (!current.length) { - if (j < chunks.length - 1) - { + if (j < chunks.length - 1) { current = chunks[++j]; skipWhitespace(0); // skip space at the beginning of a chunk return true; // things changed diff --git a/lib/less/parser/parser.js b/lib/less/parser/parser.js index a309e45cc..952f66743 100644 --- a/lib/less/parser/parser.js +++ b/lib/less/parser/parser.js @@ -240,8 +240,7 @@ var Parser = function Parser(context, imports, fileInfo) { primary: function () { var mixin = this.mixin, root = [], node; - while (true) - { + while (true) { while (true) { node = this.comment(); if (!node) { break; } @@ -1207,8 +1206,7 @@ var Parser = function Parser(context, imports, fileInfo) { features = features && new(tree.Value)(features); return new(tree.Import)(path, features, options, index, fileInfo); } - else - { + else { parserInput.i = index; error("malformed import statement"); } @@ -1360,8 +1358,7 @@ var Parser = function Parser(context, imports, fileInfo) { return new(tree.Import)(path, null, options, index, fileInfo); } - else - { + else { parserInput.i = index; error("malformed plugin statement"); } diff --git a/lib/less/source-map-output.js b/lib/less/source-map-output.js index c1aceaba7..4e21e24cc 100644 --- a/lib/less/source-map-output.js +++ b/lib/less/source-map-output.js @@ -105,8 +105,7 @@ module.exports = function (environment) { if (this._outputSourceFiles) { for (var filename in this._contentsMap) { - if (this._contentsMap.hasOwnProperty(filename)) - { + if (this._contentsMap.hasOwnProperty(filename)) { var source = this._contentsMap[filename]; if (this._contentsIgnoredCharsMap[filename]) { source = source.slice(this._contentsIgnoredCharsMap[filename]); diff --git a/lib/less/tree/dimension.js b/lib/less/tree/dimension.js index 7c895749f..e3ce27ef1 100644 --- a/lib/less/tree/dimension.js +++ b/lib/less/tree/dimension.js @@ -127,7 +127,7 @@ Dimension.prototype.convertTo = function (conversions) { conversions = derivedConversions; } applyUnit = function (atomicUnit, denominator) { - /*jshint loopfunc:true */ + /* jshint loopfunc:true */ if (group.hasOwnProperty(atomicUnit)) { if (denominator) { value = value / (group[atomicUnit] / group[targetUnit]); diff --git a/lib/less/visitors/extend-visitor.js b/lib/less/visitors/extend-visitor.js index 5feb473e4..cd3a390eb 100644 --- a/lib/less/visitors/extend-visitor.js +++ b/lib/less/visitors/extend-visitor.js @@ -198,8 +198,7 @@ ProcessExtendsVisitor.prototype = { if (iterationCount > 100) { var selectorOne = "{unable to calculate}"; var selectorTwo = "{unable to calculate}"; - try - { + try { selectorOne = extendsToAdd[0].selfSelectors[0].toCSS(); selectorTwo = extendsToAdd[0].selector.toCSS(); } diff --git a/package.json b/package.json index 07dafb9ac..10ff3e6bb 100644 --- a/package.json +++ b/package.json @@ -59,7 +59,7 @@ "grunt-contrib-jasmine": "^0.8.2", "grunt-contrib-jshint": "^0.11.0", "grunt-contrib-uglify": "^0.8.0", - "grunt-jscs": "~1.5.0", + "grunt-jscs": "^1.6.0", "grunt-shell": "^1.1.1", "grunt-browserify": "~3.5.0", "jit-grunt": "^0.9.1", diff --git a/test/browser/runner-global-vars-options.js b/test/browser/runner-global-vars-options.js index 859751a4d..54dc66289 100644 --- a/test/browser/runner-global-vars-options.js +++ b/test/browser/runner-global-vars-options.js @@ -3,4 +3,5 @@ var less = { errorReporting: "console", globalVars: { "@global-var": "red" -}}; + } +}; diff --git a/test/browser/runner-main-options.js b/test/browser/runner-main-options.js index 87c20af66..c0008334a 100644 --- a/test/browser/runner-main-options.js +++ b/test/browser/runner-main-options.js @@ -4,15 +4,15 @@ var less = { }; less.strictMath = true; less.functions = { - add: function(a, b) { - return new(less.tree.Dimension)(a.value + b.value); - }, - increment: function(a) { - return new(less.tree.Dimension)(a.value + 1); - }, - _color: function(str) { - if (str.value === "evil red") { - return new(less.tree.Color)("600"); - } - } + add: function(a, b) { + return new(less.tree.Dimension)(a.value + b.value); + }, + increment: function(a) { + return new(less.tree.Dimension)(a.value + 1); + }, + _color: function(str) { + if (str.value === "evil red") { + return new(less.tree.Color)("600"); + } + } }; \ No newline at end of file diff --git a/test/plugins/visitor/index.js b/test/plugins/visitor/index.js index 6792c0620..8f4f1a4ab 100644 --- a/test/plugins/visitor/index.js +++ b/test/plugins/visitor/index.js @@ -4,19 +4,17 @@ }; RemoveProperty.prototype = { - isReplacing: true, - run: function (root) { - return this._visitor.visit(root); - }, - visitRule: function (ruleNode, visitArgs) { - if (ruleNode.name != '-some-aribitrary-property') - { - return ruleNode; + isReplacing: true, + run: function (root) { + return this._visitor.visit(root); + }, + visitRule: function (ruleNode, visitArgs) { + if (ruleNode.name != '-some-aribitrary-property') { + return ruleNode; + } else { + return []; + } } - else { - return []; - } - } }; exports.install = function(less, pluginManager) {