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

initialization doesn't work in VS Code #2

Open
dwelle opened this issue Oct 9, 2018 · 3 comments
Open

initialization doesn't work in VS Code #2

dwelle opened this issue Oct 9, 2018 · 3 comments

Comments

@dwelle
Copy link

dwelle commented Oct 9, 2018

OS: win 7
VS Code Version: 1.27.2

Using Microsoft/vscode-eslint extension.

throws:

[Error - 5:35:09 PM] Error: To use eslint-plugin-rulesdir, you must load it beforehand and set the `RULES_DIR` property on the module to a string.
    at Object.get rules [as rules] (\node_modules\eslint-plugin-rulesdir\index.js:24:13)
    at Rules.importPlugin (\node_modules\eslint\lib\rules.js:97:20)
    at Plugins.define (\node_modules\eslint\lib\config\plugins.js:55:21)
    at Plugins.load (\node_modules\eslint\lib\config\plugins.js:143:18)
    at Array.forEach (<anonymous>)
    at Plugins.loadAll (\node_modules\eslint\lib\config\plugins.js:166:21)
    at loadFromDisk (\node_modules\eslint\lib\config\config-file.js:501:35)
    at Object.load (\node_modules\eslint\lib\config\config-file.js:559:20)
    at Config.getLocalConfigHierarchy (\node_modules\eslint\lib\config.js:227:44)
    at Config.getConfigHierarchy (\node_modules\eslint\lib\config.js:179:43)

root .eslintrc.js:

const rulesDirPlugin = require("eslint-plugin-rulesdir");
rulesDirPlugin.RULES_DIR = "eslint-rules";

module.exports = {
    "parser": "babel-eslint",
    "plugins": [
        "rulesdir"
    ],
    "rules": {
        "rulesdir/spaced-comment-line": [ "warn", "always" ]
    }
};

In Atom, this setup works fine.

To be honest, this is probably the extension's problem, but wanted to ensure it's not eslint-plugin-rulesdir's problem before opening an issue over there.

@dwelle
Copy link
Author

dwelle commented Oct 9, 2018

Looking at the source code, there's not much to be broken here. It seems somewhere along to way the eslint-plugin-rulesdir plugin is re-required. Not sure by whom.

Could this be solved by allowing to supply RULES_DIR some other way, e.g. as a package.json option or .eslint-plugin-rulesdir.json config? AFAIK, eslint doesn't allow pre-initialization of plugins and the plugin doesn't even know what .eslintrc file it belongs to. Other ideas?

@not-an-aardvark
Copy link
Contributor

Thanks for creating an issue. I think I've heard about people having problems with this in the past (also see: eslint/eslint#10229), although I'm not sure what the cause was. Is it possible that there are two separate versions of eslint-plugin-rulesdir present?

If you want to specify plugin info in a file, you could also use something like eslint-plugin-local-rules.

@dwelle
Copy link
Author

dwelle commented Oct 9, 2018

I've run a search across my whole drive and there's only a single eslint-plugin-rulesdir package, so the issue must be in how vscode/eslint handles it.

Either way, thanks for the eslint-plugin-local-rules suggestion --- that one works great and isn't such a bother to migrate to.

I'll leave this issue open so it's easier for other people to find.

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

2 participants