README
@volvo-cars/vcc-scripts
Wraps build, test, lint and formatting tools and keeps them up to date for you.
Basic usage
yarn add @volvo-cars/vcc-scripts
Example package.json
{
"main": "lib/index.js",
"module": "es/index.js",
"files": ["lib", "es"],
"scripts": {
"build": "vcc-scripts build",
"lint": "vcc-scripts lint",
"format": "vcc-scripts format",
"test": "vcc-scripts test"
},
"devDependencies": {
"vcc-scripts": "^0.0.5"
}
}
build
Runs Babel on a package, using fields from package.json
as configuration. See vcc-scripts build --help
for more information.
- Compiles
src/
to CommonJS modules to the dirname ofpackage.json#main
. - Compiles
src/
to ES modules to the dirname ofpackage.json#module
, if it exists. - Compiles
src/
to ES modules for modern browsers to the dirname ofpackage.json#esnext
, if it exists. - Outputs TypeScript definition files to the dirname of
package.json#types
, if it exists and the package has atsconfig.json
.
@volvo-cars/babel-preset-react-app is used as the Babel configuration. You can add your own plugins with a .babelrc
file that will be merged into the default configuration, but please send a pull request to the Babel preset if your change might benefit others.
To avoid including duplicated helper functions in your compiled code, run yarn add @babel/runtime
to use the shared Babel runtime and vcc-scripts will adjust the Babel config.
Example package.json
{
"main": "lib/index.js",
"module": "es/index.js",
"esnext": "esnext/index.js",
"types": "types/index.d.ts",
"files": ["lib", "es", "esnext", "types"],
"scripts": {
"build": "vcc-scripts build",
"build:watch": "vcc-scripts build --watch"
},
"dependencies": {
"@babel/runtime": "^7.4.0"
}
}
test
Runs Jest with a default configuration. See vcc-scripts test --help
for more information.
Any additional arguments will be passed through to the Jest cli.
Commonly used setup scripts are added automatically, such as a Google Analytics global and @testing-library/jest-dom/extend-expect
. To add your own setup scripts, use the --setupFiles
or --setupFilesAfterEnv
options.
Example package.json
{
"scripts": {
"test": "vcc-scripts test --coverage --setupFiles ./testing/setup.js",
"test:watch": "vcc-scripts test --watch --setupFiles .//testing/setup.js"
}
}
lint
Runs eslint with the official Volvo Cars eslint configurations without having to install eslint or configurations separately. See vcc-scripts lint --help
for more information.
Any additional arguments will be passed through to the eslint cli.
You can add your own configuration with custom .eslintrc
files in sub-folders.
For your editor plugins to pick up the correct eslint config, create an .eslintrc.js
in the root of your project with
module.exports = require('@volvo-cars/vcc-scripts/config/eslint.js');
Example package.json
{
"scripts": {
"lint": "vcc-scripts lint",
"lint:fix": "vcc-scripts lint --fix"
}
}
format
Runs prettier with the official Volvo Cars configuration without having to install prettier or configuration separately.
For your editor to pick up the correct prettier config, create a .prettierrc
file with "@volvo-cars/prettier-config"
in your project root.
Example package.json
{
"scripts": {
"format": "vcc-scripts format",
"format:check": "vcc-scripts format --dry-run"
}
}