{"id":10847,"library":"estree-util-is-identifier-name","title":"Check ECMAScript Identifier Names","description":"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.","status":"active","version":"3.0.0","language":"javascript","source_language":"en","source_url":"https://github.com/syntax-tree/estree-util-is-identifier-name","tags":["javascript","estree","ast","ecmascript","tree","identifier","character","typescript"],"install":[{"cmd":"npm install estree-util-is-identifier-name","lang":"bash","label":"npm"},{"cmd":"yarn add estree-util-is-identifier-name","lang":"bash","label":"yarn"},{"cmd":"pnpm add estree-util-is-identifier-name","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"There is no default export. Use named imports for `name`. This package is ESM-only since v2.0.0, so `require()` will fail.","wrong":"import name from 'estree-util-is-identifier-name'","symbol":"name","correct":"import { name } from 'estree-util-is-identifier-name'"},{"note":"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.","wrong":"const start = require('estree-util-is-identifier-name').start","symbol":"start","correct":"import { start } from 'estree-util-is-identifier-name'"},{"note":"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.","wrong":"import * as estreeUtils from 'estree-util-is-identifier-name'; const { cont } = estreeUtils;","symbol":"cont","correct":"import { cont } from 'estree-util-is-identifier-name'"},{"note":"This symbol is a TypeScript type. Use `import type` for type-only imports to prevent potential runtime errors or bundling issues.","wrong":"import { Options } from 'estree-util-is-identifier-name'","symbol":"Options","correct":"import type { Options } from 'estree-util-is-identifier-name'"}],"quickstart":{"code":"import { cont, name, start } from 'estree-util-is-identifier-name';\n\n// Check if a string is a valid identifier name\nconsole.log('Is \"$something69\" a valid name?', name('$something69')); // => true\nconsole.log('Is \"69\" a valid name?', name('69')); // => false\nconsole.log('Is \"var\" a valid name (keywords are not handled here)?', name('var')); // => true\n\n// Check if a code point can start an identifier\n// 48 is the Unicode code point for '0'\nconsole.log('Can code point 48 (for \"0\") start an identifier?', start(48)); // => false\n// 97 is the Unicode code point for 'a'\nconsole.log('Can code point 97 (for \"a\") start an identifier?', start(97)); // => true\n\n// Check if a code point can continue an identifier\n// 48 is the Unicode code point for '0'\nconsole.log('Can code point 48 (for \"0\") continue an identifier?', cont(48)); // => true\n\n// Example with JSX option for names that include hyphens\nconsole.log('Is \"my-component\" a valid name (without JSX)?', name('my-component')); // => false\nconsole.log('Is \"my-component\" a valid name (with JSX)?', name('my-component', { jsx: true })); // => true","lang":"typescript","description":"Demonstrates how to validate full identifier names and individual code points for starting or continuing an identifier, including the optional JSX support."},"warnings":[{"fix":"Upgrade your Node.js environment to version 16 or higher.","message":"Version 3.0.0 and above require Node.js 16 or later. Older Node.js versions are no longer supported.","severity":"breaking","affected_versions":">=3.0.0"},{"fix":"Ensure you are passing actual Unicode code points (e.g., from `String.prototype.codePointAt()`) to `cont` and `start`.","message":"The `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.","severity":"breaking","affected_versions":">=3.0.0"},{"fix":"Migrate your codebase to use ES Modules (`import`) or ensure your environment supports dynamic `import()` for CommonJS contexts.","message":"The package switched to ESM-only in v2.0.0. Attempting to `require()` this package in a CommonJS context will result in an error.","severity":"breaking","affected_versions":">=2.0.0"},{"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.","message":"The 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.","severity":"breaking","affected_versions":">=3.0.0"}],"env_vars":null,"last_verified":"2026-04-19T00:00:00.000Z","next_check":"2026-07-18T00:00:00.000Z","problems":[{"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.","cause":"Attempting to `require()` the package in a CommonJS module after version 2.0.0.","error":"ERR_REQUIRE_ESM"},{"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.","cause":"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.","error":"TypeError: The 'code' argument must be an integer"},{"fix":"Change `import name from 'estree-util-is-identifier-name'` to `import { name } from 'estree-util-is-identifier-name'`.","cause":"Attempting to use a default import, but the package only provides named exports.","error":"SyntaxError: Named export 'default' not found (module 'estree-util-is-identifier-name.js')"}],"ecosystem":"npm"}