Skip to content

Commit 88a6f20

Browse files
committed
chore: enable lint and CI
1 parent 01580a7 commit 88a6f20

30 files changed

+174
-85
lines changed

.eslintignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
**/dist/**

.eslintrc.json

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
{
2+
"root": true,
3+
"parser": "@typescript-eslint/parser",
4+
"parserOptions": {
5+
"ecmaVersion": 6,
6+
"sourceType": "module"
7+
},
8+
"plugins": ["@typescript-eslint"],
9+
"extends": [
10+
"eslint:recommended",
11+
"plugin:@typescript-eslint/eslint-recommended",
12+
"plugin:@typescript-eslint/recommended"
13+
],
14+
"rules": {
15+
"@typescript-eslint/no-unused-vars": [
16+
"error",
17+
{ "varsIgnorePattern": "^_", "argsIgnorePattern": "^_" }
18+
],
19+
"@typescript-eslint/no-explicit-any": "off",
20+
"@typescript-eslint/ban-ts-comment": "off"
21+
}
22+
}

.github/workflows/build-test.yml

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
name: CI
2+
3+
on:
4+
pull_request:
5+
branches:
6+
- main
7+
- dev
8+
9+
permissions:
10+
contents: read
11+
12+
jobs:
13+
build-test:
14+
runs-on: buildjet-8vcpu-ubuntu-2204
15+
16+
services:
17+
postgres:
18+
image: postgres
19+
env:
20+
POSTGRES_PASSWORD: abc123
21+
# Set health checks to wait until postgres has started
22+
options: >-
23+
--health-cmd pg_isready
24+
--health-interval 10s
25+
--health-timeout 5s
26+
--health-retries 5
27+
ports:
28+
- 5432:5432
29+
30+
strategy:
31+
matrix:
32+
node-version: [20.x]
33+
34+
steps:
35+
- name: Checkout
36+
uses: actions/checkout@v3
37+
38+
- name: Install pnpm
39+
uses: pnpm/action-setup@v2
40+
with:
41+
version: 10.12.1
42+
43+
- name: Use Node.js ${{ matrix.node-version }}
44+
uses: buildjet/setup-node@v3
45+
with:
46+
node-version: ${{ matrix.node-version }}
47+
cache: 'pnpm'
48+
49+
- name: Get pnpm store directory
50+
id: pnpm-cache
51+
shell: bash
52+
run: |
53+
echo "STORE_PATH=$(pnpm store path)" >> $GITHUB_OUTPUT
54+
55+
- name: Setup pnpm cache
56+
uses: buildjet/cache@v3
57+
with:
58+
path: ${{ steps.pnpm-cache.outputs.STORE_PATH }}
59+
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
60+
restore-keys: |
61+
${{ runner.os }}-pnpm-store-
62+
63+
- name: Install dependencies
64+
run: pnpm install --frozen-lockfile
65+
66+
- name: Build
67+
run: pnpm run build
68+
69+
- name: Lint
70+
run: pnpm run lint
71+
72+
# install again for internal dependencies
73+
- name: Install internal dependencies
74+
run: pnpm install --frozen-lockfile
75+
76+
- name: Test
77+
run: pnpm run test

package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,19 @@
22
"name": "zenstack-v3",
33
"version": "3.0.0-alpha.1",
44
"description": "ZenStack",
5-
"packageManager": "pnpm@10.0.0",
5+
"packageManager": "pnpm@10.12.1",
66
"scripts": {
77
"build": "pnpm -r build",
88
"watch": "pnpm -r --parallel watch",
9+
"lint": "pnpm -r lint",
910
"test": "pnpm vitest"
1011
},
1112
"keywords": [],
1213
"author": "",
1314
"license": "ISC",
1415
"devDependencies": {
1516
"@swc/core": "^1.10.15",
17+
"eslint": "~8.57.1",
1618
"npm-run-all": "^4.1.5",
1719
"tsup": "^8.3.5",
1820
"tsx": "^4.19.2",

packages/cli/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
"scripts": {
2424
"build": "tsup-node",
2525
"watch": "tsup-node --watch",
26+
"lint": "eslint src --ext ts",
2627
"test": "vitest",
2728
"pack": "pnpm pack"
2829
},

packages/language/.eslintrc.json

Lines changed: 0 additions & 13 deletions
This file was deleted.

packages/language/src/validators/expression-validator.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
11
import { AstUtils, type AstNode, type ValidationAcceptor } from 'langium';
22
import {
33
BinaryExpr,
4-
DataModelAttribute,
54
Expression,
65
isArrayExpr,
76
isDataModel,
87
isDataModelAttribute,
9-
isDataModelField,
108
isEnum,
119
isLiteralExpr,
1210
isMemberAccessExpr,
@@ -18,7 +16,6 @@ import {
1816

1917
import {
2018
findUpAst,
21-
getAttributeArgLiteral,
2219
isAuthInvocation,
2320
isAuthOrAuthMemberAccess,
2421
isDataModelFieldReference,

packages/language/src/validators/schema-validator.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
import type { LangiumDocuments, ValidationAcceptor } from 'langium';
22
import { PLUGIN_MODULE_NAME, STD_LIB_MODULE_NAME } from '../constants';
3-
import { isDataModel, isDataSource, type Model } from '../generated/ast';
3+
import { isDataSource, type Model } from '../generated/ast';
44
import {
55
getAllDeclarationsIncludingImports,
6-
getDataModelAndTypeDefs,
7-
hasAttribute,
86
resolveImport,
97
resolveTransitiveImports,
108
} from '../utils';

packages/runtime/package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
"build": "tsup-node && pnpm test-typecheck",
88
"test-typecheck": "tsc --project tsconfig.test.json",
99
"watch": "tsup-node --watch",
10+
"lint": "eslint src --ext ts",
1011
"test": "vitest",
1112
"pack": "pnpm pack"
1213
},
@@ -85,6 +86,7 @@
8586
"dependencies": {
8687
"@paralleldrive/cuid2": "^2.2.2",
8788
"decimal.js": "^10.4.3",
89+
"is-plain-object": "^5.0.0",
8890
"kysely": "^0.27.5",
8991
"nanoid": "^5.0.9",
9092
"pg-connection-string": "^2.9.0",
@@ -112,8 +114,8 @@
112114
"@types/pg": "^8.0.0",
113115
"@types/tmp": "^0.2.6",
114116
"@zenstackhq/language": "workspace:*",
115-
"@zenstackhq/testtools": "workspace:*",
116117
"@zenstackhq/sdk": "workspace:*",
118+
"@zenstackhq/testtools": "workspace:*",
117119
"tmp": "^0.2.3"
118120
}
119121
}

packages/runtime/src/client/client-impl.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,7 @@ export class ClientImpl<Schema extends SchemaDef> {
199199
);
200200
}
201201

202+
// eslint-disable-next-line @typescript-eslint/ban-types
202203
return (procOptions[name] as Function).apply(this, [this, ...args]);
203204
}
204205

0 commit comments

Comments
 (0)