Babel plugin that compiles ES2015 unicode string and number literals to ES5
86
Build a Babel plugin that formats hexadecimal numeric literals for improved readability.
Modern codebases often contain hexadecimal literals that represent various values like colors, memory addresses, or bit masks. While these values are functionally correct, they can benefit from consistent formatting to improve code readability.
Create a Babel plugin that processes JavaScript/TypeScript code and applies formatting rules to hexadecimal numeric literals (those starting with 0x or 0X).
Your plugin should:
0x)0xff.toString())The plugin should transform code like this:
// Input
const color = 0XaBcDeF;
const mask = 0x1a2b;
const value = 0Xff.toString();
// Output
const color = 0xABCDEF;
const mask = 0x1A2B;
const value = 0xFF.toString();@generates
/**
* Babel plugin that formats hexadecimal literals
* @returns {Object} Babel plugin object
*/
export default function() {
// Implementation here
}0xabc to 0xABC @test0XDEF to 0xDEF @test0XaBc123 to 0xABC123 @test0xff.toString() correctly @testProvides utilities for creating Babel plugins with proper versioning and API compatibility.
Core Babel transformation system. Required for plugin development and testing.
Install with Tessl CLI
npx tessl i tessl/npm-babel-plugin-transform-es2015-literalsdocs
evals
scenario-1
scenario-2
scenario-3
scenario-4
scenario-5
scenario-6
scenario-7
scenario-8
scenario-9
scenario-10