Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Spellchecker and "extends" #16

Open
kachkaev opened this issue Jun 8, 2016 · 4 comments
Open

Spellchecker and "extends" #16

kachkaev opened this issue Jun 8, 2016 · 4 comments

Comments

@kachkaev
Copy link

kachkaev commented Jun 8, 2016

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
Copy link
Author

kachkaev commented Jun 8, 2016

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
Copy link

+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
Copy link

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

@kachkaev
Copy link
Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants