esniff is a specialized, low-footprint JavaScript source code parser designed for use cases that require syntax-aware analysis without needing to construct a full Abstract Syntax Tree (AST). It excels at tasks like finding specific function calls or property accesses by navigating the code based on syntax rules, which is more robust than regular expression matching. The current stable version is 2.0.1, released in February 2024. The package maintains a relatively active release cadence, with several minor and patch updates and a major breaking change (v2.0.0) in early 2024. Its key differentiator is its focus on efficiency and targeted code fragment detection over comprehensive AST generation, making it suitable for performance-critical analysis where a full AST would be overkill.
npm install esniffVerified import paths — ran on the pinned version, not inferred.
Demonstrates how to use `esniff` to parse all `require()` calls within a given code string, leveraging the `trigger` event and `accessor` methods.
Rewrite calls to `esniff` to use the new `executor` function signature, interacting with the provided `emitter` and `accessor` object. Refer to the v2.0.0 documentation for the updated API.
Review existing code analysis logic to ensure compatibility with modern ECMAScript identifier rules. No direct code fix for `esniff` itself, but the interpretation of results might change.
Update import paths for all affected utility modules to include the `utils/` prefix. For example, `require('esniff/accessed-properties')` becomes `require('esniff/utils/accessed-properties')`.Ensure that code passed to `esniff` is syntactically valid. Consider pre-validating code with a linter or a more robust parser if syntax error detection is required.
Be aware of this specific edge case. If such code patterns are expected, manual pre-processing or alternative parsing might be necessary for those specific code fragments. Most real-world code does not exhibit this pattern.
Update your `esniff` calls to match the v2.0.0 `esniff(code, executor)` signature. The second argument should be a function that receives an `emitter`.
Change the import path to include the `utils/` subdirectory. For example, `require('esniff/accessed-properties')` should be `require('esniff/utils/accessed-properties')`.For modern Node.js environments configured for ESM (e.g., `"type": "module"` in `package.json`), use `import esniff from 'esniff';` instead of `const esniff = require('esniff');`. If both ESM and CJS are needed, ensure dual-package authoring or use a bundler that handles interoperability.No dependency data recorded yet.