Skip to content

testCaseNonStaticCode

Test case code should be a static string literal.

✅ This rule is included in the flint logical presets.

Test case code values should be static string literals ('', "", or ` `). Dynamically generating test cases with variables, function calls, template interpolations, or spreads can make individual test cases harder to tweak, encourage catch-all tests, and make the tests difficult to statically analyze.

const code = "a";
ruleTester.describe(rule, {
valid: [code],
invalid: [],
});
ruleTester.describe(rule, {
valid: [{ code: getCode() }],
invalid: [],
});
ruleTester.describe(rule, {
valid: [{ code: `a${b}` }],
invalid: [],
});
ruleTester.describe(rule, {
valid: [{ ...baseCase }],
invalid: [],
});

This rule is not configurable.

Made with ❤️‍🔥 around the world by the Flint team and contributors.