aotaduy / eslint-plugin-spellcheck

MIT License
183 stars 17 forks source link

How to ignore color codes like #efefef (error looks like "You have a misspelled word: efefef on String") #92

Open ivan-code-care opened 1 year ago

rafael-graunke commented 1 year ago

I think you can skip this by using regex in the "skipIfMatch" directive. Follow the ".eslintrc" example on README:

"plugins": [
   "spellcheck"
],
"rules": {
   "spellcheck/spell-checker": [1,
       {
           "comments": true,
           "strings": true,
           "identifiers": true,
           "templates": true,
           "lang": "en_US",
           "skipWords": [
               "dict",
               "aff",
               "hunspellchecker",
               "hunspell",
               "utils"
           ],
           "skipIfMatch": [
               "http://[^s]*",
               "^[-\\w]+\/[-\\w\\.]+$",
               "^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$" //This regex will match hex color, upper or lowercase, 3 or 6 digits.
           ],
           "skipWordIfMatch": [
               "^foobar.*$"
           ],
           "minLength": 3
        }
    ]
}