Skip to content

Commit

Permalink
Configure husky (#877)
Browse files Browse the repository at this point in the history
Signed-off-by: Christophe Bedard <[email protected]>
  • Loading branch information
christophebedard authored May 29, 2024
1 parent e5cb918 commit c48db04
Show file tree
Hide file tree
Showing 7 changed files with 27 additions and 12 deletions.
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

0 comments on commit c48db04

Please sign in to comment.