Merge pull request #411 from mirumee/add/strict-null-check-errors-snapshots
Snapshot strict null mode error count
This commit is contained in:
commit
779a9b6505
3 changed files with 31 additions and 0 deletions
1
.travis/check-strict-null-errors.snapshot
Normal file
1
.travis/check-strict-null-errors.snapshot
Normal file
|
@ -0,0 +1 @@
|
||||||
|
2829
|
|
@ -189,6 +189,7 @@
|
||||||
"extract-messages": "npm run extract-json-messages && npm run transpile-messages",
|
"extract-messages": "npm run extract-json-messages && npm run transpile-messages",
|
||||||
"build-types": "apollo client:codegen --target=typescript types --globalTypesFile=src/types/globalTypes.ts",
|
"build-types": "apollo client:codegen --target=typescript types --globalTypesFile=src/types/globalTypes.ts",
|
||||||
"check-types": "tsc --noEmit",
|
"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",
|
"generate-component": "plop --plopfile .plop/plopfile.js",
|
||||||
"start": "webpack-dev-server --open -d",
|
"start": "webpack-dev-server --open -d",
|
||||||
"storybook": "start-storybook -p 3000 -c src/storybook/",
|
"storybook": "start-storybook -p 3000 -c src/storybook/",
|
||||||
|
|
29
scripts/count-strict-null-check-errors.js
Normal file
29
scripts/count-strict-null-check-errors.js
Normal 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);
|
||||||
|
}
|
||||||
|
});
|
Loading…
Reference in a new issue