Skip to content

Commit 30e406b

Browse files
Merge pull request #54 from shiftcode/#53-basic-ts-guards
#53 basic ts guards
2 parents e84d150 + 4763c67 commit 30e406b

33 files changed

+272
-62
lines changed

.github/workflows/main.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,9 @@ jobs:
9393
# build lint plugins before linting
9494
- name: Build lint plugins
9595
run: npm run build:lint:ci
96+
# check formatting
97+
- name: Check Formatting
98+
run: npm run format:ci
9699
# lint
97100
- name: Lint
98101
run: npm run lint:ci

package-lock.json

Lines changed: 10 additions & 10 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,10 @@
1111
"scripts": {
1212
"build:ci": "lerna run build",
1313
"build:lint:ci": "lerna run build:lint:ci",
14+
"format": "lerna run format",
15+
"format:ci": "lerna run format:ci",
1416
"lint:ci": "lerna run lint:ci",
1517
"prepare": "husky",
16-
"prettier": "lerna run prettier",
1718
"publish-libs": "node packages/publish-helper/dist/publish-lib",
1819
"test:ci": "lerna run test:ci"
1920
},

packages/branch-utilities/.lintstagedrc.yml

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
1-
# we use eslint instead of ng lint, because we can't use --project (tsconfig specifying files with include, exclude)
2-
# and --files argument pointing to other files
3-
src/{**/,}*.ts,test/{**/,}*.ts:
4-
- npm run prettier:staged
1+
# Reformat all .ts / .js
2+
"**/*.(t|j)s":
3+
- npm run format:staged
54
- npm run lint:staged
65

76
# sort package.json keys

packages/branch-utilities/package.json

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@shiftcode/branch-utilities",
3-
"version": "5.0.0",
3+
"version": "5.0.1-pr53.1",
44
"description": "Utilities for local and ci to get branch name and stage",
55
"repository": "https://github.com/shiftcode/sc-commons-public",
66
"license": "MIT",
@@ -16,13 +16,15 @@
1616
"scripts": {
1717
"prebuild": "rm -rf ./dist",
1818
"build": "tsc",
19+
"format": "npm run format:base -- --write",
20+
"format:base": "prettier --config ../../.prettierrc.yml '{src,e2e,test}/**/*.ts'",
21+
"format:ci": "npm run format:base -- --check",
22+
"format:staged": "prettier --write --config ../../.prettierrc.yml",
1923
"lint": "npm run lint:src:fix",
2024
"lint:ci": "npm run lint:src",
2125
"lint:src": "eslint ./src",
2226
"lint:src:fix": "eslint ./src --cache --fix",
2327
"lint:staged": "eslint --fix --cache",
24-
"prettier": "prettier --write --config ../../.prettierrc.yml '{src,e2e,test}/**/*.ts'",
25-
"prettier:staged": "prettier --write --config ../../.prettierrc.yml",
2628
"prepublish": "node ../publish-helper/dist/prepare-dist.js",
2729
"test": "NODE_OPTIONS=\"--experimental-vm-modules --trace-warnings\" npx jest --config jest.config.js",
2830
"test:ci": "npm run test",

packages/branch-utilities/src/lib/base.utils.spec.ts

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -81,9 +81,10 @@ describe('base utils', () => {
8181
})
8282

8383
describe('parseBranchName', () => {
84-
8584
test('works when valid pattern', () => {
86-
expect(parseBranchName('#7-abc')).toEqual({ branchId: 7, branchName: 'abc' } satisfies ReturnType<typeof parseBranchName>)
85+
expect(parseBranchName('#7-abc')).toEqual({ branchId: 7, branchName: 'abc' } satisfies ReturnType<
86+
typeof parseBranchName
87+
>)
8788

8889
expect(parseBranchName('#72-abc').branchId).toBe(72)
8990
expect(parseBranchName('#000-int').branchId).toBe(0)
@@ -94,8 +95,12 @@ describe('base utils', () => {
9495
})
9596

9697
test('works for github copilot created branches', () => {
97-
expect(parseBranchName('copilot/fix-123')).toEqual({ branchId: 123, branchName: 'fix' } satisfies ReturnType<typeof parseBranchName>)
98-
expect(parseBranchName('copilot/feat-123')).toEqual({ branchId: 123, branchName: 'feat' } satisfies ReturnType<typeof parseBranchName>)
98+
expect(parseBranchName('copilot/fix-123')).toEqual({ branchId: 123, branchName: 'fix' } satisfies ReturnType<
99+
typeof parseBranchName
100+
>)
101+
expect(parseBranchName('copilot/feat-123')).toEqual({ branchId: 123, branchName: 'feat' } satisfies ReturnType<
102+
typeof parseBranchName
103+
>)
99104
})
100105

101106
test('throws when invalid pattern', () => {

packages/branch-utilities/src/lib/base.utils.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -90,9 +90,11 @@ export function getBranchInfo(env: unknown, branchName?: string): BranchInfo {
9090
}
9191

9292
export function isFullBranchOverrideDefined(envVars: unknown): envVars is CustomScOverrideEnv {
93-
return envVars !== null
94-
&& typeof (envVars as CustomScOverrideEnv).SC_OVERRIDE_BRANCH_NAME ==='string'
95-
&& typeof (envVars as CustomScOverrideEnv).SC_OVERRIDE_IS_PR ==='string'
93+
return (
94+
envVars !== null &&
95+
typeof (envVars as CustomScOverrideEnv).SC_OVERRIDE_BRANCH_NAME === 'string' &&
96+
typeof (envVars as CustomScOverrideEnv).SC_OVERRIDE_IS_PR === 'string'
97+
)
9698
}
9799

98100
export function getBranchNameOverride(env: CustomScOverrideEnv): string {

packages/eslint-config-recommended/.lintstagedrc.yml

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
1-
# we use eslint instead of ng lint, because we can't use --project (tsconfig specifying files with include, exclude)
2-
# and --files argument pointing to other files
3-
src/{**/,}*.ts,test/{**/,}*.ts:
4-
- npm run prettier:staged
1+
# Reformat all .ts / .js
2+
"**/*.(t|j)s":
3+
- npm run format:staged
54
- npm run lint:staged
65

76
# sort package.json keys

packages/eslint-config-recommended/package.json

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@shiftcode/eslint-config-recommended",
3-
"version": "5.0.0",
3+
"version": "5.0.1-pr53.1",
44
"description": "default shiftcode config for eslint",
55
"repository": "https://github.com/shiftcode/sc-commons-public",
66
"license": "UNLICENSED",
@@ -24,19 +24,21 @@
2424
"prebuild": "rm -rf ./dist",
2525
"build": "tsc",
2626
"build:lint:ci": "npm run build",
27+
"format": "npm run format:base -- --write",
28+
"format:base": "prettier --config ../../.prettierrc.yml '{src,e2e,test}/**/*.ts'",
29+
"format:ci": "npm run format:base -- --check",
30+
"format:staged": "prettier --write --config ../../.prettierrc.yml",
2731
"lint": "npm run lint:src:fix",
2832
"lint:ci": "npm run lint:src",
2933
"lint:src": "eslint ./src",
3034
"lint:src:fix": "eslint ./src --cache --fix",
3135
"lint:staged": "eslint --fix --cache",
32-
"prettier": "prettier --write --config ../../.prettierrc.yml '{src,e2e,test}/**/*.ts'",
33-
"prettier:staged": "prettier --write --config ../../.prettierrc.yml",
3436
"prepublish": "node ../publish-helper/dist/prepare-dist.js",
3537
"test": "echo 'Error: no test specificed'",
3638
"test:ci": "npm run test"
3739
},
3840
"dependencies": {
39-
"@shiftcode/eslint-plugin-rules": "^4.0.0",
41+
"@shiftcode/eslint-plugin-rules": "^4.0.1-pr53.1",
4042
"@typescript-eslint/eslint-plugin": "^8.18.0",
4143
"@typescript-eslint/parser": "^8.18.0",
4244
"eslint": "^8.56.0",

packages/eslint-plugin-rules/.lintstagedrc.yml

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
1-
# we use eslint instead of ng lint, because we can't use --project (tsconfig specifying files with include, exclude)
2-
# and --files argument pointing to other files
3-
src/{**/,}*.ts,test/{**/,}*.ts:
4-
- npm run prettier:staged
1+
# Reformat all .ts / .js
2+
"**/*.(t|j)s":
3+
- npm run format:staged
54
- npm run lint:staged
65

76
# sort package.json keys

0 commit comments

Comments
 (0)