Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
}
})
.toSource()
// HACK to remove dangling ${} after clean up
// TODO: remove CSS calls from AST instead of with comments
const cleanSource = newSource
.replace(/[\s]+\$\{\/\/TOGGLE_REMOVE[\s]+(css)?`/gm, '')
.replace(/`\/\*TOGGLE_REMOVE\*\/}[\s]*/gm, '')
if (skipCodeFormatting) {
return cleanSource
}
try {
return format({
text: cleanSource,
prettierOptions: {
parser: 'flow'
},
filePath: eslintConfigPath || ESLINT_CONFIG_PATH
})
} catch (e) {
console.error('file path', file.path)
return cleanSource
}
}
return new Promise(async (resolve, reject) => {
scrolex.stick('Making Pretty', { components: `invig>${srcPath}` })
srcPath = srcPath.replace(/\.coffee$/, '.js')
const sourceCode = await fs.readFile(srcPath, 'utf8')
const options = {
text : sourceCode,
eslintConfig,
prettierOptions: {
bracketSpacing: true,
},
fallbackPrettierOptions: {
singleQuote: true,
printWidth : 120,
},
}
const code = format(options)
if (this.opts.dryrun) resolve()
fs.outputFile(srcPath, code).then(resolve).catch(reject)
})
}
'space-before-function-paren': [2, 'always'],
'padding-line-between-statements': [
2,
{ blankLine: 'always', prev: 'import', next: 'export' }
],
'lines-around-comment': [2, { beforeLineComment: true }],
'no-console': 0,
'no-empty': 0,
'no-unused-vars': 0,
'no-constant-condition': 0,
'no-trailing-spaces': 0
}
}
};
const formattedCode = format(options);
fs.writeFileSync(target, formattedCode);
return;
}
fs.writeFileSync(target, code);
}