Skip to content

Commit

Permalink
Breaking: enforce prettier on pre-commit hook (#88)
Browse files Browse the repository at this point in the history
  • Loading branch information
forabi committed Jun 14, 2018
1 parent 74024be commit a84e62f
Show file tree
Hide file tree
Showing 12 changed files with 62 additions and 49 deletions.
8 changes: 8 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
.git/
package.json
node_modules/

coverage

.serverless
.webpack
3 changes: 2 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
"**/.babelrc.json": "jsonc",
"**/tsconfig.json": "jsonc",
"**/tslint.json": "jsonc",
"**/.eslintrc.json": "jsonc"
"**/.eslintrc.json": "jsonc",
"**/.prettierignore": "gitignore"
}
}
42 changes: 21 additions & 21 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,30 +6,30 @@ This repository contains shared configuration files used across multiple [Hollow

`@hollowverse/config` currently includes configuration files for:

* TypeScript ([`tsconfig.json`](./tsconfig.json))
* TSLint ([`tslint.json`](./tslint.json))
* ESLint ([`.eslintrc.json`](./.eslintrc.json), other language-specific configurations in [`./eslint`](./eslint))
* Stylelint ([`.stylelintrc`](./.stylelintrc))
* Prettier ([`prettier.config.js`](./prettier.config.js))
* Babel ([`lambda/.babelrc`](./lambda/.babelrc) for AWS Lambda)
- TypeScript ([`tsconfig.json`](./tsconfig.json))
- TSLint ([`tslint.json`](./tslint.json))
- ESLint ([`.eslintrc.json`](./.eslintrc.json), other language-specific configurations in [`./eslint`](./eslint))
- Stylelint ([`.stylelintrc`](./.stylelintrc))
- Prettier ([`prettier.config.js`](./prettier.config.js))
- Babel ([`lambda/.babelrc`](./lambda/.babelrc) for AWS Lambda)

### How to use the shared configuration

1. Install this package as dependency of your project:
```bash
yarn add @hollowverse/config --dev
# or
npm install @hollowverse/config --save-dev
```
2. Install the [peer dependencies](./package.json#L31) for each of the tools used in the new project.
3. Extend your project configuration files with the corresponding files from this package. For example, here is how to extend `tsconfig.json`:
```json
{
"extends": "./node_modules/@hollowverse/config/tsconfig.json"
}
```
Refer to each tool's documentation for more information on how to extend the configuration.
4. Add properties to the configuration file to override the shared configuration as needed.
1. Install this package as dependency of your project:
```bash
yarn add @hollowverse/config --dev
# or
npm install @hollowverse/config --save-dev
```
2. Install the [peer dependencies](./package.json#L31) for each of the tools used in the new project.
3. Extend your project configuration files with the corresponding files from this package. For example, here is how to extend `tsconfig.json`:
```json
{
"extends": "./node_modules/@hollowverse/config/tsconfig.json"
}
```
Refer to each tool's documentation for more information on how to extend the configuration.
4. Add properties to the configuration file to override the shared configuration as needed.

---

Expand Down
2 changes: 1 addition & 1 deletion clown/common/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"extends": ["./node_modules/@hollowverse/config/eslint/base/.eslintrc.json"]
}
}
8 changes: 8 additions & 0 deletions clown/common/.prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
.git/
package.json
node_modules/

coverage

.serverless
.webpack
3 changes: 2 additions & 1 deletion clown/common/.vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@
"**/.babelrc.json": "jsonc",
"**/tslint.json": "jsonc",
"**/tsconfig.json": "jsonc",
"**/.eslintrc.json": "jsonc"
"**/.eslintrc.json": "jsonc",
"**/.prettierignore": "gitignore"
},
"typescript.implementationsCodeLens.enabled": true,
"typescript.referencesCodeLens.enabled": true,
Expand Down
9 changes: 5 additions & 4 deletions clown/common/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
"pre-push": "# OVERRIDE",
"pre-commit": "yarn common-check",
"lint-staged": "lint-staged",
"common-check": "run-p -c --aggregate-output validate-filenames 'clown check' check-integrity",
"check-prettier": "prettier './**/*.{t,j}s{,x}' '**/*.{css,scss,json,md}' --list-different",
"common-check": "run-p -c --aggregate-output check-prettier validate-filenames 'clown check' check-integrity",
"check-integrity": "yarn check --integrity",
"validate-filenames": "validate-filenames"
},
Expand All @@ -17,7 +18,7 @@
"prettier --write",
"git add"
],
"**/!(package).json": [
"**/*.json": [
"prettier --write",
"git add"
],
Expand All @@ -27,7 +28,7 @@
},
"husky": {
"hooks": {
"pre-commit": "run-p -c --aggregate-output lint-staged pre-commit",
"pre-commit": "npm-run-all -s lint-staged -p -c --aggregate-output pre-commit",
"pre-push": "yarn pre-push",
"post-merge": "yarnhook",
"post-checkout": "yarnhook",
Expand All @@ -37,7 +38,7 @@
"devDependencies": {
"@hollowverse/validate-filenames": "^3.0.2",
"husky": "^1.0.0-rc.1",
"prettier": "^1.12.0",
"prettier": "^1.13.5",
"yarnhook": "^0.2.0",
"lint-staged": "^7.0.5",
"babel-eslint": "^8.2.2",
Expand Down
2 changes: 1 addition & 1 deletion eslint/node/.eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
"env": {
"node": true
}
}
}
10 changes: 3 additions & 7 deletions eslint/react/base/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,15 +1,11 @@
{
"plugins": [
"react"
],
"plugins": ["react"],
"parserOptions": {
"ecmaVersion": 8,
"sourceType": "module",
"ecmaFeatures": {
"jsx": true
}
},
"extends": [
"prettier/react"
]
}
"extends": ["prettier/react"]
}
7 changes: 2 additions & 5 deletions eslint/react/javascript/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
{
"extends": "../base/.eslintrc.json",
"parser": "babel-eslint",
"extends": [
"airbnb/react",
"plugin:react/recommended"
]
}
"extends": ["airbnb/react", "plugin:react/recommended"]
}
11 changes: 6 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,15 @@
"clown": "clown",
"pre-push": "yarn common-check",
"pre-commit": "yarn common-check",
"common-check": "run-p -c --aggregate-output validate-filenames 'clown check' check-integrity",
"common-check": "run-p -c --aggregate-output check-prettier validate-filenames 'clown check' check-integrity",
"commitlint": "commitlint -e $GIT_PARAMS",
"semantic-release": "semantic-release",
"check-integrity": "yarn check --integrity"
"check-integrity": "yarn check --integrity",
"check-prettier": "prettier './**/*.{t,j}s{,x}' '**/*.{css,scss,json,md}' --list-different"
},
"husky": {
"hooks": {
"pre-commit": "run-p -c --aggregate-output lint-staged pre-commit",
"pre-commit": "npm-run-all -s lint-staged -p -c --aggregate-output pre-commit",
"pre-push": "yarn pre-push",
"post-merge": "yarnhook",
"post-checkout": "yarnhook",
Expand All @@ -40,7 +41,7 @@
"prettier --write",
"git add"
],
"**/!(package).json": [
"**/*.json": [
"prettier --write",
"git add"
],
Expand All @@ -65,7 +66,7 @@
"husky": "^1.0.0-rc.1",
"lint-staged": "^7.0.5",
"npm-run-all": "^4.1.2",
"prettier": "^1.12.0",
"prettier": "^1.13.5",
"semantic-release": "^15.1.5",
"typescript": "^2.7.2",
"yarnhook": "^0.2.0"
Expand Down
6 changes: 3 additions & 3 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3755,9 +3755,9 @@ preserve@^0.2.0:
version "0.2.0"
resolved "https://registry.yarnpkg.com/preserve/-/preserve-0.2.0.tgz#815ed1f6ebc65926f865b310c0713bcb3315ce4b"

prettier@^1.12.0:
version "1.12.1"
resolved "https://registry.yarnpkg.com/prettier/-/prettier-1.12.1.tgz#c1ad20e803e7749faf905a409d2367e06bbe7325"
prettier@^1.13.5:
version "1.13.5"
resolved "https://registry.yarnpkg.com/prettier/-/prettier-1.13.5.tgz#7ae2076998c8edce79d63834e9b7b09fead6bfd0"

pretty-format@^22.4.3:
version "22.4.3"
Expand Down

0 comments on commit a84e62f

Please sign in to comment.