Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
var featureify = function(source, config) {
config = config || {};
enabled = config.enabled || {};
var namespace = config.namespace || "Ember";
var tree = esprima.parse(source, {
range: true
});
var sourceModifier = new SourceModifier(source);
var walk = function(node) {
if (node.type === "IfStatement") {
if (node.test.type === "CallExpression" && node.test.callee) {
// test object.property.property
if (node.test.callee.object &&
node.test.callee.object.object &&
node.test.callee.object.property) {
// test namespace.FEATURES.isEnabled()
if (node.test.callee.object.object.name === namespace &&
node.test.callee.object.property.name === "FEATURES" &&
node.test.callee.property.name === "isEnabled") {
var featureName = node.test.arguments[0].value;
module.exports = function (text, output, scope) {
var tree = esprima.parse(text);
var tracker = newScope()
crawlScope(tree, function (node, scope, parent, param, path) {
var fn = crawls[node.type]
if (fn) fn(node, scope, parent, param, path)
}, tracker, newScope);
var globals = Object.getOwnPropertyNames(window)
.concat(['arguments', 'this', 'setTimeout', 'clearTimeout', 'setInterval', 'clearInterval']);
// fixScope(tracker, tree, globals)
catchOutputs(tree, '$out')
var code = escodegen.generate(tree)
code += ';' + tracker.declared.map(function (name) {
checkString: function(str, filename) {
filename = filename || 'input';
var tree;
str = str.replace(/^#![^\n]+\n/, '\n');
try {
tree = esprima.parse(str, {loc: true, range: true, comment: true, tokens: true});
} catch (e) {
throw new Error('Syntax error at ' + filename + ': ' + e.message);
}
var file = new JsFile(filename, str, tree);
var errors = new Errors(file);
this._activeRules.forEach(function(rule) {
// Do not process the rule if it's equals to null (#203)
if (this._config[rule.getOptionName()] !== null ) {
rule.check(file, errors);
}
}, this);
// sort errors list to show errors as they appear in source
errors.getErrorList().sort(function(a, b) {
function addAdRequire(ast, adRequirePath) {
var body = ast.body;
var useStrictNode = body[0];
assert.ok(isUseStrictExpr(useStrictNode));
var requireNode = parse("var ad = require('" + adRequirePath + "');").body[0];
var rest = body.slice(1);
// Remove any existing calls to require ad, to avoid duplication.
var restFiltered = rest.filter(function(node) {
return !_.isEqual(node, requireNode);
});
return build.program([useStrictNode, requireNode].concat(restFiltered));
}
describe('CanIUseProvider', () => {
for (const test of tests) {
const MemberExpression = new SourceCode(test.code, esprima.parse(test.code, {
tokens: true,
loc: true,
comment: true,
range: true,
tolerant: true,
attachComment: true
}));
const isValid = DetermineCompat(MemberExpression.ast.body[0].expression);
it(test.name || test.id, () => {
expect(isValid).to.equal(test.pass);
});
}
});
function check(src1: any, src2: any) {
astNodesAreEquivalent.assert(parse(src1), parse(src2));
}
return options.go(evaluate(node.arguments[0], scope, options), function (arg) {
var node
try {
node = esprima.parse(arg)
} catch (ex) {
var SyntaxError = scope.get('SyntaxError')
throw new SyntaxError(ex.message)
}
return evaluate(node, scope, options)
})
} else if (node.callee.type === 'MemberExpression') {
function compile(content, filename) {
var tree, licenses, comments, formatOption, preserveLicenseComment, propagateLicenseComment;
preserveLicenseComment = argv.preserveLicenseComment;
propagateLicenseComment = argv.propagateLicenseCommentToHeader;
tree = esprima.parse(content, {
loc: true,
range: true,
raw: true,
tokens: true,
comment: preserveLicenseComment || propagateLicenseComment
});
comments = concatSingleLineComments(content, tree.comments || []);
if (preserveLicenseComment || propagateLicenseComment) {
licenses = comments.reduce(function (results, commentBlock) {
if (!commentBlock.isLicense()) {
return results;
}
return results.concat(commentBlock.comments);
}, []);
function createAst(content) {
try {
return esprima.parse(content, { loc: true });
} catch (e) {
logger.error(e.message);
return "";
}
}
function parse(src){
return esprima.parse(src, {
range: true
});
};