Install and configure ESLint, Prettier, lint-staged and Husky with one command
The main problem is that if you're creating a new project you have to configure all of that and spend some time that you could spent
procrastinating actually writing the code. It's not as complicated as, say, Webpack configuration, but it's still something that could be automated.
That's where autoslap comes in. All you have to do is run
autoslap it in your project's main directory... and that's it. It also works with existing projects: ones that were just created (e.g. using
create-react-app), ones with already existing tooling (e.g. only
prettier) and ones which don't even have a package.json yet. autoslap installs these packages and adds a basic config to your package.json, which you can tweak anytime.
If you're installing both
eslint-config-prettier will also be installed and configured.
In the near future you'll also be able to save a profile with your own preferred config for each of these tools.
npm install -g autoslap
yarn global add autoslap
After installing the package, go to the main directory of your project and run
autoslap. This should be enough in 99% of the cases. If your project was just initialized and has no dependencies, you might want to run it with flag
--yarn to make sure it's installed with yarn instead of npm. By default, autoslap checks if you have a
yarn.lock file in your directory - if so, it will use yarn, otherwise it will use npm.
You can also disable installing some tools by using flags
autoslap --no-eslint will not install or configure anything related to ESLint. All available options can be checked out by running
- Saving own config(s)
- Handling external config files (.prettierrc etc.)
- Should it configure tools if they're installed but not configured?
- Typescript support in ESLint (before you ask: I'm not planning supporting TSLint) - should it be even handled at all?
- Automatic Prettier exclusions based on installed plugins (maybe includes the point above?)
You might be wondering why this package is named that way. It's an acronym for "automatic staged linting and prettyfying". Expanded name doesn't really make much sense, but autoslap sounds catchy to me. You can also think about it as a slap to the ugly code in your repo, you won't be seeing it again. And the slap will be fully automated!
Paweł Dąbrowski © 2019