Skip to content

Commit

Permalink
feat: implemented check:types script to ensure TS types correctness
Browse files Browse the repository at this point in the history
  • Loading branch information
Ayzrian committed Jan 23, 2025
1 parent f4fb63d commit 726d7ff
Show file tree
Hide file tree
Showing 7 changed files with 108 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: Check Types

on:
pull_request:
branches: [ master ]

jobs:
run_linter:

runs-on: ubuntu-latest

strategy:
matrix:
node-version: [20.x]

steps:
- uses: actions/checkout@v2
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}
- run: npm install
- run: npm run check:types
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: Check Types

on:
pull_request:
branches: [ master ]

jobs:
run_linter:

runs-on: ubuntu-latest

strategy:
matrix:
node-version: [20.x]

steps:
- uses: actions/checkout@v2
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}
- run: npm install
- run: npm run check:types
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: Check Types

on:
pull_request:
branches: [ master ]

jobs:
run_linter:

runs-on: ubuntu-latest

strategy:
matrix:
node-version: [20.x]

steps:
- uses: actions/checkout@v2
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}
- run: npm install
- run: npm run check:types
1 change: 1 addition & 0 deletions mate-scripts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"lint": "eslint ./src",
"test": "echo \"Error: no test specified\" && exit 1",
"build": "rm -rf ./bin && rollup -c && node ./shebangify.js && chmod +x ./bin/mateScripts.js",
"build:windows": "rollup -c && node ./shebangify.js",
"prepublishOnly": "npm run build",
"postpublish": "rm -rf ./bin",
"patch": "npm version patch && npm publish",
Expand Down
31 changes: 31 additions & 0 deletions mate-scripts/src/commands/CheckTypes.command.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import { Command } from './Command';
import {execBashCodeSilent} from "../tools";

Check failure on line 2 in mate-scripts/src/commands/CheckTypes.command.ts

View workflow job for this annotation

GitHub Actions / lintTest (16.x)

A space is required after '{'

Check failure on line 2 in mate-scripts/src/commands/CheckTypes.command.ts

View workflow job for this annotation

GitHub Actions / lintTest (16.x)

A space is required before '}'

Check failure on line 2 in mate-scripts/src/commands/CheckTypes.command.ts

View workflow job for this annotation

GitHub Actions / lintTest (16.x)

Strings must use singlequote

export type CheckTypesOptions = Record<string, unknown>;

export class CheckTypesCommand extends Command {
protected common(): void {
// do nothing
}

protected reactTypescript = (options: CheckTypesOptions) => {

Check failure on line 11 in mate-scripts/src/commands/CheckTypes.command.ts

View workflow job for this annotation

GitHub Actions / lintTest (16.x)

'options' is defined but never used
this.checkTypes();
};


Check failure on line 15 in mate-scripts/src/commands/CheckTypes.command.ts

View workflow job for this annotation

GitHub Actions / lintTest (16.x)

More than 1 blank line not allowed
protected vueTypescript = (options: CheckTypesOptions) => {

Check failure on line 16 in mate-scripts/src/commands/CheckTypes.command.ts

View workflow job for this annotation

GitHub Actions / lintTest (16.x)

'options' is defined but never used
this.checkTypes();
};


Check failure on line 20 in mate-scripts/src/commands/CheckTypes.command.ts

View workflow job for this annotation

GitHub Actions / lintTest (16.x)

More than 1 blank line not allowed
protected typescript = (options: CheckTypesOptions) => {

Check failure on line 21 in mate-scripts/src/commands/CheckTypes.command.ts

View workflow job for this annotation

GitHub Actions / lintTest (16.x)

'options' is defined but never used
this.checkTypes();
};

private checkTypes() {
execBashCodeSilent(
`${this.binDir}tsc --no-emit`,
);
}

Check failure on line 29 in mate-scripts/src/commands/CheckTypes.command.ts

View workflow job for this annotation

GitHub Actions / lintTest (16.x)

Block must not be padded by blank lines

}
1 change: 1 addition & 0 deletions mate-scripts/src/commands/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ export * from './Build.command';
export * from './Deploy.command';
export * from './Update.command';
export * from './Migrate.command';
export * from './CheckTypes.command';
6 changes: 6 additions & 0 deletions mate-scripts/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {
TestCommand,
UpdateCommand,
MigrateCommand,
CheckTypesCommand,
} from './commands';
import {
deployController,
Expand Down Expand Up @@ -50,6 +51,11 @@ program
.description('lint html, css and js files')
.action(commandFactory.make(LintCommand, lintController));

program
.command('check:types')
.description('validates TS types')
.action(commandFactory.make(CheckTypesCommand));

program
.command('test')
.option('-n, --not-open', 'should open test report in browser', false)
Expand Down

0 comments on commit 726d7ff

Please sign in to comment.