Merge pull request #411 from mirumee/add/strict-null-check-errors-snapshots

Snapshot strict null mode error count
This commit is contained in:
Dominik Żegleń 2020-02-25 15:38:02 +01:00 committed by GitHub
commit 779a9b6505
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 31 additions and 0 deletions

View file

@ -0,0 +1 @@
2829

View file

@ -189,6 +189,7 @@
"extract-messages": "npm run extract-json-messages && npm run transpile-messages",
"build-types": "apollo client:codegen --target=typescript types --globalTypesFile=src/types/globalTypes.ts",
"check-types": "tsc --noEmit",
"check-strict-null-errors": "tsc --noEmit --strictNullChecks | node scripts/count-strict-null-check-errors.js",
"generate-component": "plop --plopfile .plop/plopfile.js",
"start": "webpack-dev-server --open -d",
"storybook": "start-storybook -p 3000 -c src/storybook/",

View file

@ -0,0 +1,29 @@
/* eslint-disable @typescript-eslint/no-var-requires */
/* eslint-disable no-console */
const fs = require("fs");
const readline = require("readline");
const updateSnapshot = process.argv.includes("-u");
const snapshotPath = ".travis/check-strict-null-errors.snapshot";
const shouldCount = /^src/;
let errors = 0;
const rl = readline.createInterface({
input: process.stdin,
output: process.stdout,
terminal: false
});
rl.on("line", line => {
if (shouldCount.test(line)) {
errors++;
}
});
rl.on("close", () => {
if (updateSnapshot) {
fs.writeFileSync(snapshotPath, errors);
} else {
console.log(errors);
}
});