Skip to content

Commit 0330955

Browse files
authored
Merge pull request #88 from MOV-AI/FP-2920-configure-husky-lint-staged-and-prettier
FP 2920 configure husky lint staged and prettier
2 parents 634520e + 16a4782 commit 0330955

22 files changed

+692
-214
lines changed

.devcontainer/devcontainer.json

+2-4
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,10 @@
1919
},
2020
"postCreateCommand": "bash -i -c 'nvm install $(cat .nvmrc) -y && nvm use && corepack enable && pnpm clean && pnpm install'",
2121
"remoteUser": "node",
22-
"runArgs": [
23-
"--network=host"
24-
],
22+
"runArgs": ["--network=host"],
2523
"mounts": [
2624
"type=bind,src=${localEnv:HOME}/.npmrc,dst=/home/node/.npmrc",
2725
"type=bind,src=${localEnv:HOME}/.ssh,dst=/home/node/.ssh",
2826
"type=bind,src=${localEnv:HOME}/movai/src/feapps,dst=/workspaces/"
2927
]
30-
}
28+
}

.github/workflows/TestOnPR.yml

+1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ jobs:
1212
uses: MOV-AI/.github/.github/workflows/[email protected]
1313
with:
1414
deploy: "false"
15+
run_lint_staged: "true"
1516
run_tests: "true"
1617
use_nvmrc: "true"
1718
pm: "pnpm"

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ typings/
5252

5353
# Optional npm cache directory
5454
.npm
55+
.pnpm-store
5556

5657
# Optional eslint cache
5758
.eslintcache

.husky/pre-commit

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
pnpm exec lint-staged

.prettierignore

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
package.json
2+
pnpm-lock.yaml

.prettierrc.json

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{}

.storybook/main.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ module.exports = {
1111
resolve: {
1212
alias: {
1313
vscode: require.resolve(
14-
"@codingame/monaco-languageclient/lib/vscode-compatibility"
14+
"@codingame/monaco-languageclient/lib/vscode-compatibility",
1515
),
1616
},
1717
extensions: [".js", ".json", ".ttf"],
@@ -39,5 +39,5 @@ module.exports = {
3939
core: {
4040
builder: "webpack5",
4141
},
42-
addons: ['storybook-addon-mock/register'],
42+
addons: ["storybook-addon-mock/register"],
4343
};

.storybook/middleware.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ module.exports = function (router) {
2020
ws: true,
2121
logLevel: "error",
2222
secure: false,
23-
}
24-
)
23+
},
24+
),
2525
);
2626

2727
// to test language server locally
@@ -33,7 +33,7 @@ module.exports = function (router) {
3333
logLevel: "error",
3434
secure: false,
3535
changeOrigin: true,
36-
})
36+
}),
3737
);
3838

3939
// using movai-flow dev

.vscode/extensions.json

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"recommendations": ["esbenp.prettier-vscode"]
3+
}

.vscode/settings.json

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"prettier.configPath": ".prettierrc.json",
3+
"editor.formatOnSave": true
4+
}

CHANGELOG.md

+4
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
# TBD
2+
3+
- [FP-2920](https://movai.atlassian.net/browse/FP-2920): Configure husky, lint-staged and prettier for lib-code-editor
4+
15
# 1.1.4
26

37
- [FP-2926](https://movai.atlassian.net/browse/FP-2926): Clear console and app errors

README.md

+65-52
Original file line numberDiff line numberDiff line change
@@ -7,26 +7,28 @@ Mov.ai's library to expose Code Editors
77
# Table of Content
88

99
<!-- TOC -->
10-
* [Mov.ai library for code editor](#movai-library-for-code-editor)
11-
* [Table of Content](#table-of-content)
12-
* [Setting Up Your Development Environment](#setting-up-your-development-environment)
13-
* [Common Configuration](#common-configuration)
14-
* [Configure ~/.npmrc](#configure-npmrc)
15-
* [Using a DevContainer (recommended)](#using-a-devcontainer-recommended)
16-
* [Using a Local Setup](#using-a-local-setup)
17-
* [Tools Required](#tools-required)
18-
* [Install Node with NVM](#install-node-with-nvm)
19-
* [Install PNPM](#install-pnpm)
20-
* [Using a DevContainer Setup](#using-a-devcontainer-setup)
21-
* [Tools Required](#tools-required-1)
22-
* [Development](#development)
23-
* [How to install this library to an app](#how-to-install-this-library-to-an-app)
24-
* [How to Link this library locally to an App](#how-to-link-this-library-locally-to-an-app)
25-
<!-- TOC -->
10+
11+
- [Mov.ai library for code editor](#movai-library-for-code-editor)
12+
- [Table of Content](#table-of-content)
13+
- [Setting Up Your Development Environment](#setting-up-your-development-environment)
14+
- [Common Configuration](#common-configuration)
15+
- [Configure ~/.npmrc](#configure-npmrc)
16+
- [Using a DevContainer (recommended)](#using-a-devcontainer-recommended)
17+
- [Using a Local Setup](#using-a-local-setup)
18+
- [Tools Required](#tools-required)
19+
- [Install Node with NVM](#install-node-with-nvm)
20+
- [Install PNPM](#install-pnpm)
21+
- [Using a DevContainer Setup](#using-a-devcontainer-setup)
22+
- [Tools Required](#tools-required-1)
23+
- [Development](#development)
24+
- [How to install this library to an app](#how-to-install-this-library-to-an-app)
25+
- [How to Link this library locally to an App](#how-to-link-this-library-locally-to-an-app)
26+
<!-- TOC -->
2627

2728
# Setting Up Your Development Environment
2829

2930
You can set up your development environment in two ways:
31+
3032
- In a DevContainer (recommended)
3133
- Locally
3234

@@ -71,58 +73,61 @@ To install Node.js using `nvm` (Node Version Manager), follow these steps:
7173

7274
Open your terminal and run the following command to install `nvm`:
7375

74-
```bash
75-
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.4/install.sh | bash
76-
```
76+
```bash
77+
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.4/install.sh | bash
78+
```
7779

7880
2. **Load `nvm`:**
7981

8082
After installing `nvm`, you need to load it. Close and reopen your terminal, or run:
8183

82-
```bash
83-
source ~/.nvm/nvm.sh
84-
```
84+
```bash
85+
source ~/.nvm/nvm.sh
86+
```
8587

8688
3. **Install the required Node.js version:**
8789

8890
With `nvm` installed and loaded, run the following command to use the required Node.js version:
8991

90-
```bash
91-
nvm install && nvm use # uses the node version specify in the .nvmrc file
92-
```
92+
```bash
93+
nvm install && nvm use # uses the node version specify in the .nvmrc file
94+
```
9395

9496
4. **Set the used Node.js as the default version:**
9597

96-
```bash
97-
nvm current # prints the node.js version being used
98-
nvm alias default xx.xx.x # sets xx.xx.x as default
99-
```
98+
```bash
99+
nvm current # prints the node.js version being used
100+
nvm alias default xx.xx.x # sets xx.xx.x as default
101+
```
100102

101103
5. **Verify the installation:**
102104

103-
```bash
104-
node -v
105-
```
105+
```bash
106+
node -v
107+
```
106108

107109
This should output the node version specified in `.nvmrc` file.
108110

109-
110111
#### Install PNPM
111112

112113
To install `pnpm`, follow these steps:
113114

114115
1. Using the required pnpm version:
115116

116117
The pnpm version required is specify in the `package.json` file as:
117-
```json
118-
{
119-
"packageManager": "[email protected]"
120-
}
121-
```
118+
119+
```json
120+
{
121+
"packageManager": "[email protected]"
122+
}
123+
```
124+
122125
In order to have Node.js use the specified version, run:
123-
```bash
126+
127+
```bash
124128
corepack enable
125-
```
129+
```
130+
126131
Upon first use, Corepack downloads the latest version from the network and uses it when running pnpm commands.
127132

128133
### Using a DevContainer Setup
@@ -138,9 +143,10 @@ To install `pnpm`, follow these steps:
138143
## How to install this library to an app
139144

140145
1. - Install package:
141-
```bash
142-
"pnpm install @mov-ai/mov-fe-lib-code-editor"
143-
```
146+
147+
```bash
148+
"pnpm install @mov-ai/mov-fe-lib-code-editor"
149+
```
144150

145151
## How to Link this library locally to an App
146152

@@ -149,26 +155,33 @@ Here's how it can be done:
149155

150156
1. In the app, identify this library in the `package.json`:
151157

152-
```
153-
"@mov-ai/mov-fe-lib-code-editor": "^x.x.x-X",
154-
```
158+
```
159+
"@mov-ai/mov-fe-lib-code-editor": "^x.x.x-X",
160+
```
155161

156162
2. Replace the library version with the path of this local library:
157163

158-
```
164+
```
159165
"@mov-ai/mov-fe-lib-code-editor": "file:/home/username/path/to/library/frontend-npm-lib-code-editor"
160-
```
166+
```
161167

162168
3. Build this local library:
163169

164-
```bash
170+
```bash
165171
pnpm install # installs dependencies
166172
pnpm buildDev # builds the app and watches for changes
167-
```
173+
```
168174

169175
4. Install and build the app:
170176

171-
```bash
177+
```bash
172178
pnpm install # installs dependencies including the local library
173179
pnpm start # runs the app
174-
```
180+
```
181+
182+
## How to setup linting git hook
183+
184+
1. Install husky git hook:
185+
```bash
186+
"pnpm prepare"
187+
```

babel.config.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
{
22
"presets": ["@babel/preset-react", "@babel/preset-env"],
33
"plugins": ["@babel/plugin-transform-react-jsx"]
4-
}
4+
}

jest.config.js

+3-4
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,10 @@ module.exports = {
33
"^.+\\.[tj]sx?$": "babel-jest",
44
},
55
transformIgnorePatterns: [
6-
"node_modules/(?!(@codingame/monaco-languageclient|vscode-languageserver-textdocument)/)"
6+
"node_modules/(?!(@codingame/monaco-languageclient|vscode-languageserver-textdocument)/)",
77
],
8-
testEnvironment: 'jsdom',
8+
testEnvironment: "jsdom",
99
moduleNameMapper: {
10-
'^monaco-editor$': '<rootDir>/src/__mocks__/monaco-editor.js', // Adjust as needed
10+
"^monaco-editor$": "<rootDir>/src/__mocks__/monaco-editor.js", // Adjust as needed
1111
},
1212
};
13-

0 commit comments

Comments
 (0)