Skip to content

Commit

Permalink
Monorepo [1/?] - move precommit scripts to root (#5998)
Browse files Browse the repository at this point in the history
## About

This pull request is a part of the effort of migrating to monorepo
structure:
- #5992
- #5993

## Summary

This particular pull requests moves the precommit husky script to the
root directory to enable it. It also extracts `lint-staged`
configuration from `packages/react-native-reanimated` to a separate file
for it to be less polluted.

## Test plan

The script should be working as expected. Try it by cloning the monorepo
and doing something bad in the code.
  • Loading branch information
tjzel committed Jun 5, 2024
1 parent 04171e3 commit 8c381e0
Show file tree
Hide file tree
Showing 6 changed files with 690 additions and 448 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

REANIMATED_PATH=packages/react-native-reanimated

yarn lint-staged
cd $REANIMATED_PATH
yarn type:check:all
yarn find-unused-code:js

Expand Down
9 changes: 8 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,12 @@
"name": "react-native-reanimated-monorepo",
"version": "0.0.0",
"packageManager": "yarn@4.1.1",
"private": true
"private": true,
"scripts": {
"build": "husky"
},
"devDependencies": {
"husky": "^9.0.11",
"lint-staged": "^15.2.2"
}
}
14 changes: 14 additions & 0 deletions packages/react-native-reanimated/.lintstagedrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
const REANIMATED_PATH = 'packages/react-native-reanimated';
module.exports = {
'*.(js|ts|tsx)': [
`cd ${REANIMATED_PATH} && yarn eslint `,
`cd ${REANIMATED_PATH} && yarn eslint --quiet --ext '.js,.ts,.tsx' src/`,
`cd ${REANIMATED_PATH} && yarn prettier --write`,
],
'plugin/**/*.{js,ts,tsx}': `cd ${REANIMATED_PATH} && yarn lint:plugin`,
'**/*.{h,cpp}': `cd ${REANIMATED_PATH} && yarn lint:cpp`,
'android/src/**/*.java': `cd ${REANIMATED_PATH} && yarn format:java`,
'android/src/**/*.{h,cpp}': `cd ${REANIMATED_PATH} && yarn format:android`,
'apple/**/*.{h,m,mm,cpp}': `cd ${REANIMATED_PATH} && yarn format:ios`,
'Common/**/*.{h,cpp}': `cd ${REANIMATED_PATH} && yarn format:common`,
};
18 changes: 0 additions & 18 deletions packages/react-native-reanimated/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -139,9 +139,7 @@
"eslint-plugin-react-hooks": "^4.6.0",
"eslint-plugin-standard": "^5.0.0",
"eslint-plugin-tsdoc": "^0.2.17",
"husky": "^7.0.4",
"jest": "^29.0.0",
"lint-staged": "^15.2.2",
"madge": "^5.0.1",
"prettier": "^2.5.1",
"react": "18.2.0",
Expand All @@ -154,22 +152,6 @@
"ts-prune": "^0.10.3",
"typescript": "^4.1.3"
},
"lint-staged": {
"*.(js|jsx|ts|tsx|h|cpp|m|mm|java|kt|swift|md|mdx)": [
"yarn cspell"
],
"*.(js|ts|tsx)": [
"yarn eslint",
"yarn eslint --quiet --ext '.js,.ts,.tsx' src/",
"yarn prettier --write"
],
"plugin/**/*.ts": "yarn lint:plugin",
"**/*.{h,cpp}": "yarn lint:cpp",
"android/src/**/*.java": "yarn format:java",
"android/src/**/*.{h,cpp}": "yarn format:android",
"apple/**/*.{h,m,mm,cpp}": "yarn format:ios",
"Common/**/*.{h,cpp}": "yarn format:common"
},
"react-native-builder-bob": {
"source": "src",
"output": "lib",
Expand Down
Loading

0 comments on commit 8c381e0

Please sign in to comment.