🧹
Detecting unused classes
There is an ESLint plugin that detects unused classes:

Usage

  1. 1.
    Add the dependency:
yarn add --dev eslint-plugin-tss-unused-classes
  1. 1.
    Enable it in you ESLint config
Case 1: You are in a create-react-app project: Edit your package.json:
{
//...
"eslintConfig": {
"plugins": [
//...
"tss-unused-classes"
],
"rules": {
"tss-unused-classes/unused-classes": "warn"
}
},
//...
}
​Example projet​
Case 2: You have installed ESLint manually: Edit your .eslintrc.js file:
module.exports = {
// ...
plugins: [
// ...
'tss-unused-classes'
],
rules: {
// ...
'tss-unused-classes/unused-classes': 'warn'
}
}
​Example project​

Disabling warnings

In case of false positive, disabling the warning:
  • For a line: // eslint-disable-next-line tss-unused-classes/unused-classes
  • For the entire file: // eslint-disable-next-line tss-unused-classes/unused-classes
Copy link
Edit on GitHub
On this page
Usage
Disabling warnings