-
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
kick off the project **Intentions:** - π - Initial commit
- Loading branch information
0 parents
commit 978de47
Showing
19 changed files
with
8,021 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
{ | ||
"env": { | ||
"es2021": true, | ||
"node": true | ||
}, | ||
"extends": [ | ||
"standard", | ||
"plugin:typescript-sort-keys/recommended", | ||
"prettier" | ||
], | ||
"parser": "@typescript-eslint/parser", | ||
"parserOptions": { | ||
"ecmaFeatures": { | ||
"jsx": true | ||
}, | ||
"ecmaVersion": "latest", | ||
"sourceType": "module" | ||
}, | ||
"plugins": [ | ||
"@typescript-eslint", | ||
"unused-imports", | ||
"typescript-sort-keys", | ||
"prefer-arrow", | ||
"prettier", | ||
"sort-class-members" | ||
], | ||
"rules": { | ||
"indent": "off", | ||
"space-before-function-paren": "off", | ||
"no-unused-vars": "off", | ||
"unused-imports/no-unused-imports": "error", | ||
"unused-imports/no-unused-vars": [ | ||
"warn", | ||
{ | ||
"vars": "all", | ||
"varsIgnorePattern": "^_", | ||
"args": "after-used", | ||
"argsIgnorePattern": "^_" | ||
} | ||
], | ||
"prettier/prettier": "error", | ||
"import/extensions": "off", | ||
"import/no-extraneous-dependencies": "off", | ||
"import/no-unresolved": "off", | ||
"import/prefer-default-export": "off", | ||
"typescript-sort-keys/interface": "error", | ||
"typescript-sort-keys/string-enum": "error", | ||
"prefer-arrow/prefer-arrow-functions": [ | ||
"error", | ||
{ | ||
"disallowPrototype": true, | ||
"singleReturnOnly": true, | ||
"classPropertiesAllowed": false | ||
} | ||
], | ||
"sort-class-members/sort-class-members": [ | ||
"error", | ||
{ | ||
"order": [ | ||
"[static-properties]", | ||
"[properties]", | ||
"[conventional-private-properties]", | ||
"constructor", | ||
"[static-methods]", | ||
"[methods]", | ||
"[conventional-private-methods]" | ||
], | ||
"accessorPairPositioning": "getThenSet" | ||
} | ||
] | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
ko_fi: linesofcodedev | ||
custom: ['https://www.paypal.me/TimMikeladze'] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
name: Main CI workflow | ||
|
||
on: [push] | ||
|
||
jobs: | ||
run-ci: | ||
name: Run Type Check & Linters | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v3 | ||
|
||
- name: Set up Node | ||
uses: actions/setup-node@v3 | ||
with: | ||
node-version: 18 | ||
cache: 'yarn' | ||
|
||
- name: Install dependencies | ||
run: yarn install --frozen-lockfile | ||
|
||
- name: Build | ||
run: yarn build | ||
|
||
- name: Check types | ||
run: yarn type-check | ||
|
||
- name: Check linting | ||
run: yarn lint | ||
|
||
- name: Test | ||
run: yarn test:ci |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
node_modules | ||
dist | ||
.idea | ||
yarn-error.log | ||
coverage | ||
.env | ||
.tsc-baseline.json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
yarn lint-staged |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
save-exact = true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
dist | ||
coverage | ||
*.lock | ||
*.snap | ||
.prettierignore | ||
.env.template | ||
.gitignore | ||
.husky/** | ||
.npmrc |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"semi": false, | ||
"singleQuote": true, | ||
"trailingComma": "none" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
The MIT License (MIT) | ||
|
||
Copyright (c) 2023 Tim Mikeladze | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import { GitEmoji } from 'commit-it' | ||
|
||
export default { | ||
plugins: [ | ||
new GitEmoji({ | ||
askForShortDescription: false, | ||
commitBodyRequired: false | ||
}) | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
{ | ||
"name": "tsc-baseline", | ||
"version": "0.0.0", | ||
"description": "Save a baseline of TypeScript errors and compare new errors against it. Useful for type-safe feature development in TypeScript projects that have a lot of errors. This tool will filter out errors that are already in the baseline and only show new errors.", | ||
"author": "Tim Mikeladze <tim.mikeladze@gmail.com>", | ||
"keywords": [ | ||
"tsc", | ||
"errors", | ||
"typescript", | ||
"tsc errors", | ||
"baseline", | ||
"tsc baseline", | ||
"typescript baseline" | ||
], | ||
"repository": { | ||
"type": "git", | ||
"url": "git@github.com:TimMikeladze/tsc-baseline.git" | ||
}, | ||
"license": "MIT", | ||
"files": [ | ||
"./dist" | ||
], | ||
"source": "src/index.ts", | ||
"types": "dist/index.d.ts", | ||
"type": "module", | ||
"exports": { | ||
"require": "./dist/index.cjs", | ||
"default": "./dist/index.modern.js" | ||
}, | ||
"main": "./dist/index.cjs", | ||
"module": "./dist/index.module.js", | ||
"unpkg": "./dist/index.umd.js", | ||
"bin": "./dist/cli.module.js", | ||
"scripts": { | ||
"dev": "microbundle watch src/{index,cli}.ts -f esm", | ||
"build": "yarn link:self && rm -rf dist && microbundle src/{index,cli}.ts && yalc publish", | ||
"lint": "eslint --fix \"src/**/*.+(ts|tsx|js|jsx)\" && prettier --write .", | ||
"test": "vitest --passWithNoTests", | ||
"test:ci": "vitest run --coverage --passWithNoTests", | ||
"type-check": "tsc", | ||
"release": "release-it", | ||
"commit": "commit-it", | ||
"cli": "yarn build -f modern && node dist/cli.modern.js", | ||
"link:self": "yalc link && yarn link" | ||
}, | ||
"release-it": { | ||
"git": { | ||
"commitMessage": "π | v${version}" | ||
}, | ||
"github": { | ||
"release": true | ||
}, | ||
"npm": { | ||
"publish": false | ||
} | ||
}, | ||
"lint-staged": { | ||
"**/*.{ts,js,jsx,tsx}": "eslint --fix", | ||
"*": "prettier --write" | ||
}, | ||
"husky": { | ||
"hooks": { | ||
"pre-commit": "lint-staged" | ||
} | ||
}, | ||
"devDependencies": { | ||
"@types/node": "20.4.5", | ||
"@types/object-hash": "3.0.3", | ||
"@typescript-eslint/eslint-plugin": "6.2.0", | ||
"@typescript-eslint/parser": "6.2.0", | ||
"@vitest/coverage-v8": "0.33.0", | ||
"commit-it": "0.0.11", | ||
"eslint": "8.46.0", | ||
"eslint-config-prettier": "8.9.0", | ||
"eslint-config-standard": "17.1.0", | ||
"eslint-plugin-import": "2.28.0", | ||
"eslint-plugin-n": "16.0.1", | ||
"eslint-plugin-node": "11.1.0", | ||
"eslint-plugin-prefer-arrow": "1.2.3", | ||
"eslint-plugin-prettier": "5.0.0", | ||
"eslint-plugin-promise": "6.1.1", | ||
"eslint-plugin-sort-class-members": "1.18.0", | ||
"eslint-plugin-typescript-sort-keys": "2.3.0", | ||
"eslint-plugin-unused-imports": "3.0.0", | ||
"husky": "8.0.3", | ||
"lint-staged": "13.2.3", | ||
"microbundle": "0.15.1", | ||
"prettier": "3.0.0", | ||
"release-it": "16.1.3", | ||
"typescript": "5.1.6", | ||
"vitest": "0.33.0", | ||
"yalc": "1.0.0-pre.53" | ||
}, | ||
"dependencies": { | ||
"commander": "11.0.0", | ||
"object-hash": "3.0.0" | ||
}, | ||
"resolutions": { | ||
"semver": ">=6.3.1" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
{ | ||
"extends": ["config:base"], | ||
"stabilityDays": 3, | ||
"timezone": "America/Los_Angeles", | ||
"schedule": ["on the first day of the month"], | ||
"packageRules": [ | ||
{ | ||
"matchPackagePatterns": ["*"], | ||
"matchUpdateTypes": ["minor", "patch"], | ||
"groupName": "all non-major dependencies", | ||
"groupSlug": "all-minor-patch" | ||
} | ||
], | ||
"ignoreDeps": [] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
#!/usr/bin/env node | ||
|
||
import { Command } from 'commander' | ||
import { | ||
getNewErrors, | ||
parseTypeScriptErrors, | ||
readTypeScriptErrorsFromFile, | ||
toHumanReadableText, | ||
writeTypeScriptErrorsToFile | ||
} from './util' | ||
import { resolve } from 'path' | ||
import { rmSync } from 'fs' | ||
;(async () => { | ||
const program = new Command() | ||
|
||
program | ||
.name('tsc-baseline') | ||
.description( | ||
'Save a baseline of TypeScript errors and compare new errors against it.Useful for type-safe feature development in TypeScript projects that have a lot of errors. This tool will filter out errors that are already in the baseline and only show new errors.' | ||
) | ||
|
||
let stdin = '' | ||
|
||
program.option( | ||
'-p --path <path>', | ||
`Path to file to save baseline errors to. Defaults to .tsc-baseline.json` | ||
) | ||
|
||
const getConfig = () => { | ||
const config = program.opts() | ||
return { | ||
path: resolve(process.cwd(), config.path || '.tsc-baseline.json') | ||
} | ||
} | ||
|
||
program.command('save [message]').action((message) => { | ||
if (stdin) { | ||
message = stdin | ||
if (message) { | ||
const config = getConfig() | ||
writeTypeScriptErrorsToFile(parseTypeScriptErrors(message), config.path) | ||
console.log("\nSaved baseline errors to '" + config.path + "'") | ||
} | ||
} | ||
}) | ||
|
||
program.command('check [message]').action((message) => { | ||
if (stdin) { | ||
message = stdin | ||
if (message) { | ||
const config = getConfig() | ||
const oldErrors = readTypeScriptErrorsFromFile(config.path) | ||
const newErrors = getNewErrors( | ||
oldErrors, | ||
parseTypeScriptErrors(message) | ||
) | ||
const newErrorsCount = | ||
newErrors.size === 0 | ||
? '0 errors found' | ||
: `${newErrors.size} error${newErrors.size > 1 ? 's' : ''} found` | ||
|
||
console.error(` | ||
${toHumanReadableText(newErrors)} | ||
${newErrorsCount}. ${oldErrors.size} error${ | ||
oldErrors.size > 1 ? 's' : '' | ||
} already in baseline.`) | ||
} | ||
} | ||
}) | ||
|
||
program.command('clear').action(() => { | ||
const config = getConfig() | ||
rmSync(config.path) | ||
console.log("Removed baseline file '" + config.path + "'") | ||
}) | ||
|
||
if (process.stdin.isTTY) { | ||
program.parse(process.argv) | ||
} else { | ||
process.stdin.on('readable', function () { | ||
// @ts-ignore | ||
const chunk = this.read() | ||
if (chunk !== null) { | ||
stdin += chunk | ||
} | ||
}) | ||
process.stdin.on('end', function () { | ||
program.parse(process.argv) | ||
}) | ||
} | ||
|
||
try { | ||
await program.parseAsync(process.argv) | ||
} catch (err: any) { | ||
console.error(err.message) | ||
} | ||
})() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from './util' |
Oops, something went wrong.