jsx-ast-utils-x is a dedicated utility module for statically analyzing JSX Abstract Syntax Tree (AST) nodes. It provides a set of helper functions to query and extract information from JSX elements, attributes, and expressions, making it particularly useful for developing custom ESLint rules or other static analysis tools for React or similar JSX-based codebases. The current stable version is `0.1.0`. As a new package, its release cadence is likely to be agile, with minor versions addressing new features or bug fixes. Key differentiators include its focused scope, providing a core set of AST traversal and querying functions specifically for JSX, and its lean dependency tree (recently replacing external dependencies with built-in methods) which contributes to a smaller footprint and potentially better performance. It serves as a more modular and potentially more modern alternative to similar functionality found embedded in larger linting plugins.
npm install jsx-ast-utils-xVerified import paths — ran on the pinned version, not inferred.
This ESLint rule example demonstrates how to use `hasProp`, `getPropValue`, and `elementType` to enforce accessibility best practices for JSX elements, specifically checking for `aria-label` attributes on elements and reporting issues for empty or missing labels on buttons.
Review your usage with the latest version. If you encounter unexpected behavior, compare against the previous versions to identify any regressions or changes in how specific AST nodes are handled.
Always ensure the AST nodes passed to `jsx-ast-utils-x` functions are valid JSX AST structures, typically obtained from a parser like `@babel/eslint-parser` or `typescript-eslint`.
Add nullish checks before accessing properties or passing them to `jsx-ast-utils-x` functions. For instance, `if (node.attributes) { hasProp(node.attributes, 'name'); }`.Ensure your ESLint configuration (e.g., `.eslintrc.js`) specifies `parserOptions: { ecmaVersion: 'latest', sourceType: 'module' }` if you are using `import` statements directly in the config file itself, or if the files being linted are ESM.No dependency data recorded yet.