Callum Macrae

Counting eslint-disabled occurrences in your JavaScript

You're probably familiar with the following:

// eslint-disable-next-line no-console
console.log('totally should not be doing this');

Using eslint-disable, eslint-disable-line, and eslint-disable-next-line, you can disable specific eslint rules for certain lines or sections of your code.

But how much are you actually doing it?

Use this command to find out:

Here's the command as text:

grep -r 'eslint-disable' -h ./src |    # Find all lines containing "eslint-disable"
    sed -E 's/^.*\/[*/] | \*\/|,//g' | # Remove whitespace and brackets
    tr ' ' '\n' |                      # Put every word on own line
    grep -v 'eslint' |                 # Remove every line containing "eslint"
    sort |                             # Sort rules so the same rule is grouped together
    uniq -c |                          # Count number of occurances of each rule
    sort -bgr                          # Sort by number of occurances from greatest to lowest

And again on one line:

grep -r 'eslint-disable' -h ./src | sed -E 's/^.*\/[*/] | \*\/|,//g' | tr ' ' '\n' | grep -v 'eslint' | sort | uniq -c | sort -bgr

« Return to home