Registry / testing / eslint-type-tracer

eslint-type-tracer

JSON →
library0.5.2jsnpmunverified

A utility for inferring runtime types of expression nodes within ESLint rules, enabling type-aware linting without a full TypeScript type checker. Version 0.5.2 is the latest stable release with support for Temporal, Math.sumPrecise(), well-known symbols, and improved type definitions. It is published under MIT license and maintained by ota-meshi. Key differentiators: lightweight, no external runtime dependencies, limited to single-file analysis (no cross-module inference), and exports ESM via .mjs extension. Designed for ESLint v8.57+, Node.js >=18. Typical use cases include validating arrays, strings, numbers, and other built-in types inside ESLint rule implementations.

npm install eslint-type-tracer
INSTALL
IMPORT
SIG · ESLINT-TYPE-TRACER
E
eslint-type-tracer
testingjavascriptv0.5.2
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.

buildTypeTracer
import { buildTypeTracer } from 'eslint-type-tracer'
const { buildTypeTracer } = require('eslint-type-tracer')
Since v0.5.1, package uses .mjs extension. CommonJS require() still works if the runtime supports it, but ESM import is preferred.
buildTypeChecker
import { buildTypeChecker } from 'eslint-type-tracer'
import buildTypeChecker from 'eslint-type-tracer'
Default import is not supported. Only named exports are available.
TypeName
import type { TypeName } from 'eslint-type-tracer'
TypeName is a type exported for TypeScript users; it is not a runtime value. Use type import.

Creates an ESLint rule that uses buildTypeTracer to infer the type of the object in a member expression and reports if it is an Array.

import { buildTypeTracer } from 'eslint-type-tracer'; import type { Rule } from 'eslint'; const myRule: Rule.RuleModule = { create(context) { const typeTrace = buildTypeTracer(context.sourceCode); return { CallExpression(node) { const callee = node.callee; if (callee.type === 'MemberExpression') { const objectTypeNames = typeTrace(callee.object); if (objectTypeNames.includes('Array')) { context.report({ node, message: 'Array method called.' }); } } } }; } }; export default myRule;
Debug
Known issues
breakingIn v0.5.0, support for Temporal was added, which may cause breakage if your code expects previous behavior with Date-like types now being inferred as Temporal types.
fix
Update to v0.5.2 or later where Temporal definitions were improved.
affects: >=0.5.0 <0.5.2
breakingIn v0.2.0, the API was redesigned. The previous default export or function signatures are removed.
fix
Migrate to v0.2.0+ using buildTypeTracer and buildTypeChecker.
affects: <0.2.0
deprecatedThe package is ESM-first starting v0.5.1. CommonJS require may still work but is not officially supported and may break in future versions.
fix
Switch to ESM imports ('import { ... } from "eslint-type-tracer"') or use dynamic import.
affects: >=0.5.1
gotchaType inference is limited to the current file only. Cross-module types cannot be inferred.
fix
Do not rely on the tool for cross-module inference; consider using TypeScript's type checker if needed.
affects: >=0.1.0
Errors
Common errors & fixes
Error [ERR_REQUIRE_ESM]: require() of ES Module ... from ... not supported.
Since v0.5.1, the package exports ES modules (.mjs) and CommonJS require() is not natively supported in older Node versions.
fix
Use dynamic import: const { buildTypeTracer } = await import('eslint-type-tracer'); or use ESM in your project.
Cannot find module 'eslint-type-tracer' or its corresponding type declarations.
TypeScript cannot find types if the package is not installed or if the import path is wrong.
fix
Ensure eslint-type-tracer is installed and that you are using the correct import: import { buildTypeTracer } from 'eslint-type-tracer'.
Upgrade
Version history
0.5.2latest on npm
Audit
Dependencies
eslintrequiredPeer dependency: the package is designed to work as an ESLint plugin utility and requires ESLint v8.57+
Agent activity
4 hits · last 30 days
node
4
Resources
eslint-type-tracer — npm install eslint-type-tracer · libregistry