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 prettier in the root directory #49

Merged
merged 5 commits into from
Nov 30, 2023
Merged
Show file tree
Hide file tree
Changes from 4 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
1 change: 1 addition & 0 deletions .git-blame-ignore-revs
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
# Auto-fix linting
d2a058fe6cfbab6f82d0d977d1b2d8bd9f494df1
0976ac1b09b7257fe74389bafe94697059a07aed
2 changes: 1 addition & 1 deletion .github/workflows/core.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Set up pnpm
uses: pnpm/action-setup@v2

Expand Down
7 changes: 7 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
repos:
- repo: local
hooks:
# Root
- id: root-lint
name: "lint root"
entry: /usr/bin/env bash -c "npm run format"
exclude: (^core/|^dapp/|^website/)
language: script
description: "Checks code according to the package's linter configuration"
# Core
- id: core-lint-sol
name: "lint core sol"
Expand Down
7 changes: 7 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Packages that have own prettier configuration.
core/
dapp/
website/

# Auto-generated files.
pnpm-lock.yaml
3 changes: 3 additions & 0 deletions .prettierrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module.exports = {
...require("@thesis/prettier-config"),
}
15 changes: 9 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ please see the [documentation](https://pnpm.io/installation).
#### Package Dependencies

To install the packages dependencies run:

```sh
pnpm install
```
Expand All @@ -30,19 +31,21 @@ automatically discover code issues, before they submit the code.
To setup the hooks follow the steps:

1. Install `pre-commit` tool:
```sh
brew install pre-commit
```

```sh
brew install pre-commit
```

2. Install the hooks for the repository:
```sh
pre-commit install
```
```sh
pre-commit install
```

#### Testing

To test the pre-commit hooks configuration you can invoke them with one of the
commands:

```sh
# Execute hooks for all files:
pre-commit run --all-files
Expand Down
2 changes: 1 addition & 1 deletion core/.prettierrc.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module.exports = {
...require("@thesis-co/prettier-config"),
...require("../.prettierrc.js"),
plugins: ["prettier-plugin-solidity"],
overrides: [
{
Expand Down
2 changes: 1 addition & 1 deletion dapp/.prettierrc.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module.exports = {
...require("@thesis-co/prettier-config"),
...require("../.prettierrc.js"),
}
1 change: 0 additions & 1 deletion dapp/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
},
"devDependencies": {
"@thesis-co/eslint-config": "^0.6.1",
"@thesis/prettier-config": "github:thesis/prettier-config",
"@types/react": "^18.2.15",
"@types/react-dom": "^18.2.7",
"@typescript-eslint/eslint-plugin": "^6.10.0",
Expand Down
12 changes: 10 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
{
"private": true,
"packageManager": "[email protected]"
"private": true,
"packageManager": "[email protected]",
"scripts": {
"format": "prettier --check .",
"format:fix": "prettier --write ."
},
"devDependencies": {
"@thesis/prettier-config": "github:thesis/prettier-config",
"prettier": "^3.1.0"
}
}
15 changes: 8 additions & 7 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion website/.prettierrc.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module.exports = {
...require("@thesis-co/prettier-config"),
...require("../.prettierrc.js"),
}
1 change: 0 additions & 1 deletion website/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
},
"devDependencies": {
"@thesis-co/eslint-config": "^0.6.1",
"@thesis/prettier-config": "github:thesis/prettier-config",
"@types/node": "^20.3.3",
"@types/react": "^18.2.14",
"@types/react-dom": "^18.2.6",
Expand Down
Loading