Create-react-app: Move Babel and ESLint configuration into package.json after ejecting

Created on 26 Sep 2016  路  15Comments  路  Source: facebook/create-react-app

Update: claimed by @montogeek

Currently we emit .babelrc and .eslintrc after ejecting.
This is better than embedding them in Webpack config like before, but still not ideal.

I think we should embed Babel and ESLint configuration into package.json after ejecting.
We already do this for Jest.

Relevant settings in package.json are called babel and eslintConfig.

This issue is up for grabs. If you鈥檇 like to work on it please comment below so that multiple people don鈥檛 work on the same thing. Please respect it if somebody has already commented, and don鈥檛 try to submit a PR before them.

Most helpful comment

Less dotfiles FTW in my opinion. It's getting out of hand have a dotfile for all the things.

Seems to make more sense to have all the configuration live in a single spot with key value pairs rather than distributing the concern to all these different dotfiles.

All 15 comments

Why not ask for it?

Example:
Do you want to export .babelrc and .eslintrc config files? (Y/n)

What鈥檚 the benefit to separate files as opposed to package.json?

I like to have each library configuration on its respective config file

Less dotfiles FTW in my opinion. It's getting out of hand have a dotfile for all the things.

Seems to make more sense to have all the configuration live in a single spot with key value pairs rather than distributing the concern to all these different dotfiles.

I like to have each library configuration on its respective config file

You can always move it, it鈥檚 literally four lines:

  babel: {
    presets: ['react-app']
  },
  eslintConfig: {
    extends: 'react-app'
  }

I think this is a better default but once you eject, you can do anything you like.

Yeah - and especially because CRA is targeted towards beginners, I can't tell you how much email I get from people who lose their dotfiles because no OS shows hidden files by default.

Ok, agree, can I do it? :D

Go for it @montogeek!

I'm not sure if this is a good idea. I understand hidden files can be confusing beginners, but maybe the solution is not moving parts of the config to package.json, but teaching beginners to work with dotfiles.

Dotfiles are still going to be the solution for any platform independent configuration files that are supposed to also work in non-JS projects where package.json is not available, for example: .env, .gitignore, .editorconfig or .graphqlrc. Every developer will be exposed to these sooner than later, so I feel trying to hide them from the users instead of teaching might be just passing the buck.

Those are system level dotfiles though, and that makes sense. Seems like for package specific ones it can eliminate confusion by keeping that configuration altogether? (no strong opinion here, just thoughts) :)

I meant the project specific .env, .gitignore, .editorconfig or .graphqlrc etc. files. Ejecting a CRA project already creates a .gitignore and we support .env for specifying environment variables.

Anyway, I don't feel strongly about this either, and can't come up with reasons why config in package.json would be any _worse_ than separate files. So why not. 馃槄

You project鈥檚 build won鈥檛 break if you miss .gitignore or .editorconfig. I see the point about .graphqlrc and .env but both are more advanced use cases. Making just the common case more bulletproof is better than doing nothing IMO.

Agreed, you convinced me. 馃憤

And unlike GraphQL or environment variables, Jest, ESLint and Babel are all JS specific things, so package.json also kind of makes sense for them.

We already do this for Jest.

I'm glad that my decision to not make yet another dotfile for jest is getting some traction :)

Was this page helpful?
0 / 5 - 0 ratings

Related issues

alleroux picture alleroux  路  3Comments

ap13p picture ap13p  路  3Comments

adrice727 picture adrice727  路  3Comments

oltsa picture oltsa  路  3Comments

Evan-GK picture Evan-GK  路  3Comments