JSX parsing plugin for the Acorn JavaScript parser that enables fast parsing of React JSX syntax
76
Build a validation tool that analyzes JSX code and detects invalid attribute expressions.
Your tool should parse JSX source code and identify attributes that have empty expression containers. When such invalid syntax is found, the tool should report an error with a descriptive message indicating the problem.
The validator should:
attribute={})@generates
Implement a function validateJSX that takes a string of JSX source code and returns a validation result object with the following structure:
{
valid: boolean, // true if no errors, false otherwise
error: string | null // error message if invalid, null otherwise
}<div attr={} />), the validator returns valid: false with an appropriate error message @test<div attr={value} />), the validator returns valid: true with no error @test<div>{}</div>), the validator returns valid: true since this is allowed in JSX @test/**
* Validates JSX source code for empty expression containers in attributes
*
* @param {string} jsxCode - The JSX source code to validate
* @returns {Object} Validation result with 'valid' boolean and 'error' string
*/
function validateJSX(jsxCode) {
// Implementation here
}
module.exports = { validateJSX };JavaScript parser that provides the base parsing functionality.
JSX parsing plugin for Acorn that adds JSX syntax support and validation.
Install with Tessl CLI
npx tessl i tessl/npm-acorn-jsxdocs
evals
scenario-1
scenario-2
scenario-3
scenario-4
scenario-5
scenario-6
scenario-7
scenario-8
scenario-9
scenario-10