Skip to content

Commit

Permalink
Set up code quality infrastructure
Browse files Browse the repository at this point in the history
  • Loading branch information
illright committed Dec 3, 2023
1 parent dd1a1f3 commit 0852c81
Show file tree
Hide file tree
Showing 8 changed files with 795 additions and 186 deletions.
50 changes: 50 additions & 0 deletions .github/workflows/check.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
name: Check the code

on: push

jobs:
check:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout

- name: Install Node.js
uses: actions/setup-node@v4
with:
node-version: lts/*
cache: pnpm

- name: Set up pnpm
uses: pnpm/action-setup@v2
with:
version: 8
run_install: true

- name: Get/set Prettier and ESLint cache
uses: actions/cache@v3
with:
path: |
node_modules/.cache/prettier
.eslintcache
key: ${{ runner.os }}-prettier-eslint-${{ github.sha }}
restore-keys: |
${{ runner.os }}-prettier-eslint-
- name: Try to build the library
run: pnpm run build

- name: Lint code for static errors
run: pnpm run lint

- name: Check code formatting
run: pnpm run check-formatting

- name: Type-check the code
run: pnpm run typecheck

- name: Run unit tests
run: pnpm run test

- name: Run integration tests
run: pnpm run test-integration
4 changes: 4 additions & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"

npx lint-staged
2 changes: 2 additions & 0 deletions .lintstagedrc.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
"*": "prettier --write --log-level warn --ignore-unknown --cache"
"*.ts": "eslint --cache --fix"
1 change: 1 addition & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
pnpm-lock.yaml
dist
node_modules
.tsup
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,13 @@ test("basic functionality in a JavaScript project", async () => {
{ cwd: temporaryDirectory },
);
await execa("node", [fsd, "f", "auth", "-r", "src"], { cwd: project });
await execa("node", [fsd, "entities", "client", "-s", "api,ui", "--root", "src"], {
cwd: project,
});
await execa(
"node",
[fsd, "entities", "client", "-s", "api,ui", "--root", "src"],
{
cwd: project,
},
);
await execa("node", [fsd, "pages", "login"], {
cwd: project,
});
Expand All @@ -36,5 +40,7 @@ test("basic functionality in a JavaScript project", async () => {
await expect(
fs.stat(join(project, "src/entities/client/ui")),
).resolves.toBeTruthy();
await expect(fs.stat(join(project, "src/pages/login/index.js"))).resolves.toBeTruthy();
await expect(
fs.stat(join(project, "src/pages/login/index.js")),
).resolves.toBeTruthy();
});
File renamed without changes.
29 changes: 17 additions & 12 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,29 +9,34 @@
"prepublishOnly": "npm run build",
"lint": "eslint --cache .",
"format": "prettier --write . --cache",
"test": "vitest src",
"test-integration": "vitest integration"
"check-formatting": "prettier --check . --cache",
"typecheck": "tsc --noEmit",
"test": "vitest run src",
"test-integration": "vitest run integration-tests",
"prepare": "husky install"
},
"dependencies": {
"commander": "^11.1.0",
"enquirer": "^2.4.1",
"simple-git": "^3.20.0"
"simple-git": "^3.21.0"
},
"devDependencies": {
"@tsconfig/recommended": "^1.0.3",
"@types/mock-fs": "^4.13.3",
"@types/node": "^20.8.5",
"@typescript-eslint/eslint-plugin": "^6.7.4",
"@typescript-eslint/parser": "^6.7.4",
"@types/mock-fs": "^4.13.4",
"@types/node": "^20.10.2",
"@typescript-eslint/eslint-plugin": "^6.13.1",
"@typescript-eslint/parser": "^6.13.1",
"chalk": "^5.3.0",
"eslint": "^8.50.0",
"eslint-config-prettier": "^9.0.0",
"eslint": "^8.55.0",
"eslint-config-prettier": "^9.1.0",
"execa": "^8.0.1",
"get-bin-path": "^11.0.0",
"husky": "^8.0.0",
"lint-staged": "^15.1.0",
"mock-fs": "^5.2.0",
"prettier": "^3.0.3",
"tsup": "^7.2.0",
"typescript": "^5.2.2",
"prettier": "^3.1.0",
"tsup": "^8.0.1",
"typescript": "^5.3.2",
"vitest": "^0.34.6"
},
"bin": {
Expand Down
Loading

0 comments on commit 0852c81

Please sign in to comment.