Skip to content

Instantly share code, notes, and snippets.

@donaldpipowitch
Created February 14, 2023 09:40
Show Gist options
  • Save donaldpipowitch/f54c88d157ee243b3481f06f92330d34 to your computer and use it in GitHub Desktop.
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")
// @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