Sign Up for Free

RunKit +

Try any Node.js package right in your browser

This is a playground to test code. It runs a full Node.js environment and already has all of npm’s 400,000 packages pre-installed, including eslint-config-rule-tester with all npm packages installed. Try it out:

var eslintConfigRuleTester = require("eslint-config-rule-tester")

This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.

eslint-config-rule-tester v0.1.0

A tester for ESLint config files, similar to ESLint's Rule Tester for custom plugins

eslint-config-rule-tester (ConfigTester)

ESLint has a great utility for testing custom rules called RuleTester. However, RuleTester requires a Rule object, such as the one in this source file.

If you want to test a configuration file itself (especially more complex configurations, such as no-restricted-syntax), ESLint's RuleTester won't work very well, since you're not creating new rule files, just using ESLint's core rules. ConfigTester allows you to test a specific rule from your config file.

Get Started

ConfigTester takes in a ruleName (a string to be used when printing to the console), a configFile (a normal ESLint JavaScript config file), and a testFile, which has valid and invalid tests.

To isolate a certain rule for testing, make sure the configFile you pass in only contains the rule that you are testing under rules.

The testFile should look like this:

module.exports = {
  valid: [
    "a === b",
  invalid: [
      code: "if (x == 42) { }",
      errors: ["Expected '===' and instead saw '=='."]

You can iterate over your config file to test each rule in isolation.

Please see eslint-config-jessie to see ConfigTester in full use.


RunKit is a free, in-browser JavaScript dev environment for prototyping Node.js code, with every npm package installed. Sign up to share your code.
Sign Up for Free