Skip to content

Commit 22246e8

Browse files
authored
chore: enable lint and CI (#17)
* chore: enable lint and CI * get rid of cyclic dependencies * add missing eslint plugin packages * fix build
1 parent 01580a7 commit 22246e8

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+540
-388
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@v4
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: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,31 @@
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+
"@typescript-eslint/eslint-plugin": "~7.3.1",
18+
"@typescript-eslint/parser": "~7.3.1",
19+
"eslint": "~8.57.1",
1620
"npm-run-all": "^4.1.5",
1721
"tsup": "^8.3.5",
1822
"tsx": "^4.19.2",
1923
"turbo": "^2.3.3",
2024
"typescript": "~5.7.3",
2125
"vitest": "^3.1.1"
26+
},
27+
"pnpm": {
28+
"onlyBuiltDependencies": [
29+
"better-sqlite3"
30+
]
2231
}
2332
}

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/cli/test/ts-schema-gen.test.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Expression } from '@zenstackhq/runtime/schema';
1+
import { ExpressionUtils } from '@zenstackhq/runtime/schema';
22
import { generateTsSchema } from '@zenstackhq/testtools';
33
import { describe, expect, it } from 'vitest';
44

@@ -36,7 +36,7 @@ model Post {
3636
id: {
3737
type: 'String',
3838
id: true,
39-
default: Expression.call('uuid'),
39+
default: ExpressionUtils.call('uuid'),
4040
attributes: [
4141
{ name: '@id' },
4242
{
@@ -56,7 +56,7 @@ model Post {
5656
email: { type: 'String', unique: true },
5757
createdAt: {
5858
type: 'DateTime',
59-
default: Expression.call('now'),
59+
default: ExpressionUtils.call('now'),
6060
attributes: [
6161
{
6262
name: '@default',
@@ -105,7 +105,7 @@ model Post {
105105
id: {
106106
type: 'String',
107107
id: true,
108-
default: Expression.call('cuid'),
108+
default: ExpressionUtils.call('cuid'),
109109
attributes: [
110110
{ name: '@id' },
111111
{

packages/language/.eslintrc.json

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

packages/language/package.json

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,6 @@
4040
"devDependencies": {
4141
"@types/node": "^18.0.0",
4242
"@types/pluralize": "^0.0.33",
43-
"@typescript-eslint/eslint-plugin": "~7.3.1",
44-
"@typescript-eslint/parser": "~7.3.1",
45-
"eslint": "~8.57.0",
4643
"langium-cli": "~3.3.0",
4744
"typescript": "~5.1.6"
4845
},

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';

0 commit comments

Comments
 (0)