Skip to content

Commit

Permalink
fix(practs): bump to latest best practs
Browse files Browse the repository at this point in the history
  • Loading branch information
uladkasach committed Sep 7, 2023
1 parent a4cac62 commit ab32680
Show file tree
Hide file tree
Showing 21 changed files with 531 additions and 1,318 deletions.
3 changes: 2 additions & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ module.exports = {
sourceType: 'module', // Allows for the use of imports
},
rules: {
'@typescript-eslint/explicit-function-return-type': 'off', // this can be figured out implicitly, and that is better
'@typescript-eslint/explicit-module-boundary-types': 'error', // makes code-reviews easier + code quality better by explicitly defining outputs of exported functions+classes
'@typescript-eslint/explicit-function-return-type': 'off', // prefer '@typescript-eslint/explicit-module-boundary-types' since it only requires the check on exported functions+classes
'sort-imports': 'off',
'import/prefer-default-export': 'off', // default export = bad
'import/no-default-export': 'error', // require named exports - they make it easier to refactor, enforce consistency, and increase constraints
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/.publish-npm.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,6 @@ jobs:
run: npm run build

- name: publish
run: npm publish
run: npm publish --access public
env:
NODE_AUTH_TOKEN: ${{ secrets.npm-auth-token }}
4 changes: 4 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ on:
tags:
- v*

concurrency:
group: ${{ github.workflow }}-${{ github.ref }} # per [workflow] x [branch, tag]
cancel-in-progress: true # cancel workflows for non-latest commits

jobs:
test:
uses: ./.github/workflows/.test.yml
Expand Down
26 changes: 26 additions & 0 deletions .github/workflows/review.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: review

on:
pull_request:
types:
- opened
- edited
- synchronize

permissions:
pull-requests: read

jobs:
pullreq-title:
runs-on: ubuntu-latest
steps:
- name: test:pullreq:title
uses: amannn/action-semantic-pull-request@v5
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
# https://github.com/commitizen/conventional-commit-types
types: |
fix
feat
chore
4 changes: 4 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ on:
tags-ignore:
- v* # exclude tags, since deploy workflow triggers on tags, and calls the test workflow inside of it already

concurrency:
group: ${{ github.workflow }}-${{ github.ref }} # per [workflow] x [branch, tag]
cancel-in-progress: true # cancel workflows for non-latest commits

jobs:
suite:
uses: ./.github/workflows/.test.yml
1 change: 1 addition & 0 deletions .husky/check.commit.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
npx --no-install commitlint --edit "$1"
10 changes: 10 additions & 0 deletions .husky/check.lockfile.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/bash

# posix style fn definition; https://stackoverflow.com/a/12469057/3068233
changed () {
git diff --name-only HEAD@{1} HEAD | grep "^$1" > /dev/null 2>&1
}

if changed 'package-lock.json'; then
echo "📦 package-lock.json changed. Run npm install to update your locally installed dependencies."
fi
4 changes: 2 additions & 2 deletions .husky/commit-msg
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"
. "$(dirname -- "$0")/_/husky.sh"

npx --no-install commitlint --edit "$1"
. "$(dirname -- "$0")/check.commit.sh"
4 changes: 4 additions & 0 deletions .husky/post-checkout
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/sh
. "$(dirname -- "$0")/_/husky.sh"

. "$(dirname -- "$0")/check.lockfile.sh"
4 changes: 4 additions & 0 deletions .husky/post-merge
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/sh
. "$(dirname -- "$0")/_/husky.sh"

. "$(dirname -- "$0")/check.lockfile.sh"
4 changes: 4 additions & 0 deletions .husky/post-rewrite
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/sh
. "$(dirname -- "$0")/_/husky.sh"

. "$(dirname -- "$0")/check.lockfile.sh"
5 changes: 4 additions & 1 deletion jest.acceptance.config.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
import type { Config } from 'jest';

// ensure tests run in utc, like they will on cicd and on server; https://stackoverflow.com/a/56277249/15593329
process.env.TZ = 'UTC';

// https://jestjs.io/docs/configuration
const config: Config = {
verbose: true,
testEnvironment: 'jsdom',
testEnvironment: 'node',
moduleFileExtensions: ['js', 'ts'],
transform: {
'^.+\\.tsx?$': 'ts-jest', // https://kulshekhar.github.io/ts-jest/docs/getting-started/presets
Expand Down
5 changes: 4 additions & 1 deletion jest.integration.config.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
import type { Config } from 'jest';

// ensure tests run in utc, like they will on cicd and on server; https://stackoverflow.com/a/56277249/15593329
process.env.TZ = 'UTC';

// https://jestjs.io/docs/configuration
const config: Config = {
verbose: true,
testEnvironment: 'jsdom',
testEnvironment: 'node',
moduleFileExtensions: ['js', 'ts'],
transform: {
'^.+\\.tsx?$': 'ts-jest', // https://kulshekhar.github.io/ts-jest/docs/getting-started/presets
Expand Down
2 changes: 1 addition & 1 deletion jest.integration.env.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jest.setTimeout(90000); // since we're calling downstream apis
* - prevent executing financially impacting mutations
*/
if (
process.env.NODE_ENV !== 'test' &&
(process.env.NODE_ENV !== 'test' || process.env.STAGE) &&
process.env.I_KNOW_WHAT_IM_DOING !== 'true'
)
throw new Error(`unit-test is not targeting stage 'test'`);
3 changes: 3 additions & 0 deletions jest.unit.config.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
import type { Config } from 'jest';

// ensure tests run in utc, like they will on cicd and on server; https://stackoverflow.com/a/56277249/15593329
process.env.TZ = 'UTC';

// https://jestjs.io/docs/configuration
const config: Config = {
verbose: true,
Expand Down

0 comments on commit ab32680

Please sign in to comment.