saleor-dashboard/lint/rules/named-styles.js

27 lines
666 B
JavaScript
Raw Normal View History

module.exports = {
create: context => ({
CallExpression: (codePath, node) => {
if (
["makeStyles", "withStyles"].includes(codePath.callee.name) &&
codePath.arguments.length < 2
) {
context.report({
loc: codePath.callee.loc,
messageId:
codePath.callee.name === "makeStyles"
? "expectedNameHook"
: "expectedNameHoc",
node
});
}
}
}),
meta: {
messages: {
expectedNameHoc: 'withStyles hook should have "name" property.',
expectedNameHook: 'makeStyles hook should have "name" property.'
},
type: "problem"
}
};