This package, `undeclared-identifiers`, provides a utility to identify undeclared identifiers and property accesses within JavaScript source code or an existing Abstract Syntax Tree (AST). It primarily targets older JavaScript environments, as indicated by its last significant update (v1.1.3 in 2018) and its internal reliance on `acorn-node` for parsing. It returns an object containing arrays of identified undeclared variable names and their associated property accesses. It does not perform full scope resolution, but rather flags any identifier not explicitly declared within its immediate context, making it suitable for basic linting, dependency analysis, or static code checks in environments where modern tooling might be overkill or incompatible. The package has seen infrequent updates since its initial releases, suggesting it is in a maintenance mode, with no new feature development expected.
npm install undeclared-identifiersVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to use `undeclared-identifiers` to find undeclared variables and property accesses in a given JavaScript source string, including the use of the `wildcard` option.
For projects using modern JavaScript, consider using a more actively maintained code analysis tool or an AST parser that supports the latest ECMAScript specifications.
Understand its focused scope. For comprehensive scope analysis, static type checking, or advanced linting, combine this tool with a full linter like ESLint or a TypeScript compiler.
Update to `undeclared-identifiers@1.1.3` or newer to correctly handle class and method declarations.
Update to `undeclared-identifiers@1.1.2` or newer to ensure correct behavior of the `wildcard` option.
Use a default import instead: `import undeclaredIdentifiers from 'undeclared-identifiers'`. If using `require`, ensure it's assigned to a variable directly: `const undeclaredIdentifiers = require('undeclared-identifiers')`.If analyzing modern JavaScript, you might need to pre-process your code to an older standard (e.g., using Babel) or consider a different code analysis tool that uses an up-to-date parser. This package is best suited for older JS codebases or environments.