Babel plugin that transforms eval() calls containing string literals by parsing and compiling the string content at transform time
Overall
score
98%
A Babel plugin that transforms console statements to include file location information for better debugging.
Create a Babel plugin that automatically enhances console.log(), console.warn(), and console.error() calls by prepending location information (filename and line number) to the first argument. The plugin should only transform console calls that have at least one argument.
For example, this code:
console.log('Hello, world!');
console.warn('Warning message');Should be transformed to:
console.log('[main.js:1]', 'Hello, world!');
console.warn('[main.js:2]', 'Warning message');log, warn, and errorconsole.log())[filename:line] as the first argument@generates
/**
* Babel plugin that transforms console statements to include file location.
*
* @returns {Object} Babel plugin object with visitor
*/
export default function() {
// Plugin implementation
}console.log('test') to include file location prefix @testconsole.warn('warning') to include file location prefix @testconsole.error('error') to include file location prefix @testconsole.log() with zero arguments @testProvides the Babel transformation API and core functionality.
@satisfied-by
Provides utilities for AST node creation and type checking.
@satisfied-by
Install with Tessl CLI
npx tessl i tessl/npm-babel-plugin-transform-evaldocs
evals
scenario-1
scenario-2
scenario-3
scenario-4
scenario-5
scenario-6
scenario-7
scenario-8
scenario-9
scenario-10