Skip to content

Latest commit

 

History

History
144 lines (100 loc) · 3.1 KB

README.md

File metadata and controls

144 lines (100 loc) · 3.1 KB

EthereumJS - Monorepo and Shared Config

This folder contains documentation on monorepo setup and configuration as well as shared configuration settings and scripts for common modules (like a shared tsconfig.json TypeScript configuration file or cli/coverage.sh script).

The cli scripts (./config/cli) are used in the child packages' package.json to ease repetitive script use.

Dependencies

Shared config devDependencies across all packages can go in the root package.json. However, if a package needs access to the dependency's bin (e.g. eslint or nyc) then it must be defined in the child packages' package.json.

Linting

Common linting configuration utilizing:

Exposed CLI commands:

  • ./config/cli/lint.sh
  • ./config/cli/lint-fix.sh

Usage

Add .eslintrc.js:

module.exports = {
  extends: '../../config/eslint.js',
}

In this file you can add rule adjustments or overrides for the specific package.

Add prettier.config.js:

module.exports = require('../../config/prettier.config')

Use CLI commands above in your package.json:

  "scripts": {
    "lint": "../../config/cli/lint.sh",
    "lint:fix": "../../config/cli/lint-fix.sh",
  }

Getting the most out of linting

This lint package is used as git pre-push hook on with the help of Husky.

Coverage

Tool: nyc

Exposed CLI command:

  • ./config/cli/coverage.sh

Usage

Add .nycrc:

{
  "extends": "../../config/.c8rc.json"
}

Use script above in package.json:

  "scripts": {
    "coverage": "../../config/cli/coverage.sh"
  }

TypeScript

Tool: TypeScript

Exposed CLI commands:

  • ./config/cli/ts-build.sh
  • ./config/cli/ts-compile.sh

Usage

The three files below compose the functionality built into ts-build.sh and ts-compile.sh. Note that the build is browser compatible with ES2020 target. Add tsconfig.json:

{
  "extends": "../../config/tsconfig.json",
  "include": ["src/**/*.ts", "test/**/*.ts"]
}

Add tsconfig.prod.json:

{
  "extends": "../../config/tsconfig.prod.json",
  "include": ["src/**/*.ts"],
  "compilerOptions": {
    "outDir": "./dist"
  }
}

Note: the outDir property is mandatory to generate assets to a directory.

Use CLI commands above in your package.json:

  "scripts": {
    "tsc":   "../../config/cli/ts-compile.sh",
    "build": "../../config/cli/ts-build.sh"
  }

Documentation

Add typedoc.js to a package that extends the generic TypeDoc configuration:

module.exports = {
  extends: '../../config/typedoc.js',
  // Additional directives
}