Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Configure husky #877

Merged
merged 1 commit into from
May 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 1 addition & 7 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,5 @@
},
"plugins": ["@typescript-eslint"],
"rules": {},
"ignorePatterns": [
"dist",
"coverage",
"*.md",
"*.yml",
"*.yaml"
]
"ignorePatterns": ["dist", "coverage", "*.md", "*.yml", "*.yaml"]
}
1 change: 1 addition & 0 deletions .husky/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
_
1 change: 1 addition & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
npx lint-staged
4 changes: 2 additions & 2 deletions .lintstagedrc.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
module.exports = {
"*": [
"eslint --cache --fix --ignore-path .eslintignore",
"prettier --write --ignore-path .eslintignore --ignore-unknown",
"eslint --cache --fix --config .eslintrc.json",
"prettier --write --config .prettierrc --ignore-path .prettierignore --ignore-unknown",
// Note: doing the build here ensures we omit unstaged changes
() => "npm run build",
() => "git add dist/index.js",
Expand Down
5 changes: 5 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
dist
coverage
*.md
*.yml
*.yaml
18 changes: 15 additions & 3 deletions DEVELOPING.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,23 @@ Install [Node.js](https://nodejs.org/en/download/).

We are currently using Node.js v20.

## Build and test
## Install dependencies

```
# install dependencies
```sh
npm install
```

## Setup git hooks

This will setup git hooks to run linters, generate build artifacts, and run tests when committing (pre-commit).

```sh
npm run prepare
```

## Build and test

```sh
# autoformat sources to meet enforced linter style
npm run fixup
# generate build artifacts
Expand Down
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,11 @@
"description": "GitHub Action compiling and testing a ROS 2 package",
"main": "lib/main.js",
"scripts": {
"prepare": "husky",
"build": "ncc build src/run.ts -o dist",
"fixup": "eslint . --fix",
"lint": "eslint .",
"prettier": "prettier --write .",
"test": "tsc --noEmit && jest --coverage"
},
"repository": {
Expand Down
Loading