Registry / testing / eslint-traverse

eslint-traverse

JSON →
library1.0.1jsnpmunverified

ESLint utility (v1.0.1) for creating sub-traversals of AST nodes within ESLint plugin rules. It provides a fast, lightweight traversal with 'SKIP' and 'STOP' controls, and a Path object containing node, parent, parentKey, and parentPath for ancestor tracking. Unlike manual recursive walks, it integrates directly with ESLint's context and offers Babel-style path objects. Minimal maintenance; last release 2018.

npm install eslint-traverse
INSTALL
IMPORT
SIG · ESLINT-TRAVERSE
E
eslint-traverse
testingjavascriptv1.0.1
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.

default
import traverse from 'eslint-traverse'
const traverse = require('eslint-traverse')
Package provides ESM default export; CJS require works but is not the advertised pattern.
traverse.SKIP
import traverse from 'eslint-traverse'; return traverse.SKIP
return 'skip'
SKIP is a property on the default export, not a string literal.
traverse.STOP
import traverse from 'eslint-traverse'; return traverse.STOP
return false
STOP is a unique symbol; returning falsy values does not stop traversal.

Shows how to use traverse inside an ESLint rule, skipping child functions and stopping at 'x' identifier.

import traverse from 'eslint-traverse'; export default function(context) { return { FunctionDeclaration(node) { traverse(context, node, (path) => { if (path.node.type === 'FunctionDeclaration') { return traverse.SKIP; } if (path.node.type === 'Identifier' && path.node.name === 'x') { return traverse.STOP; } console.log(path.node.type); }); } }; }
Debug
Known issues
gotchatraverse.SKIP and traverse.STOP are properties on the default export, not imported directly
fix
Use traverse.SKIP and traverse.STOP after importing traverse as default.
affects: *
gotchaThe traversal includes the starting node itself; the visitor is called for the root node.
fix
Check path.parent to skip root processing if needed.
affects: *
deprecatedPackage has not been updated since 2018; may not support latest ESLint AST changes (e.g., experimental syntax).
fix
Consider forking or using eslint-plugin-query if you need newer features.
affects: 1.0.1
Errors
Common errors & fixes
Cannot find module 'eslint-traverse'
Missing dependency in package.json.
fix
Run `npm install --save-dev eslint-traverse`.
TypeError: traverse is not a function
Incorrect import (named import vs default import).
fix
Use `import traverse from 'eslint-traverse'` instead of `import { traverse } from 'eslint-traverse'`.
traverse.SKIP is undefined
Using a namespace or named import instead of default import.
fix
Import default: `import traverse from 'eslint-traverse'` and access its properties.
Upgrade
Version history
1.0.1latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
4 hits · last 30 days
node
4
Resources
eslint-traverse — npm install eslint-traverse · libregistry