eslint-plugin-material-ui-unused-classes
eslint-plugin-material-ui-unused-classes copied to clipboard
Not working for classes imported from file
Classes which are imported from a file (usually styles.js in the same component directory) are not being checked:
import useStyles from "./styles";
...
const classes = useStyles();
The plugin seems like to assume that the classes are defined in the same file.
I have debugged the plugin and did a workaround by first saving all usedClasses to a file and loading them then in the next run to check if they include the definedClassKey. But therefore I had to add the filename as prefix for each class with context.getFilename()
because many classes have the same name in different files.
It would be great to let it work also with classes imported from a file.
Another issue I had was, that all classes were marked as unused which is wrong, but in the console only unused classes were listed. Maybe it is in relation with that issue above.
Thanks
Hi Ömer, thanks for checking out the plugin! I'm not an eslint expert, but afaik checking a file besides the active one isn't really possible unfortunately.