Registry / testing / twoslash-eslint

twoslash-eslint

JSON →
library0.3.8jsnpmunverified

ESLint-backed twoslash runner for annotating code examples with ESLint errors and warnings. Current stable version is 0.3.8, released on a monthly cadence. Key differentiators: integrates ESLint diagnostic results directly into twoslash code blocks, supports TypeScript v6 since v0.3.7, and is part of the twoslash monorepo. Experimental — breaking changes may not follow semver. Ships TypeScript types.

npm install twoslash-eslint
INSTALL
IMPORT
SIG · TWOSLASH-ESLINT
T
twoslash-eslint
testingjavascriptv0.3.8
Install
—
Import
—
Disk
—
Pass rate
0/ 6
Env Coverage0 / 6
glibc
18–22
musl
18–22
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 18–226 runs
build_error
glibc
node 18–226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

createTwoslashESLint
✓ import { createTwoslashESLint } from 'twoslash-eslint'
✗ const createTwoslashESLint = require('twoslash-eslint')
ESM-only package; CommonJS require() will fail. Use dynamic import or ESM context.
default
✓ import twoslashESLint from 'twoslash-eslint'
Default export is an alias for createTwoslashESLint. Available since v0.2.0.
TypeScriptESLintRunner
✓ import { TypeScriptESLintRunner } from 'twoslash-eslint'
✗ import { TypeScriptESLintRunner } from 'twoslash'
TypeScriptESLintRunner is a custom runner class exported from twoslash-eslint, not from core twoslash.

Creates an ESLint-backed twoslash runner and applies it to a code example with a custom ESLint rule.

import { createTwoslashESLint } from 'twoslash-eslint' import { createTwoslash } from 'twoslash' const twoslashESLint = createTwoslashESLint({ eslint: { // ESLint options overrideConfig: { rules: { 'no-unused-vars': 'warn' } } } }) const result = createTwoslash({ code: 'let x = 1', defaultCompilerOptions: { strict: true }, customRunners: [twoslashESLint] })
Debug
Known issues
breakingSince v0.3.0, TypeScript ^5.5.0 is explicitly required. Older TypeScript versions are unsupported.
fix
Upgrade TypeScript to >=5.5.0 or stay on v0.2.x if you need older TS support.
affects: <0.3.0
gotchaThe package is experimental and breaking changes may not follow semver.
fix
Pin to a specific version and test upgrades carefully.
affects: >=0.0.0
deprecatedThe `writeGlobalTypes` option was removed in v0.3.5 for Vue integration.
fix
Remove `writeGlobalTypes` from configuration. Use other Vue type handling mechanisms if needed.
affects: >=0.3.5
Errors
Common errors & fixes
ERR_REQUIRE_ESM: require() of ES Module not supported
Using CommonJS require() to import an ESM-only package.
fix
Use dynamic import: const m = await import('twoslash-eslint') or set your project to type: module.
Cannot find module 'twoslash-eslint'
Package not installed or missing from package.json dependencies.
fix
Run npm install twoslash-eslint (peer dep eslint must also be installed).
Upgrade
Version history
0.3.8latest on npm
Audit
Dependencies
eslintrequiredRuntime peer dependency required for ESLint integration
Agent activity
12 hits · last 30 days
node
12
Resources
twoslash-eslint — npm install twoslash-eslint · libregistry