Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
// these messages have been put in too!
} else if (property.key.name === 'name') {
messageNameSpace = property.value.value;
}
});
}
registerFoundMessages(messageNameSpace, messages, module);
}
});
} else if (
module.resource &&
module.resource.indexOf('.js') === module.resource.length - 3 &&
!module.resource.includes('node_modules')
) {
// Inspect each source file in the chunk if it is a js file too.
ast = espree.parse(module._source.source(), {
sourceType: 'module',
});
var createTranslateFn;
// First find the reference being used for the create translator function
ast.body.forEach(node => {
// Check if an import
if (
node.type === espree.Syntax.ImportDeclaration &&
// Check if importing from the i18n alias
node.source.value === i18nAlias
) {
node.specifiers.forEach(spec => {
// Check if this import spec is for the createTranslator function
if (spec.imported.name === 'createTranslator') {
// If so store the locally imported variable name it was assigned to
createTranslateFn = spec.local.name;
it("should return empty array if there are no directives in FunctionDeclaration body", () => {
const ast = espree.parse("function foo() { return bar; }");
const node = ast.body[0];
assert.deepStrictEqual(astUtils.getDirectivePrologue(node), []);
});
it("does not visit type annotations multiple times after monkeypatching and calling parseForESLint()", () => {
assertImplementsAST(
espree.parse("foo", { sourceType: "module" }),
babelEslint.parse("foo", {})
);
const parseResult = babelEslint.parseForESLint(
"type Foo = {}; function x(): Foo {}",
{
eslintVisitorKeys: true,
eslintScopeManager: true,
}
);
assert(parseResult.visitorKeys);
assert(parseResult.scopeManager);
const fooVariable = parseResult.scopeManager.getDeclaredVariables(
parseResult.ast.body[0]
)[0];
("should work for ES6 syntax (espree)", function() {
var names;
var ast = espree.parse([
"var zap;",
"export default function(zom) {",
" var innerFn = function(zip) {};",
" return innerFn(zom);",
"};"
].join("\n"), {
sourceType: "module",
ecmaVersion: 6
});
visit(ast, {
visitFunctionDeclaration: function(path) {
names = Object.keys(path.scope.lookup("zap").getBindings()).sort();
assert.deepEqual(names, ["zap"]);
this.traverse(path);
}
it("should get proper lines when using \\u2028 as a line break", () => {
const code = "a;\u2028b;",
ast = espree.parse(code, DEFAULT_CONFIG),
sourceCode = new SourceCode(code, ast);
const lines = sourceCode.getLines();
assert.strictEqual(lines[0], "a;");
assert.strictEqual(lines[1], "b;");
});
function program(code) {
return espree.parse(code, {
sourceType: 'module',
ecmaVersion: 8,
ecmaFeatures: {
jsx: true,
experimentalObjectRestSpread: true
}
});
}
valueExpression = 'effectiveLang';
}
while (tmpPart = partPath.shift()) {
valueExpression += `["${tmpPart}"]`;
}
if (isJSON) {
valueExpression = `JSON.stringify(${valueExpression})`;
}
}
valueExpressions.push(valueExpression);
}
let valueExpressionAst;
if (isI18nFormat) {
valueExpression = valueExpressions.join(',');
valueExpression = `_bind.element.i18nFormat(${valueExpression})`;
valueExpressionAst = espree.parse(valueExpression, espreeModuleOptions).body[0].expression;
valueExpressions.forEach((param, index) => {
let tmpMatch = param.match(/^parts\[([0-9]*)\]$/);
if (tmpMatch) {
valueExpressionAst.arguments[index] = ast.quasi.expressions[parseInt(tmpMatch[1]) + offset]
}
});
}
else {
//console.log('html: part ' + part + ' = ' + valueExpression);
valueExpressionAst = espree.parse(valueExpression, espreeModuleOptions).body[0].expression;
}
parts.push(valueExpressionAst);
}
}
strings.push({
"type": "Literal",
function extractHtmlTemplates(code) {
let targetAst;
let templates = {
_classes: []
};
try {
targetAst = espree.parse(code, espreeModuleOptions);
//console.log(JSONstringify(targetAst, null, 2));
traverseAst(targetAst, templates);
}
catch (e) {
throw e;
}
delete templates._classes;
return templates;
}
parse: (source) => (
espree.parse(source, {
...options,
range: true,
loc: true,
comment: true,
attachComment: true,
tokens: true,
})
),
},
Parser.validateOptions(options);
super();
this.source = options.source;
this.features = options.features || SUPPORTED_FEATURES;
if (hasOwnProperty(options.source, 'script') && options.source.script) {
this.scriptOffset = options.source.scriptOffset || 0;
try {
this.ast = espree.parse(options.source.script, options);
} catch (e) {
const script = utils.escapeImportKeyword(options.source.script);
this.ast = espree.parse(script, options);
}
} else {
this.scriptOffset = 0;
this.ast = null;
}
this.includeSourceLocations = options.includeSourceLocations;
this.componentName = null;
this.template = options.source.template;
this.filename = options.filename;
this.eventsEmmited = {};
this.defaultMethodVisibility = options.defaultMethodVisibility;
this.defaultActionVisibility = options.defaultActionVisibility;
this.identifiers = {};
this.imports = {};
}