Skip to content
This repository has been archived by the owner on Aug 7, 2023. It is now read-only.

Error: Cannot find module 'babel-eslint' #1186

Closed
trusktr opened this issue Oct 15, 2018 · 7 comments
Closed

Error: Cannot find module 'babel-eslint' #1186

trusktr opened this issue Oct 15, 2018 · 7 comments

Comments

@trusktr
Copy link
Contributor

trusktr commented Oct 15, 2018

Re-opening #556 (it is not resolved)

@yataras said

I've fixed it with running npm install babel-eslint in ~/.atom/packages/linter-eslint/

then @Arcanemagus said

@yataras As has been stated many times in this thread, that is not the way to fix this.

Until #845 is fixed, this is the best solution. (I want linter-eslint to fallback to global eslint only when one is not found in the current project.)

I have my entire ~/.atom folder under source control, so if something breaks the brittle workaround that @yataras mentioned, I can easily revert it.

I would rather not install eslint dependencies into all of my personal projects because it is easier to install eslint dependencies in one place and for it to work everywhere.

@IanVS
Copy link
Member

IanVS commented Oct 16, 2018

It sounds like this is a duplicate of #845, perhaps? As you say, you want to be able to use global eslint in some projects, and local eslint in others. You didn't say, but implied, that you don't want to change any settings. Because currently you can still turn the Use global eslint installation setting on and off depending on what project you're in, if you're using a mix of global and local eslint installations. Just make sure to have babel-eslint installed globally as well, if your global linting settings rely upon it.

@trusktr
Copy link
Contributor Author

trusktr commented Oct 16, 2018

Yeah, that's what I meant.

I think this would be ideal:

  • Use eslint in a project if it exists. Done, no further steps.
  • If no project eslint, then if a global eslint is installed, use that.
  • If no global eslint, use the one from linter-eslint
    • I'm not sure the one from linter-eslint should ever be used anyway, because it has no config or packages like babel-eslint installed, and the latest eslint comes with zero rules, so it is useless.

This way if we want our own outside-of-projects config, we simply just install eslint and related packages globally, and edit ~/.eslintrc.js without having to worry about the Use global eslint installation checkbox.

@IanVS
Copy link
Member

IanVS commented Oct 16, 2018

Yes, I mostly agree, except that we also need to consider folks who do not want to run any linting at all in projects where there is no .eslintrc file. Right now we have the setting Disable when no ESLint config is found (in package.json or .eslintrc), but #1068 is going to change behavior slightly such that we'll also look in a user's home directory for a config file (just like eslint does).

My guess is that we will end up with a single option of "Allow fallback to global ESLint", so that your use case can be satisfied, as well as those who do not want to lint their files if the project they're in does not have its own configuration set up.

@trusktr
Copy link
Contributor Author

trusktr commented Oct 18, 2018

How about a simple GUI button? f.e., prettier has the following button to toggle it on/off (look at the bottom of the window):

screen shot 2018-10-17 at 10 14 14 pm

This is what it looks like toggled off:

screen shot 2018-10-17 at 10 14 33 pm

This way we don't have to open Atom settings, go find the package, and then find the setting in the package README.

That would be perfect I think!

  • We just install whatever we like globally for situations when a project doesn't have eslint.
  • If we don't want to lint a project that doesn't have eslint (maybe it uses other linting/formatting tools), we just turn it off at the click of a button, like Prettier's.
  • It basically just maps to the Use global eslint installation setting.

I bet the main reason this issue has come up before is because of how tedious it is to look for the setting. The button would basically solve that.

@trusktr
Copy link
Contributor Author

trusktr commented Oct 18, 2018

Also Prettier has an option to show or not show the button in the bottom status bar.

@trusktr
Copy link
Contributor Author

trusktr commented Oct 18, 2018

Maybe in linter-eslint's case, the button would have 3 modes to cycle amongst?

Ideas for the modes:

  • off mode -- no linting even if a project has eslint and eslintrc.
    • gray color, no icon
  • project-only mode -- linting only if a project has eslint(rc).
    • blue, 📖 (book-like icon of some sort)
  • global mode -- always lint, but prefer project eslint(rc) if it exists. Auto-fallback to linter-eslint's builtin eslint if the global one doesn't exist.
    • green, 🌎 (globe icon of sorts)

When global mode is turned on, IMO it should fall back to the eslint that ships with linter-eslint if a global one is not found (if it doesn't already do that).

@Arcanemagus
Copy link
Member

As you have written this issue so far, this is just a duplicate of #845.

#1068 will break this scenario for what you are asking... but that's because it will match what ESLint itself would do. I would rather follow ESLint here since the "global user config" would only be used if your current project has no configuration. If that isn't behavior that you want then you shouldn't have a global config.

Your proposed button should be brought up with the consumers of the service linter-eslint provides. We aren't in control over when lint results are requested.


Since it seems like you may not have read #845, the tl;dr of the solution for that is what you have already proposed in #1186 (comment), with the exception that the bundled version is being removed so there would only be the project local install, with a fallback to the global install if available.

@UziTech UziTech closed this as completed Mar 14, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants