Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
parser.parse(content, function (err, tree) {
var env = new less.tree.evalEnv();
var ruleset = tree.eval(env); // jshint ignore:line
ruleset.rules.forEach(function (rule) {
if (rule.variable) {
var name = rule.name.substr(1); // remove "@"
var value = rule.value.value[0]; // can be less.tree.Color, less.tree.Expression, etc.
lessVars[name] = value.toCSS();
}
});
});
});
var path = require('path');
require.paths.unshift(path.join(__dirname, '..', '..'));
var less = require('less');
process.mixin(less, require('less/parser'));
process.mixin(less.tree, require('less/tree'));
process.mixin(exports, less);
require('ext/array');
Object.keys(options.customFunctions).forEach(function(name) {
less.tree.functions[name.toLowerCase()] = function() {
var args = [].slice.call(arguments);
args.unshift(less);
var res = options.customFunctions[name].apply(this, args);
return typeof res === "object" ? res : new less.tree.Anonymous(res);
};
});
}
/**
* @file LesslintVisitor 基类
* 这个类里会遍历 less ast 的 rules ,根据 rule 的类型去加载 lint 目录下不同的检测文件
* @author ielgnaw(wuji0223@gmail.com)
*/
var path = require('path');
var fs = require('fs');
var tree = require('less').tree;
var util = require('./util');
/**
* 解析需要检测的规则配置,生成真正需要检测的配置
* 会把不需要检测的配置从 me.detectConfigs 中过滤掉,需要检测的换成 lint 文件里的 exports
*
* @return {Object} 真正需要检测的配置
*/
function analyzeConfigs() {
var ret = {};
var me = this;
fs.readdirSync(
path.join(__dirname, 'rule')
).forEach(
function (fileName) {
module.exports.on = function () {
toCSS = less.tree.Ruleset.prototype.toCSS
less.tree.Ruleset.prototype.toCSS = compile
}
module.exports.on = function () {
toCSS = less.tree.Ruleset.prototype.toCSS
less.tree.Ruleset.prototype.toCSS = compile
}
module.exports.off = function () {
less.tree.Value.prototype.toCSS = toCSS
}
less.functions.functionRegistry.add(name.toLowerCase(), function() {
var args = [].slice.call(arguments);
args.unshift(less);
var res = options.customFunctions[name].apply(this, args);
return typeof res === 'object' ? res : new less.tree.Anonymous(res);
});
});
less.functions.functionRegistry.add(name.toLowerCase(), function() {
var args = [].slice.call(arguments);
args.unshift(less);
var res = options.customFunctions[name].apply(this, args);
return typeof res === 'object' ? res : new less.tree.Anonymous(res);
});
});
less.tree.functions[name.toLowerCase()] = function() {
var args = [].slice.call(arguments);
args.unshift(less);
var res = options.customFunctions[name].apply(this, args);
return typeof res === "object" ? res : new less.tree.Anonymous(res);
};
});