Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const parse = function (code) {
return babelEslint.parse(code).body[0].expression
}
const parse = function (code) {
return babelEslint.parse(code).body[0].declarations[0].init
}
const license = init(context, program, function () {
const options = context.options[0] || {};
const license = options.license;
assert(!!license, '"license" option is required');
const parsed = babelEslint.parse(license);
assert(!parsed.body.length, '"license" option must only include a single comment');
assert(parsed.comments.length === 1, '"license" option must only include a single comment');
return {
source: license,
nodeValue: normalizeWhitespace(parsed.comments[0].value)
};
});
Program() {
const options = context.options[0] || {}
const licenseToBeAdded = options.license
assert(!!licenseToBeAdded, '"license" option is required')
const parsed = parse(licenseToBeAdded)
assert(
!parsed.body.length,
'"license" option must only include a single comment'
)
assert(
parsed.comments.length === 1,
'"license" option must only include a single comment'
)
const license = {
source: licenseToBeAdded,
nodeValue: normalizeWhitespace(parsed.comments[0].value)
}
const sourceCode = context.getSourceCode()
const comment = sourceCode
return licenses.map((license, i) => {
const parsed = babelEslint.parse(license);
assert(!parsed.body.length, `"licenses[${i}]" option must only include a single comment`);
assert(parsed.comments.length === 1, `"licenses[${i}]" option must only include a single comment`);
return normalizeWhitespace(parsed.comments[0].value);
});
});