简体   繁体   中英

In what cases should you install eslint globally?

I have 3 projects each in their own repository and folder. I use sublime to do my linting from the GUI. Sometimes if I want to auto fix files I will go to the command line and run eslint. --fix eslint. --fix

My configurations are getting a bit complicated as I have had to install multiple packages for sublime, I've had to setup a configuration file in sublime for eslint, and I have had to setup the configuration file for eslint itself.

And finally, I am trying to use the babel parser instead of the default pareser but am not able to get it to work. Everything else seems to work fine.

So I am trying to make sure I understand how all these pieces work together before I troubleshoot further.

Currently I have node and nodemon installed globally. But it also makes sense to install eslint, and associated packages globally as well.

I mean in general I don't understand why you would want different projects to have different styles so I don't understand why the directions suggest you install locally for each project.

https://eslint.org/docs/user-guide/getting-started

In particular

It is also possible to install ESLint globally rather than locally (using npm install eslint --global). However, this is not recommended, and any plugins or shareable configs that you use must be installed locally in either case.

Why is this so?

Can I setup just one of my folders correctly, ie locally, and have sublime know how to line my other two folders/projects?

Seems like more complexity is added by requiring local installation of plugins. Are these directions valid and if so why are there many places doing global installs? For example here on SO .

I'm trying to make my configuration life easier not harder.

Sublime ESLint Config File

{
  "node_path": "/usr/local/bin",
  "node_modules_path": "/usr/local/lib/node_modules",
  "config_file": "/Users/c/top/ll/config/.eslintrc"
}

.eslintrc File

{
  "parserOptions": {
    "ecmaVersion": 12,
    "sourceType": "module",
    "ecmaFeatures": {
      "jsx": true
    }
  },
  "rules": {
    "semi": "error",
    "indent": ["error", 2, { "SwitchCase": 1 }],
    "eqeqeq": ["error", "always"],
    "max-depth": ["error", 5],
    "space-before-function-paren": ["error", "never"],
    "template-curly-spacing": ["error", "always"],
    "quotes": ["error", "single", { "allowTemplateLiterals": true }],
    "curly": "error",
    "brace-style": ["error", "1tbs"],
    "space-before-blocks": "error"
  }
}

ESLint is intended to be used in a project-basis. If you want to have the same configurations, you need to configure your IDE to apply your ESlint settings on all projects.

You can check for SublimeLinter and configure your ESLint settings for all your projects

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM