eslint-plugin-mui-unused-classes
Advanced tools
Comparing version 2.0.0 to 2.0.1
{ | ||
"name": "eslint-plugin-mui-unused-classes", | ||
"version": "2.0.0", | ||
"version": "2.0.1", | ||
"description": "eslint plugin to detect unused material-ui styling classes", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -57,2 +57,7 @@ function getBasicIdentifier(node) { | ||
}); | ||
} else if ( | ||
body.type === 'CallExpression' && | ||
body.callee.name === 'createStyles' && | ||
body.arguments[0].type === 'ObjectExpression') { | ||
stylesObj = body.arguments[0] | ||
} | ||
@@ -59,0 +64,0 @@ |
35
test.js
@@ -60,2 +60,16 @@ | ||
}`, | ||
// valid createStyles case | ||
`const useStyles = makeStyles(theme => | ||
createStyles({ | ||
usedClass: { | ||
backgroundColor: 'hotpink', | ||
}, | ||
}), | ||
); | ||
export const Component = () => { | ||
const classes = useStyles(); | ||
return <div className={classes.usedClass}>test</div>; | ||
};` | ||
], | ||
@@ -131,4 +145,25 @@ invalid: [ | ||
}] | ||
}, | ||
// invalid case using createStyles | ||
{ | ||
code: ` | ||
const useStyles = makeStyles(theme => | ||
createStyles({ | ||
testClass: { | ||
backgroundColor: 'red', | ||
}, | ||
usedClass: { | ||
backgroundColor: 'hotpink', | ||
}, | ||
}), | ||
); | ||
export const Component = () => { | ||
const classes = useStyles(); | ||
return <div className={classes.usedClass}>test</div>; | ||
};`, | ||
errors: [{ message: 'Class `testClass` is unused'}] | ||
} | ||
], | ||
}); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
44686
8
324