Coder Social home page Coder Social logo

tooling's Introduction

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-lint

Verifies 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-lint

Verifies the correctness of all JSON schemas.

  • Definitions and properties need to a description in the correct format.
  • Only allowed properties are used.
  • $ref must be the only property when provided.
  • tsType is needed when instanceof is used.
  • type: "string" is needed when absolutePath is used.
  • additionalProperties is needed when properties are used.
--schemas ./schemas/**/*.json

Glob to the schemas that should be processed.

compile-to-definitions

node node_modules/tooling/compile-to-definitions

Generates 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.

precompile-schemas

node node_modules/tooling/precompile-schemas

Generate .check.js files next to the JSON schemas. They export a single function which returned a boolean whether the object is validate according to the schema. This function doesn't do error handling, so run a real schema validation when it returns false.

It will also generate a .check.d.ts file with type declarations.

--schemas ./schemas/**/*.json

Glob to the schemas that should be processed.

---declarations declarations

Folder of the generated declaration files.

inherit-types

node node_modules/tooling/inherit-types

Synchronize 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-header

Ensures 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-schemas

Sort JSON schema according to convention.

--schemas ./schemas/**/*.json

Glob to the schemas that should be processed.

generate-types

node node_modules/tooling/generate-types

Generate 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.

When a declarations/index.d.ts file exists, types from this are also exposed.

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-types

Generates 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.

tooling's People

Contributors

alexander-akait avatar commanderroot avatar connormiha avatar nschonni avatar snitin315 avatar sokra avatar thelarkinn avatar vankop avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.