Registry / serialization / estree-util-is-identifier-name

estree-util-is-identifier-name

JSON →
library3.0.0jsnpmunverified

estree-util-is-identifier-name is a focused utility from the unified collective designed to determine whether a given string or Unicode code point can constitute a valid ECMAScript (JavaScript) identifier name. The package, currently at stable version 3.0.0, provides functions like `name` to validate full identifier strings, and `start` and `cont` to check individual code points for starting or continuing an identifier. Major releases, such as v3.0.0, typically coincide with updates to Node.js compatibility (now requiring Node.js 16+) and significant internal changes like the adoption of `exports` for module resolution and enhanced Unicode support for astrals and code points. A key differentiator is its strict adherence to ECMAScript identifier rules, including optional support for JSX identifiers, while intentionally not handling language keywords. It's an ESM-only package since v2.0.0 and ships with full TypeScript types.

npm install estree-util-is-identifier-name
INSTALL
IMPORT
SIG · ESTREE-UTIL-IS-IDE
E
estree-util-is-identifier-name
serializationjavascriptv3.0.0
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

name
import { name } from 'estree-util-is-identifier-name'
import name from 'estree-util-is-identifier-name'
There is no default export. Use named imports for `name`. This package is ESM-only since v2.0.0, so `require()` will fail.
start
import { start } from 'estree-util-is-identifier-name'
const start = require('estree-util-is-identifier-name').start
ESM-only since v2.0.0. `require()` will fail. In v3.0.0, the `code` parameter expects a Unicode code point, not a char code.
cont
import { cont } from 'estree-util-is-identifier-name'
import * as estreeUtils from 'estree-util-is-identifier-name'; const { cont } = estreeUtils;
Direct named imports are preferred. ESM-only since v2.0.0. In v3.0.0, the `code` parameter expects a Unicode code point, not a char code.
Options
import type { Options } from 'estree-util-is-identifier-name'
import { Options } from 'estree-util-is-identifier-name'
This symbol is a TypeScript type. Use `import type` for type-only imports to prevent potential runtime errors or bundling issues.

Demonstrates how to validate full identifier names and individual code points for starting or continuing an identifier, including the optional JSX support.

import { cont, name, start } from 'estree-util-is-identifier-name'; // Check if a string is a valid identifier name console.log('Is "$something69" a valid name?', name('$something69')); // => true console.log('Is "69" a valid name?', name('69')); // => false console.log('Is "var" a valid name (keywords are not handled here)?', name('var')); // => true // Check if a code point can start an identifier // 48 is the Unicode code point for '0' console.log('Can code point 48 (for "0") start an identifier?', start(48)); // => false // 97 is the Unicode code point for 'a' console.log('Can code point 97 (for "a") start an identifier?', start(97)); // => true // Check if a code point can continue an identifier // 48 is the Unicode code point for '0' console.log('Can code point 48 (for "0") continue an identifier?', cont(48)); // => true // Example with JSX option for names that include hyphens console.log('Is "my-component" a valid name (without JSX)?', name('my-component')); // => false console.log('Is "my-component" a valid name (with JSX)?', name('my-component', { jsx: true })); // => true
Debug
Known issues
breakingVersion 3.0.0 and above require Node.js 16 or later. Older Node.js versions are no longer supported.
fix
Upgrade your Node.js environment to version 16 or higher.
affects: >=3.0.0
breakingThe `cont` and `start` functions in v3.0.0 now expect Unicode code points as input, not char codes. Passing char codes (e.g., from `String.prototype.charCodeAt()`) will lead to incorrect results or unexpected behavior for astral characters.
fix
Ensure you are passing actual Unicode code points (e.g., from `String.prototype.codePointAt()`) to `cont` and `start`.
affects: >=3.0.0
breakingThe package switched to ESM-only in v2.0.0. Attempting to `require()` this package in a CommonJS context will result in an error.
fix
Migrate your codebase to use ES Modules (`import`) or ensure your environment supports dynamic `import()` for CommonJS contexts.
affects: >=2.0.0
breakingThe package now uses `exports` for module resolution, which may break paths for users relying on internal or non-standard module imports. Avoid using private APIs or deeply nested paths.
fix
Always use the main entry points (e.g., `import { name } from 'estree-util-is-identifier-name'`) and avoid direct imports from sub-paths or internal files.
affects: >=3.0.0
Errors
Common errors & fixes
ERR_REQUIRE_ESM
Attempting to `require()` the package in a CommonJS module after version 2.0.0.
fix
Change `const { name } = require('estree-util-is-identifier-name')` to `import { name } from 'estree-util-is-identifier-name'` and ensure your project is configured for ES Modules.
TypeError: The 'code' argument must be an integer
Passing non-numeric values or incorrect types to `start` or `cont` functions, or using `String.prototype.charCodeAt()` which returns UTF-16 code units (char codes) instead of Unicode code points for astral characters in v3.0.0.
fix
Ensure you pass a valid Unicode code point number (an integer) to `start` and `cont`. Use `String.prototype.codePointAt(index)` to get the correct code point for a character, especially for characters outside the Basic Multilingual Plane.
SyntaxError: Named export 'default' not found (module 'estree-util-is-identifier-name.js')
Attempting to use a default import, but the package only provides named exports.
fix
Change `import name from 'estree-util-is-identifier-name'` to `import { name } from 'estree-util-is-identifier-name'`.
Upgrade
Version history
3.0.0latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
2 hits · last 30 days
node
2
Resources
estree-util-is-identifier-name — npm install estree-util-is-identifier-name · libregistry