[SOLVED] How to set up a global `~/.eslintrc.js` for use in Atom?


#1

Does anyone know how to set up a global ~/.eslintrc.js for use in Atom?

I am wondering, where do I install things like babel-parser, eslint-config-prettier, typescript-eslint-parser, and all other packages that will be used by eslintrc?

My ~/.eslintrc.js file is minimal right now:

module.exports = {
  parserOptions: {
    sourceType: "module",
    ecmaVersion: 2018,
    ecmaFeatures: {
      jsx: true,
      impliedStrict: true
    }
  },

  overrides: [
    {
      files: ["**/*/.ts", "**/*.tsx"],
      parser: "typescript-eslint-parser"
    }
  ]
};

When I open a .js file from anywhere in the filesystem, I see syntax errors now (as expected). But when I open a .ts file, nothing seems to happen, not even errors from linter-eslint. Just nothing.

I’ve installed typescript-eslint-parser globally.

Any ideas why it is not working?


#2

Okay, I’m getting somewhere. I tried changing my config to

module.exports = {
  extends: ["prettier"],
  parser: "babel-eslint",
}

then when I open up a .js file, I see an error that Cannot find module 'babel-eslint'. But I have installed babel-eslint globally.

Where do I need to install babel-eslint?

I am trying to avoid having to install stuff in every project, I want to have a default eslint experience opening any file regardless which project it is in (for personal projects where I have the same code style in all of them).

Any ideas?


#3

Alright, I needed to install the plugins, etc, inside ~/.atom/packages/linter-eslint so that things would work. I version control my whole ~/.atom folder, so if this brittle workaround breaks, I can revert and fix it.

[SOLVED]