Add prettier

This commit is contained in:
Rene Saarsoo 2020-09-17 22:50:12 +03:00
parent ae31567cbf
commit 08e8f781d6
3 changed files with 11 additions and 3 deletions

View File

@ -4,10 +4,12 @@
"license": "GPL-3.0-or-later", "license": "GPL-3.0-or-later",
"scripts": { "scripts": {
"lint:ts": "tsc --no-emit", "lint:ts": "tsc --no-emit",
"test": "ts-node src/index.ts examples/threshold-pushing.txt" "test": "ts-node src/index.ts examples/threshold-pushing.txt",
"format:js": "prettier --write src/"
}, },
"devDependencies": { "devDependencies": {
"@types/node": "^14.10.3", "@types/node": "^14.10.3",
"prettier": "^2.1.2",
"ts-node": "^9.0.0", "ts-node": "^9.0.0",
"typescript": "^4.0.2" "typescript": "^4.0.2"
} }

View File

@ -13,7 +13,7 @@ const parseDefinition = (line: string): Def | undefined => {
return { return {
type: matches[1], type: matches[1],
text: matches[2], text: matches[2],
} };
}; };
const isDefined = <T>(x: T | undefined): x is T => Boolean(x); const isDefined = <T>(x: T | undefined): x is T => Boolean(x);
@ -24,7 +24,8 @@ console.log(`Parsing: ${filename}`);
const file = fs.readFileSync(filename, "utf8"); const file = fs.readFileSync(filename, "utf8");
file.split(/\n/) file
.split(/\n/)
.map(parseDefinition) .map(parseDefinition)
.filter(isDefined) .filter(isDefined)
.forEach((def) => console.log(def.type)); .forEach((def) => console.log(def.type));

View File

@ -27,6 +27,11 @@ make-error@^1.1.1:
resolved "https://registry.yarnpkg.com/make-error/-/make-error-1.3.6.tgz#2eb2e37ea9b67c4891f684a1394799af484cf7a2" resolved "https://registry.yarnpkg.com/make-error/-/make-error-1.3.6.tgz#2eb2e37ea9b67c4891f684a1394799af484cf7a2"
integrity sha512-s8UhlNe7vPKomQhC1qFelMokr/Sc3AgNbso3n74mVPA5LTZwkB9NlXf4XPamLxJE8h0gh73rM94xvwRT2CVInw== integrity sha512-s8UhlNe7vPKomQhC1qFelMokr/Sc3AgNbso3n74mVPA5LTZwkB9NlXf4XPamLxJE8h0gh73rM94xvwRT2CVInw==
prettier@^2.1.2:
version "2.1.2"
resolved "https://registry.yarnpkg.com/prettier/-/prettier-2.1.2.tgz#3050700dae2e4c8b67c4c3f666cdb8af405e1ce5"
integrity sha512-16c7K+x4qVlJg9rEbXl7HEGmQyZlG4R9AgP+oHKRMsMsuk8s+ATStlf1NpDqyBI1HpVyfjLOeMhH2LvuNvV5Vg==
source-map-support@^0.5.17: source-map-support@^0.5.17:
version "0.5.19" version "0.5.19"
resolved "https://registry.yarnpkg.com/source-map-support/-/source-map-support-0.5.19.tgz#a98b62f86dcaf4f67399648c085291ab9e8fed61" resolved "https://registry.yarnpkg.com/source-map-support/-/source-map-support-0.5.19.tgz#a98b62f86dcaf4f67399648c085291ab9e8fed61"