Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

undeclared-identifiers

goto-bus-stop4.3mApache-2.01.1.3

find undeclared identifiers and property accesses in a javascript file.

ast, check, detect, identifiers, javascript, undeclared

readme

undeclared-identifiers

find undeclared identifiers and property accesses in a javascript file.

npm travis standard

Install

npm install undeclared-identifiers

Usage

var undeclaredIdentifiers = require('undeclared-identifiers')

undeclaredIdentifiers(src)
// { identifiers: ['Buffer'],
//   properties: ['Buffer.isBuffer'] }

API

res = undeclaredIdentifiers(source, opts)

Find undeclared identifiers and properties that are used in the source. source can be an AST or a source string that will be parsed using acorn-node.

res is an object with properties:

  • res.identifiers - an array of variable names as strings.
  • res.properties - an array of property names as .-separated strings, such as 'xyz.abc'. These are the property accesses on the undeclared variables found in res.identifiers.

Set opts.properties to false to only return identifiers.

When opts.wildcard is true, unknown uses of undeclared identifiers will be added to res.properties as 'VarName.*'.

undeclaredIdentifiers('Buffer(), Buffer.from()', { wildcard: true })
// { identifiers: ['Buffer'],
//   properties: ['Buffer.*', 'Buffer.from'] }

License

Apache-2.0

changelog

undeclared-identifiers change log

All notable changes to this project will be documented in this file.

This project adheres to Semantic Versioning.

1.1.3

  • Do not count class names and method names as undeclared. (#1)

1.1.2

  • Fix wildcard use not being detected after property use. (349d998)

1.1.1

  • Fix standard property access being detected as wildcards. (029a0b7)

1.1.0

1.0.0

  • initial release.