tooling
A collection of reusable tooling for webpack repos
Setup
Add this repo as dev dependency:
"devDependencies": {
"tooling": "webpack/tooling"
}The lockfile will take care pinning the version.
Run yarn upgrade tooling to upgrade the to latest version.
Add two scripts to the package.json:
"scripts": {
"special-lint": "...",
"special-lint-fix": "..."
}Add all tooling that should be used to these scripts (concatenated with &&). In the special-lint-fix version pass --write to all tooling.
Example:
"scripts": {
"special-lint": "node node_modules/tooling/compile-to-definitions",
"special-lint-fix": "node node_modules/tooling/compile-to-definitions --write"
}Common arguments
By default all tooling checks if affected files are up-to-date, so it can be added as linting step in CI.
Use --write to switch to updating mode.
In this mode affected files are updated to the fixed version when possible.
By default all tooling will operate in the root directory of the calling project.
Use --root some/dir to operate in a different directory.
Some tooling displays more information when --verbose is used.
Most tooling uses prettier to format generated files, so a prettier config is needed and prettier need to be installed.
lockfile-lint
node node_modules/tooling/lockfile-lintVerifies the correctness of a yarn lockfile. Makes sure that all dependencies are provided from npm (e. g. not github dependencies). This is important as some users might not be able to access github.
yarn.lock must be present in root directory.
schemas-lint
node node_modules/tooling/schemas-lintVerifies the correctness of all JSON schemas.
- Definitions and properties need to a
descriptionin the correct format. - Only allowed properties are used.
$refmust be the only property when provided.tsTypeis needed wheninstanceofis used.type: "string"is needed whenabsolutePathis used.additionalPropertiesis needed whenpropertiesare used.
--schemas ./schemas/**/*.json
Glob to the schemas that should be processed.
compile-to-definitions
node node_modules/tooling/compile-to-definitionsGenerates typescript declaration files from JSON schemas.
--schemas ./schemas/**/*.json
Glob to the schemas that should be processed.
---declarations declarations
Output folder of the generated declaration files.
inherit-types
node node_modules/tooling/inherit-typesSynchronize jsdoc method annotations in classes with jsdoc of the same method in base class.
This copies jsdoc one to one from base class, but omits @abstract.
tsconfig.json must be present in root directory and typescript must be installed.
format-file-header
node node_modules/tooling/format-file-headerEnsures that the starting of all source files follows the following convention:
/*
MIT License http://www.opensource.org/licenses/mit-license.php
Author ...
*/
"use strict";
const Import = require("./Import");
const SortedAlphabetically = require("./SortedAlphabetically");
/** @typedef {import("../TypeImport")} TypeImport */
/** @typedef {import("../SortedAlphabetically")} SortedAlphabetically */--source ./lib/**/*.js
Glob to the source that should be processed.
format-schemas
node node_modules/tooling/format-schemasSort JSON schema according to convention.
--schemas ./schemas/**/*.json
Glob to the schemas that should be processed.
generate-types
node node_modules/tooling/generate-typesGenerate typescript types declarations file (types.d.ts) from the visible types in the exposed main (package.json) entry file.
This declaration file should be used as types in package.json.
tsconfig.types.json must be present in root directory and typescript must be installed.
--types types.d.ts
Path of the generated declarations file.
type-coverage
node node_modules/tooling/generate-typesGenerates type coverage raw coverage data in the coverage directory.
instanbul report can be used to generate a readable report.
tsconfig.json must be present in root directory and typescript must be installed.