Skip to content

Commit

Permalink
style: Lint and style code
Browse files Browse the repository at this point in the history
* Use gts for linting and styling, according to NDE standards.
  • Loading branch information
ddeboer committed May 27, 2024
1 parent 0c7d07d commit 993ead7
Show file tree
Hide file tree
Showing 46 changed files with 6,503 additions and 4,861 deletions.
8 changes: 8 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
root = true

[*]
indent_style = space
indent_size = 2
end_of_line = lf
charset = utf-8
insert_final_newline = true
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
build/
15 changes: 1 addition & 14 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,16 +1,3 @@
{
"env": {
"browser": true,
"es2021": true
},
"extends": ["standard-with-typescript", "prettier"],
"parserOptions": {
"ecmaVersion": "latest",
"sourceType": "module",
"project": ["tsconfig.json"]
},
"rules": {
"@typescript-eslint/return-await": "off",
"@typescript-eslint/no-non-null-assertion": "off"
}
"extends": "./node_modules/gts/"
}
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
with:
node-version: lts/*
- run: npm ci
- run: npm run build
- run: npm run compile
- run: npm run semantic-release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Expand Down
21 changes: 7 additions & 14 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,45 +1,38 @@
# For more information on running Github CI with Node: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-nodejs
name: Test
run-name: Testing commit by ${{ github.actor }}

# when pipeline is triggered
on:
# manual trigger workflow in UI
workflow_dispatch:
# commit on any branch
push:
# only trigger on branches, not on tags
branches: ['**']
# during pull request
pull_request:
branches:
- main

# cancel any ongoing job in the branch if there is one more recent
concurrency:
group: ${{ github.ref }}
cancel-in-progress: true

jobs:
install-build-test:
test:
runs-on: ubuntu-latest

strategy:
matrix:
# Using Node LTS https://nodejs.org/en
node-version: [20.10.0]
node-version: [lts/*]

steps:
- run: echo "Job was automatically triggered by a ${{ github.event_name }} event on ${{ github.ref }} - ${{ github.repository }}."
- uses: actions/checkout@v4
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
- name: Check versions
run: echo "Node version:" && node -v && echo "NPM version:" && npm -v
- name: Install dependencies
run: npm install
- run: npm run lint
- name: Build
run: npm run build
run: npm run compile
- name: LDWorkbench init & test run
run: rm -rf ./pipelines && npx ld-workbench --init && npx ld-workbench -c "src/utils/tests/static/single/conf.yml"
- name: Test
Expand Down
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
dist
node_modules
build/
node_modules/
.eslintcache
3 changes: 1 addition & 2 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"

npx lint-staged
# npm test
npm run lint
3 changes: 3 additions & 0 deletions .prettierrc.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module.exports = {
...require('gts/.prettierrc.json')
}
6 changes: 3 additions & 3 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"yaml.schemas": {
"static/ld-workbench.schema.json": [
"pipelines/configurations/**/*.yml",
"static/example/*.yml",
],
"static/example/*.yml"
]
}
}
}
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ For local development, the following command should get you going:
git clone https://github.com/netwerk-digitaal-erfgoed/ld-workbench.git
cd ld-workbench
npm i
npm run build
npm run compile
```

To start the CLI tool you can use this command:
Expand All @@ -133,7 +133,7 @@ To start the CLI tool you can use this command:
npm run ld-workbench -- --configDir static/example
```

Since this project is written in Typescript, your code needs to be transpiled to Javascript before you can run it (using `npm run build`). With `npm run dev` the transpiler will watch changes in the Typescript code an transpiles on each change.
Since this project is written in Typescript, your code needs to be transpiled to Javascript before you can run it (using `npm run compile`). With `npm run dev` the transpiler will watch changes in the Typescript code an transpiles on each change.

The configuration of this project is validated and defined by [JSON Schema](https://json-schema.org). The schema is located in `./static/ld-workbench-schema.json`. To create the types from this schema, run `npm run util:json-schema-to-typescript`. This will regenerate `./src/types/LDWorkbenchConfiguration.d.ts`, do not modify this file by hand.

Expand Down
Loading

0 comments on commit 993ead7

Please sign in to comment.