Registry / testing / eslint-plugin-tss-unused-classes

eslint-plugin-tss-unused-classes

JSON →
library1.0.3jsnpmunverified

An ESLint plugin that detects unused styling classes created with tss-react (the CSS-in-JS library for Material-UI). Current stable version is 1.0.3. The plugin is actively maintained by the tss-react author. It works by analyzing calls to makeStyles and checking if returned class names are referenced in JSX. Unlike general unused class linters, this one is tightly integrated with tss-react's API, reducing false positives. It has no runtime dependencies and supports ESLint 7/8/9.

npm install eslint-plugin-tss-unused-classes
INSTALL
IMPORT
SIG · ESLINT-PLUGIN-TSS-
E
eslint-plugin-tss-unused-classes
testingjavascriptv1.0.3
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

plugin
// In .eslintrc.js: plugins: ['tss-unused-classes'], rules: { 'tss-unused-classes/unused-classes': 'warn' }
// Do not import as a module in JS; it's an ESLint plugin
This is an ESLint plugin, not a module. Configure via eslint config.
unused-classes rule
'tss-unused-classes/unused-classes': 'warn'
'tss-unused-classes': 'warn'
The rule is namespaced under the plugin name; prefix with 'tss-unused-classes/'.
// eslint-disable-next-line
// eslint-disable-next-line tss-unused-classes/unused-classes
// eslint-disable-next-line unused-classes
Disable comments must use the full rule name with plugin prefix.

Setup and example of detecting unused tss-react classes with ESLint.

// 1. Install: yarn add --dev eslint-plugin-tss-unused-classes // 2. Configure .eslintrc.js: module.exports = { plugins: ['tss-unused-classes'], rules: { 'tss-unused-classes/unused-classes': 'warn' } }; // 3. In a React component using tss-react: import { makeStyles } from 'tss-react/mui'; const useStyles = makeStyles()((theme) => ({ root: { color: 'red' }, unusedRoot: { color: 'blue' } })); export function MyComponent() { const { classes } = useStyles(); // Want to use classes.root but forgot? Plugin will warn about classes.unusedRoot return <div className={classes.root}>Hello</div>; }
Debug
Known issues
gotchaThe plugin only works with the object syntax of makeStyles (not with the callback returning CSSProperties directly if used without object wrapper).
fix
Ensure makeStyles()() call returns an object with class names as keys.
affects: >=0.0.1
gotchaFalse positives may occur if classes are used via string interpolation or dynamic access (e.g., classes[`${name}`]).
fix
Disable the rule on that line with eslint-disable-next-line comment.
affects: >=0.0.1
deprecatedESLint 7 is no longer supported as of version 1.0.0; check your ESLint version.
fix
Upgrade to ESLint 8 or 9.
affects: >=1.0.0
breakingv1.0.0 dropped support for ESLint 6 and below, and changed rule prefix from @tss-unused-classes to tss-unused-classes.
fix
Update eslint config to use 'tss-unused-classes' instead of '@tss-unused-classes'.
affects: >=1.0.0
Errors
Common errors & fixes
ESLint: Rule 'tss-unused-classes/unused-classes' was not found.
Plugin not installed or not listed in plugins array.
fix
Run 'yarn add --dev eslint-plugin-tss-unused-classes' and add 'tss-unused-classes' to plugins array in .eslintrc.
Parsing error: The keyword 'import' is reserved
ESLint is not configured for ES modules.
fix
Set 'sourceType': 'module' in parserOptions, or use a babel parser for JSX.
Warning: Rule 'tss-unused-classes/unused-classes' has been deprecated (note: not actually deprecated, but may appear if using old config format).
Using legacy format with @ prefix in older versions.
fix
Use 'tss-unused-classes/unused-classes' without @.
Upgrade
Version history
1.0.3latest on npm
Audit
Dependencies
eslintrequiredpeer dependency, plugin runs within ESLint
Agent activity
4 hits · last 30 days
node
4
Resources
eslint-plugin-tss-unused-classes — npm install eslint-plugin-tss-unused-classes · libregistry