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

Usage

  1. 1.
    Add the dependency:
1
yarn add --dev eslint-plugin-tss-unused-classes
Copied!
  1. 1.
    Enable it in you ESLint config
Case 1: You are in a create-react-app project: Edit your package.json:
1
{
2
//...
3
"eslintConfig": {
4
"plugins": [
5
//...
6
"tss-unused-classes"
7
],
8
"rules": {
9
"tss-unused-classes/unused-classes": "warn"
10
}
11
},
12
//...
13
}
Copied!
​Example projet​
Case 2: You have installed ESLint manually: Edit your .eslintrc.js file:
1
module.exports = {
2
// ...
3
plugins: [
4
// ...
5
'tss-unused-classes'
6
],
7
rules: {
8
// ...
9
'tss-unused-classes/unused-classes': 'warn'
10
}
11
}
Copied!
​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