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

better-regex rule not found #583

Closed
brettz9 opened this issue Mar 8, 2020 · 4 comments
Closed

better-regex rule not found #583

brettz9 opened this issue Mar 8, 2020 · 4 comments

Comments

@brettz9
Copy link
Contributor

brettz9 commented Mar 8, 2020

Apologies if this ends up being more of a tooling issue, but as it impacts a new unicorn rule, I thought I'd bring it up in case it is due to some config.

After updating to Unicorn 17.0.0, when I use my IDE (Atom) with the linter-eslint package, I am getting an error in my linter, even after IDE restart, that "Definition for rule 'unicorn/better-regex' was not found. (unicorn/better-regex)". Yet when I run my eslint script for the same repository, there are no complaints. I see it is indeed version 17 in node_modules, and I see the file for better-regex and index.js pointing to it.

I have global eslint disabled in the IDE setting (and uninstalled my global copy just to be safe), so I really find it puzzling why it says the rule wasn't found.

Even more puzzling--I get the error about the rule when checking a file in one repo and not in another (where both use the rule).

Getting it even when paring down to just:

module.exports = {
  "extends": [
    "plugin:unicorn/recommended"
  ],
  "plugins": [
    "promise"
  ],
  "rules": {
    "unicorn/better-regex": ["error"]
  }
};

or

module.exports = {
  "plugins": [
    "unicorn",
    "promise"
  ],
  "rules": {
    "unicorn/better-regex": ["error"]
  }
};

Adding "root": true` does not help either.

If I switch to unicorn/regex-shorthand, it works.

Any thoughts of what this could be?

@yakov116
Copy link
Contributor

yakov116 commented Mar 8, 2020

https://github.com/sindresorhus/eslint-plugin-unicorn/releases

Breaking
Rename regex-shorthand rule to better-regex (#522) a5e5405

@brettz9
Copy link
Contributor Author

brettz9 commented Mar 8, 2020

Yes, thanks, but I'm trying with that new rule,better-regex. I just mentioned the regex-shorthand to contrast that it is working while better-regex is not. Despite my having updated to the version which should have better-regex and appears to.

@brettz9
Copy link
Contributor Author

brettz9 commented Mar 8, 2020

Still getting this after #584 / v17.0.1 upgrade (and Atom restart)...

@brettz9
Copy link
Contributor Author

brettz9 commented Mar 9, 2020

Figured it out... My home directory had an older copy of unicorn. The IDE's algorithm (FWIW, in getRelativePath of linter-eslint/src/worker-helpers.js) to set a base path was to look for an .eslintignore, and in this case, as I didn't have one in that project, it looked in the home directory and finding one there, it set that HOME path to be the cwd. Adding an .eslintignore to my project worked around the issue for me (and yes, I do want to have linting info at HOME). Sorry for the noise! Thanks!

(FWIW: Filed as AtomLinter/linter-eslint#1338 )

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