aotaduy / eslint-plugin-spellcheck

MIT License
183 stars 17 forks source link

Spellchecker and "extends" #16

Open kachkaev opened 8 years ago

kachkaev commented 8 years ago

I'm planning to to use the same eslint rules in a few projects and I would like to extract them into a separate node module (just like airbnb has done). The idea is to link to these "master" rules from each project and to have them synchronized:

cd dependent-project
npm install eslint-config-my-super-rules

dependent-project/.eslintrc:

{
  "extends": "my-super-rules"
}

I would like the spellchecker to be configured inside my-super-rules:

node_modules/eslint-config-my-super-rules/.eslintrc:

{
    "extends": "airbnb",
    "plugins": [
        "spellcheck",
    ],
    "rules": {
        "spellcheck/spell-checker": [1,
           {
               "comments": "true",
               "strings": "true",
               "identifiers": "true",
               "skipWords": [
                   "jsdoc",
                   "classdesc",
                   "enum",
                   "inheritdoc",
                   "memberof",
                   "mixin",
                   "namespace",
                   "param",
                   "readonly",
                   "todo",
                   "typedef",

                   "attr",
                   "http",
                   "https",
                   "react",
                   "..."
                ],
                "skipIfMatch": [
                    "http://[^s]*",
                    "#[A-Fa-f0-9]{6}[^a-zA-Z\\d]*$",
                    "#[A-Fa-f0-9]{3}[^a-zA-Z\\d]*$"
                ]
            }
        ]
    }
}

It seems reasonable to make all skipWords that are likely to be used in all the dependent projects a part of my-super-rules.

The problem starts when I decide to add a few more skipWords right in the project. Since "spellcheck/spell-checker" is a single rule from .eslint's point of view, the only thing I can do is to overwrite everything that was defined in node_modules/eslint-config-my-super-rules/.eslintrc. This will mean that I will have to pollute my shared .eslint with lots of rare special cases to have the plugin's config shared. The workflow for adding new project-specific words becomes complex as well: it is necessary to open another repo, modif it, change the version of eslint-config-my-super-rules, publish the package, go back to my project's repo and then npm update (this is a reasonable workflow for common words, because those change not so often and there is an additional gain in return: the result is shared).

I can't see a clear solution to this issue at the moment but I imagine the problem raising again and again as the popularity of your useful plugin grows. What would you recommend?

kachkaev commented 8 years ago

Hmm... What if the spellchecker searched for some known file in the project's root dir, just like eslint does itself with .eslintrc? I.e. no matter what's written in the config, the plugin also 'feeds' from project-dir/.eslint-spellchecker-skipwords or similar?

BTW this issue might be a special case of a wider problem, which is about using a combination of different dictionaries that either sit in different npm modules or in the project itself.

techieshark commented 6 years ago

+1:

I ran into a similar issue with two eslint config files in the same project - I wanted the plugin config found in test/.eslintrc.js to be able to extend the skipWords provided in the global config.

waynehaffenden commented 4 years ago

@kachkaev Did you ever find a solution or workaround to this?

kachkaev commented 4 years ago

👋 @waynehaffenden, I haven’t been using this plugin for years. Just using CSpell in VSCode, nothing in CI/CD.