Registry /
testing / eslint-vitest-rule-tester
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
muslnode 18–226 runs
build_error
glibcnode 18–226 runs
build_error
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
run
✓ import { run } from 'eslint-vitest-rule-tester'
✗ const { run } = require('eslint-vitest-rule-tester')
ESM-only package; require() will fail if not using a bundler with ESM interop.
createRuleTester
✓ import { createRuleTester } from 'eslint-vitest-rule-tester'
✗ import createRuleTester from 'eslint-vitest-rule-tester'
createRuleTester is a named export, not default.
runClassic
✓ import { runClassic } from 'eslint-vitest-rule-tester'
✗ import { runClassic } from 'eslint-vitest-rule-tester/classic'
runClassic is exported from the main entry point, no subpath.
Demonstrates the run() function with a custom rule, snapshotting output and errors.
import { run } from 'eslint-vitest-rule-tester';
import { expect } from 'vitest';
// Define a simple ESLint rule (example)
const myRule = {
meta: { fixable: 'code', messages: { noLet: 'Use const instead of let.' } },
create(context) {
return {
VariableDeclaration(node) {
if (node.kind === 'let') {
context.report({
node,
messageId: 'noLet',
fix(fixer) {
return fixer.replaceTextRange(
[node.range[0], node.range[0] + 3],
'const'
);
}
});
}
}
};
}
};
run({
name: 'no-let',
rule: myRule,
parserOptions: { ecmaVersion: 2020, sourceType: 'module' },
valid: [
'const foo = 1'
],
invalid: [
{
code: 'let foo = 1',
output(output) {
expect(output).toMatchInlineSnapshot('"const foo = 1;"');
},
errors(errors) {
expect(errors).toHaveLength(1);
expect(errors[0].messageId).toBe('noLet');
}
}
]
});
Errors
Common errors & fixes
Cannot find module 'eslint-vitest-rule-tester'
Package not installed or not in node_modules.
fixRun 'npm install -D eslint-vitest-rule-tester'.
export 'run' (imported as 'run') was not found in 'eslint-vitest-rule-tester'
Using wrong import syntax (named vs default) or typo.
fixUse 'import { run } from 'eslint-vitest-rule-tester''. RuleTester is not a constructor
Trying to instantiate RuleTester from this package; it exports functions, not classes.
fixUse 'run()' or 'createRuleTester()' instead.
Audit
Dependencies
eslintrequiredpeer dependency for rule testing
vitestrequiredpeer dependency for test runner integration