0.0.6 • Published 5 years ago

@dbchn/js-scripts v0.0.6

Weekly downloads
1
License
MIT
Repository
github
Last release
5 years ago

Table of Contents

What's this?

This is a CLI to abstract away all configuration, linting and testing. This makes tooling easier to maintain accross different projects and hopefully drastically reduces setup time of new projects. Forked from

This is a fork

This is a fork of kcd-scripts which in turn is inspired by react-scripts. The intent is for this to start growing and involving on it's own though while giving a fast start to the project – hence the rebranding.

Installation

yarn add @dbchn/js-scripts

Usage

This is a CLI and exposes a bin called js-scripts.

Run them using npx js-scripts {SCRIPT_NAME_HERE}.

Read them and understand them in node_modules/@dbchn/js-scripts/src/config/.

The following scripts are available.

bootstrap

This bootstraps the project and adds config files to your project root which reference the configs in js-scripts so IDEs etc. can find your settings as well.

build

This script uses babel to build your files to a dist directory. Make sure to check node_modules/@dbchn/js-scripts/src/config/ for the exact config.

format

This script uses prettir to format your files and saves them. Make sure to check node_modules/@dbchn/js-scripts/src/config/ for the exact config.

lint

This script uses eslint to lint your files. Make sure to check node_modules/@dbchn/js-scripts/src/config/ for the exact config.

precommit

This script is executed before evey commit. For now it only lints staged code. Make sure to check node_modules/@dbchn/js-scripts/src/config/ for the exact config

If you use husky make sure to add it to your package.json.

"husky": {
  "hooks": {
    "pre-commit": "node src pre-commit"
  }
}

test

This script uses jest to test your files. Make sure to check node_modules/@dbchn/js-scripts/src/config/ for the exact config.

This project actually dogfoods itself. If you look in the package.json, you'll find scripts with node src {scriptName}. This serves as an example of some of the things you can do with jss-scripts.

Overriding Config

Unlike react-scripts, js-scripts allows you to specify your own configuration for things and have that plug directly into the way things work with js-scripts. There are various ways that it works, but basically if you want to have your own config for something, just add the configuration and js-scripts will use that instead of it's own internal config. In addition, js-scripts exposes its configuration so you can use it and override only the parts of the config you need to.

This can be a very helpful way to make editor integration work for tools like ESLint which require project-based ESLint configuration to be present to work.

To automatically generate config files referencing the js-scripts config run the bootstrap script npx js-scripts bootstrap;

Were you to do this for manually for ie. ESLint, you could create an .eslintrc with the contents of:

{"extends": "./node_modules/js-scripts/eslint.js"}

Or, for jest:

const { jest: jestConfig } = require('js-scripts/config');
module.exports = Object.assign(jestConfig, {
  // your overrides here
});

Maintainers & Contributors

Dennis Bochen

LICENSE

MIT