eslint-plugin-storybook
eslint-plugin-storybook copied to clipboard
Add rule to prevent adding argType annotations matching actions.argTypesRegex
When the user specifies a value for actions.argTypesRegex such as this one (copy/pasted from the actions addon documentation):
// .storybook/preview.js
export const parameters = {
actions: { argTypesRegex: '^on.*' }
}
then there is no need to also specify actions matching the regular expression:
// MyButton.stories.js
export default {
title: 'Button',
component: Button,
argTypes: {
onClick: { action: 'onClick' } // unnecessary because it matches `argTypesRegex`
}
};
What about adding a rule to detect and fix such cases?
Should the rule contain a configuration argument to flag/ignore an action whose name doesn't match the parameter name such as in:
// MyButton.stories.js
export default {
title: 'Button',
component: Button,
argTypes: {
onClick: { action: 'clicked' } // clicked ≠onClick
}
};