Skip to content

Commit

Permalink
chroe: devops (#180)
Browse files Browse the repository at this point in the history
* ci: add dependencies about lint tool

* ci: replace eslint with prettier

* ci: add husky, cz and commitlint

* style: lint fix via prettier

* ci: add prettier and check-types to github workflow

'
  • Loading branch information
HaydenOrz authored Oct 13, 2023
1 parent 4d1dfa6 commit 7de192d
Show file tree
Hide file tree
Showing 105 changed files with 2,614 additions and 1,822 deletions.
3 changes: 3 additions & 0 deletions .czrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"path": "./node_modules/@commitlint/cz-commitlint"
}
37 changes: 0 additions & 37 deletions .eslintrc.js

This file was deleted.

43 changes: 43 additions & 0 deletions .github/workflows/nodejs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,50 @@ jobs:
- name: install
if: steps.node_modules_cache_id.outputs.cache-hit != 'true'
run: yarn
prettier:
runs-on: ubuntu-latest
needs: [setup]
steps:
- uses: actions/checkout@v2

- name: Restore cache from yarn.lock
uses: actions/cache@v2
with:
path: package-temp-dir
key: lock-${{ github.sha }}

- name: Restore cache from node_modules
uses: actions/cache@v2
with:
path: node_modules
key: node_modules-${{ hashFiles('**/package-temp-dir/yarn.lock') }}

- name: Run prettier lint
run: |
export NODE_OPTIONS="--max_old_space_size=4096"
yarn lint
check-types:
runs-on: ubuntu-latest
needs: [setup]
steps:
- uses: actions/checkout@v2

- name: Restore cache from yarn.lock
uses: actions/cache@v2
with:
path: package-temp-dir
key: lock-${{ github.sha }}

- name: Restore cache from node_modules
uses: actions/cache@v2
with:
path: node_modules
key: node_modules-${{ hashFiles('**/package-temp-dir/yarn.lock') }}

- name: Run tsc check
run: |
export NODE_OPTIONS="--max_old_space_size=4096"
yarn check-types
test:
runs-on: ubuntu-latest
needs: [setup]
Expand Down
6 changes: 6 additions & 0 deletions .husky/commit-msg
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"

echo 'commitlint'

npx --no -- commitlint --edit
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
3 changes: 3 additions & 0 deletions .lintstagedrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module.exports = {
'*.js|ts': [`prettier --write`],
};
7 changes: 7 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
**/*.md
**/*.ejs
**/package.json
**/lib
**/dist
node_modules
coverage
10 changes: 10 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"semi": true,
"tabWidth": 4,
"printWidth": 100,
"singleQuote": true,
"useTabs": false,
"bracketSpacing": true,
"arrowParens": "always",
"trailingComma": "es5"
}
12 changes: 12 additions & 0 deletions commitlint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
module.exports = {
extends: ['@commitlint/config-conventional'],
rules: {
'type-enum': [
2,
'always',
['feat', 'fix', 'docs', 'style', 'refactor', 'test', 'build', 'ci', 'chore'],
],
'scope-case': [0, 'always'],
'scope-empty': [0, 'always'],
},
};
19 changes: 12 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,28 +18,33 @@
"dist"
],
"scripts": {
"prepare": "husky install",
"antlr4": "node ./scripts/antlr4.js",
"build": "rm -rf dist && tsc",
"eslint": "eslint ./src/**/*.ts",
"check-types": "tsc --skipLibCheck",
"check-types": "tsc -p ./tsconfig.check.json",
"test": "NODE_OPTIONS=--max_old_space_size=4096 && jest",
"release": "npm run build && node ./scripts/release.js"
"release": "npm run build && node ./scripts/release.js",
"lint": "prettier --check '**/*.ts' --config ./.prettierrc",
"lint-fix": "prettier --write '**/*.ts' --config ./.prettierrc"
},
"author": "dt-insight-front",
"license": "MIT",
"devDependencies": {
"@commitlint/cli": "^17.7.2",
"@commitlint/config-conventional": "^17.7.0",
"@commitlint/cz-commitlint": "^17.7.2",
"@swc/core": "^1.3.60",
"@swc/jest": "^0.2.26",
"@types/jest": "^29.5.1",
"@types/node": "^18.15.11",
"@typescript-eslint/eslint-plugin": "^3.10.1",
"@typescript-eslint/parser": "^3.10.1",
"antlr4ts-cli": "^0.5.0-alpha.4",
"chalk": "4.1.2",
"eslint": "^7.32.0",
"eslint-config-google": "^0.14.0",
"commitizen": "^4.3.0",
"husky": "^8.0.3",
"inquirer": "^8.2.2",
"jest": "^29.5.0",
"lint-staged": "12.5.0",
"prettier": "^3.0.3",
"standard-version": "^9.5.0",
"typescript": "^5.0.4",
"yargs-parser": "^21.1.1"
Expand Down
Loading

0 comments on commit 7de192d

Please sign in to comment.