A tester for ESLint config files, similar to ESLint's Rule Tester for custom plugins
npm install eslint-config-rule-testerIf 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.
ConfigTester takes in a ruleName (a string to be used when printing
to the console), a configObj (a configuration in the form of a
JavaScript object), and a testFile, which
has valid and invalid tests.
To isolate a certain rule for testing, make sure the configObj you pass in only contains the rule that you are testing under rules.
The testFile should look like this:
``js``
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.