Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
isPolyfill: polyfill || false,
sourceCode,
});
}
let hasteID = null;
if (filename.indexOf(NODE_MODULES) === -1 && !polyfill) {
if (options.hasteImplModulePath != null) {
// eslint-disable-next-line no-useless-call
const HasteImpl = (require.call(
null,
options.hasteImplModulePath,
): HasteImpl);
hasteID = HasteImpl.getHasteName(filename);
} else {
hasteID = docblock.parse(docblock.extract(sourceCode)).providesModule;
}
}
return {
details: {
file: filename,
hasteID: hasteID || null,
transformed,
type: options.polyfill ? 'script' : 'module',
},
type: 'code',
};
}
function insertPragma(text) {
const parsedDocblock = docblock.parseWithComments(docblock.extract(text));
const pragmas = Object.assign({ format: "" }, parsedDocblock.pragmas);
const newDocblock = docblock
.print({
pragmas,
comments: parsedDocblock.comments.replace(/^(\s+?\r?\n)+/, "") // remove leading newlines
})
.replace(/(\r\n|\r)/g, "\n"); // normalise newlines (mitigate use of os.EOL by jest-docblock)
const strippedText = docblock.strip(text);
const separatingNewlines = strippedText.startsWith("\n") ? "\n" : "\n\n";
return newDocblock + separatingNewlines + strippedText;
}
function insertPragma(text) {
const parsedDocblock = docblock.parseWithComments(docblock.extract(text));
const pragmas = { format: "", ...parsedDocblock.pragmas };
const newDocblock = docblock
.print({
pragmas,
comments: parsedDocblock.comments.replace(/^(\s+?\r?\n)+/, ""), // remove leading newlines
})
.replace(/(\r\n|\r)/g, "\n"); // normalise newlines (mitigate use of os.EOL by jest-docblock)
const strippedText = docblock.strip(text);
const separatingNewlines = strippedText.startsWith("\n") ? "\n" : "\n\n";
return newDocblock + separatingNewlines + strippedText;
}
function insertPragma(text) {
const parsedDocblock = docblock.parseWithComments(docblock.extract(text));
const pragmas = Object.assign({ format: "" }, parsedDocblock.pragmas);
const newDocblock = docblock
.print({
pragmas,
comments: parsedDocblock.comments.replace(/^(\s+?\r?\n)+/, "") // remove leading newlines
})
.replace(/(\r\n|\r)/g, "\n"); // normalise newlines (mitigate use of os.EOL by jest-docblock)
const strippedText = docblock.strip(text);
const separatingNewlines = strippedText.startsWith("\n") ? "\n" : "\n\n";
return newDocblock + separatingNewlines + strippedText;
}
function insertPragma(text) {
const parsedDocblock = docblock.parseWithComments(docblock.extract(text));
const pragmas = { format: "", ...parsedDocblock.pragmas };
const newDocblock = docblock
.print({
pragmas,
comments: parsedDocblock.comments.replace(/^(\s+?\r?\n)+/, ""), // remove leading newlines
})
.replace(/(\r\n|\r)/g, "\n"); // normalise newlines (mitigate use of os.EOL by jest-docblock)
const strippedText = docblock.strip(text);
const separatingNewlines = strippedText.startsWith("\n") ? "\n" : "\n\n";
return newDocblock + separatingNewlines + strippedText;
}
function insertPragma(text) {
const parsedDocblock = docblock.parseWithComments(docblock.extract(text));
const pragmas = Object.assign({ format: "" }, parsedDocblock.pragmas);
const newDocblock = docblock
.print({
pragmas,
comments: parsedDocblock.comments.replace(/^(\s+?\r?\n)+/, "") // remove leading newlines
})
.replace(/(\r\n|\r)/g, "\n"); // normalise newlines (mitigate use of os.EOL by jest-docblock)
const strippedText = docblock.strip(text);
const separatingNewlines = strippedText.startsWith("\n") ? "\n" : "\n\n";
return newDocblock + separatingNewlines + strippedText;
}
function insertPragma(text) {
const parsedDocblock = docblock.parseWithComments(docblock.extract(text));
const pragmas = { format: "", ...parsedDocblock.pragmas };
const newDocblock = docblock
.print({
pragmas,
comments: parsedDocblock.comments.replace(/^(\s+?\r?\n)+/, ""), // remove leading newlines
})
.replace(/(\r\n|\r)/g, "\n"); // normalise newlines (mitigate use of os.EOL by jest-docblock)
const strippedText = docblock.strip(text);
const separatingNewlines = strippedText.startsWith("\n") ? "\n" : "\n\n";
return newDocblock + separatingNewlines + strippedText;
}
function hasPragma(text) {
const pragmas = Object.keys(docblock.parse(docblock.extract(text)));
return pragmas.indexOf("prettier") !== -1 || pragmas.indexOf("format") !== -1;
}
function initDefaultOptions(state) {
defaultOptions = {};
const comment = state.file.ast.comments[0];
const docblock = (comment && comment.value) || '';
const fbtDocblockOptions = parseDocblock(docblock).fbt;
if (fbtDocblockOptions) {
defaultOptions = JSON.parse(fbtDocblockOptions);
Object.keys(defaultOptions).forEach(o => checkOption(o, ValidFbtOptions));
}
if (!defaultOptions.project) {
defaultOptions.project = '';
}
}
function initDefaultOptions(state) {
defaultOptions = {};
const comment = state.file.ast.comments[0];
const docblock = (comment && comment.value) || '';
const fbtDocblockOptions = parseDocblock(docblock).fbt;
if (fbtDocblockOptions) {
defaultOptions = JSON.parse(fbtDocblockOptions);
Object.keys(defaultOptions).forEach(o => checkOption(o, ValidFbtOptions));
}
if (!defaultOptions.project) {
defaultOptions.project = '';
}
}