This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module.exports.fix = (path) => { | |
path.node.value.raw = '\n'; | |
}; | |
module.exports.traverse = ({push}) => ({ | |
TemplateLiteral(path) { | |
const [start] = path.node.quasis; | |
if (/^\n\s+/.test(start.value.raw)) | |
push(path.get('quasis.0')); | |
} | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export function set(extra) { | |
extra += ` | |
${prefix}${casing[field] || field} | |
${value.raw ? "=" : ":"} | |
${value.value}`; | |
return extra; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const fs = require('fs') | |
const putout = require('putout') | |
async function trace(source, target) { | |
const estrace = await import('estrace/plugin'); | |
const newLine = await import('./setup/loaders/putout-new-line-plugin.js'); | |
const {code} = putout(await fs.promises.readFile(source, 'utf-8'), { | |
fixCount: 1, | |
rules: { | |
estrace: ['on', { url: 'inline', exclude: [ 'FunctionExpression', 'ArrowFunctionExpression' ] }] | |
}, | |
plugins: [ | |
[ 'estrace', estrace ], | |
[ 'new-line', newLine ], | |
], | |
}) | |
await fs.promises.writeFile(target, code) | |
} | |
async function main() { | |
await trace('source.js', 'traced.js') | |
} | |
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export function set(extra) { | |
try { | |
__estrace.enter('set', 'inline:1', arguments); | |
extra += ` | |
${prefix}${casing[field] || field} | |
${value.raw ? "=" : ":"} | |
${value.value}`; | |
return extra; | |
} finally { | |
__estrace.exit('set', 'inline:1'); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment