Created
February 14, 2023 09:40
-
-
Save donaldpipowitch/f54c88d157ee243b3481f06f92330d34 to your computer and use it in GitHub Desktop.
ESLint rule which disallows importing "@storybook/jest" (it shall not be used inside "./tests")
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// @ts-check | |
/** @type {import("eslint").Rule.RuleModule} */ | |
const rule = { | |
meta: { | |
docs: { | |
description: '"@storybook/jest" should not be used inside "./tests".', | |
}, | |
}, | |
create(context) { | |
return { | |
ImportDeclaration(node) { | |
if (node.source.value === '@storybook/jest') { | |
context.report({ | |
node, | |
message: | |
'"@storybook/jest" should not be used inside "./tests". `expect` and other Jest functions are available globally here.', | |
}); | |
} | |
}, | |
}; | |
}, | |
}; | |
module.exports = rule; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment