High-performance CommonJS module lexer for detecting named exports and reexports from JavaScript source code
93
Quality
Pending
Does it follow best practices?
Impact
93%
0.98xAverage score across 10 eval scenarios
Build a validator that analyzes JavaScript source code to extract and validate identifiers according to ECMA-262 standards, with particular attention to Unicode support and surrogate pair handling.
Your validator should:
Extract identifiers from JavaScript source code:
Validate identifiers according to JavaScript grammar rules:
Report validation results:
Parsing code with ASCII identifiers like exports.hello and module.exports.world returns valid identifiers ['hello', 'world'] @test
Parsing code with Unicode identifiers like exports.café and exports.日本語 correctly identifies these as valid identifiers @test
Parsing code with reserved words like exports.class and exports.if flags these as invalid because they are reserved words @test
Parsing code with surrogate pairs like exports.𝕳𝖊𝖑𝖑𝖔 (mathematical bold text) correctly handles the multi-byte Unicode characters @test
@generates
/**
* Validates JavaScript identifiers from source code.
*
* @param {string} source - JavaScript source code to analyze
* @returns {{ valid: string[], invalid: string[] }} Object containing arrays of valid and invalid identifiers
*/
function validateIdentifiers(source) {
// IMPLEMENTATION HERE
}
module.exports = {
validateIdentifiers
};Provides lexical analysis support for CommonJS modules
Install with Tessl CLI
npx tessl i tessl/npm-cjs-module-lexerdocs
evals
scenario-1
scenario-2
scenario-3
scenario-4
scenario-5
scenario-6
scenario-7
scenario-8
scenario-9
scenario-10