xoux
xoux

Reputation: 3494

How do I get my projects to use a global .eslintrc file by default?

I use atom text editor. Here are the steps I took to get my linter working with React and ES6:

I don't want to have to create the .eslintrc everytime I start coding a new project. I want to use the global .eslintrc file, which I found when I:

How can I make it so that when I fire up a new file and start coding I already get the options defined in this global file?

In particular, this is the setup I am using in individual projects:

{
  "parserOptions": {
    "ecmaFeatures": {
      "jsx": true
    },
    "sourceType": "module"
  },
  "env": {
    "es6": true
  },
  "plugins": [
    "eslint-plugin-react"
  ]
}

And I want this to be the default.

Upvotes: 11

Views: 10790

Answers (2)

Fab313
Fab313

Reputation: 2288

You could use the configuration cascading to your advantage : http://eslint.org/docs/user-guide/configuring#configuration-cascading-and-hierarchy

workspace
     |
     |_ .eslintrc (global, root = true)
     |
     |_ project-1
           |       
           |_ .eslintrc (project specific, if you need to overwrite some rules)


From the eslint documentation:

enter image description here

Upvotes: 2

Matthew Schuchard
Matthew Schuchard

Reputation: 28854

Go to settings --> packages --> linter-eslint settings. On that menu, look for the .eslintrc Path option. For your particular preference, you would put ~/.atom/packages/linter/.eslintrc in that field. Your .eslintrc is now being used globally across all of your projects.

Upvotes: 4

Related Questions