Skip to content

Commit e292e86

Browse files
authored
Merge pull request #2 from atlp-rwanda/ch-eslint-precommit-#187419115
#187419115 Configure ESLint and Git Pre commit hook to run tests and ESlint format
2 parents 3f8a19f + 98136c8 commit e292e86

24 files changed

+5503
-971
lines changed

Diff for: .eslintignore

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# jest
2+
jest.config.*

Diff for: .eslintrc.cjs

+56-2
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,72 @@
11
module.exports = {
22
root: true,
3-
env: { browser: true, es2020: true },
3+
env: {
4+
browser: true,
5+
es2020: true,
6+
node: true,
7+
},
48
extends: [
5-
"eslint:recommended",
9+
"airbnb",
10+
"airbnb-typescript",
11+
"airbnb/hooks",
612
"plugin:@typescript-eslint/recommended",
713
"plugin:react-hooks/recommended",
814
],
915
ignorePatterns: ["dist", ".eslintrc.cjs"],
1016
parser: "@typescript-eslint/parser",
17+
parserOptions: {
18+
project: "./tsconfig.eslint.json",
19+
tsconfigRootDir: __dirname,
20+
},
1121
plugins: ["react-refresh"],
1222
rules: {
23+
"react/react-in-jsx-scope": "off",
24+
"react/function-component-definition": [
25+
"warn",
26+
{
27+
namedComponents: "arrow-function",
28+
unnamedComponents: "arrow-function",
29+
},
30+
],
31+
"no-undef": "off",
1332
"react-refresh/only-export-components": [
1433
"warn",
1534
{ allowConstantExport: true },
1635
],
36+
"@typescript-eslint/quotes": ["off"],
37+
"arrow-body-style": ["warn", "as-needed"],
38+
"import/order": [
39+
"warn",
40+
{
41+
groups: [
42+
"builtin",
43+
"external",
44+
"internal",
45+
"parent",
46+
"sibling",
47+
"index",
48+
],
49+
"newlines-between": "always",
50+
},
51+
],
52+
"@typescript-eslint/comma-dangle": ["warn", "always-multiline"],
53+
"import/no-extraneous-dependencies": [
54+
"error",
55+
{
56+
devDependencies: [
57+
"vite.config.ts",
58+
"postcss.config.js",
59+
"tailwind.config.js",
60+
],
61+
},
62+
],
63+
"import/extensions": ["off"],
64+
},
65+
settings: {
66+
"import/resolver": {
67+
node: {
68+
extensions: [".js", ".jsx", ".ts", ".tsx"],
69+
},
70+
},
1771
},
1872
};

Diff for: .github/workflows/deploy.yml

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
name: Eagle e-commerce CI/CD
32

43
on:
@@ -33,7 +32,7 @@ jobs:
3332

3433
- name: Running test
3534
run: npm run test --coverage
36-
35+
3736
- name: Build application
3837
run: npm run build
3938

Diff for: .husky/.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
_

Diff for: .husky/pre-commit

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/usr/bin/env sh
2+
. "$(dirname -- "$0")/_/husky.sh"
3+
4+
npm run test

Diff for: .prettierrc.json

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"tabWidth": 2,
3+
"useTabs": false,
4+
"singleQuote": false,
5+
"semi": true,
6+
"bracketSpacing": true,
7+
"arrowParens": "always",
8+
"bracketSameLine": true,
9+
"endOfLine": "auto"
10+
}

Diff for: README.md

+32-12
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# EAGLE E-commerce
22

3+
<img alt="Static Badge" src="https://img.shields.io/badge/Reviewed_By-HoundCI-blue?style=flat-square">
4+
35
The front-end of Eagle E-commerce utilizes React for a modern, user-friendly interface, while Node.js powers its backend, ensuring a seamless shopping experience
46

57
[![Maintainability](https://api.codeclimate.com/v1/badges/81fa30232b27b1482f4f/maintainability)](https://codeclimate.com/github/atlp-rwanda/eagles-ec-fe/maintainability)
@@ -15,33 +17,51 @@ This project was built using the PERN (PostgreSQL, Express.js, React.js, Node.js
1517
To run the app locally, follow these steps:
1618

1719
1. **Clone the repository:**
20+
1821
```bash
1922
git clone https://github.com/atlp-rwanda/eagles-ec-fe.git
20-
```
23+
```
24+
2125
2. **Change working dir to cloned repo:**
26+
2227
```bash
2328
cd eagle-ec-fe
2429
```
30+
2531
3. **Install dependencies:**
32+
2633
```bash
2734
npm install
2835
```
36+
2937
4. **Run developmnt server:**
38+
3039
```bash
3140
npm run dev
32-
```
41+
```
42+
3343
## How to run test
3444

3545
1. **Run unit test:**
36-
```bash
46+
47+
```bash
3748
npm run test
38-
```
39-
2. **Tun test in watch mode
40-
```bash
41-
npm run test:watch
42-
```
43-
3. **Generate test coverage
44-
```bash
49+
```
50+
51+
2. \*\*Tun test in watch mode
52+
53+
```bash
54+
npm run test:watch
55+
```
56+
57+
3. \*\*Generate test coverage
58+
59+
```bash
4560
npm run test:coverage
46-
```
47-
Write your test by creating a file with .test.tsx extetion under __test__ directory.
61+
```
62+
63+
Write your test by creating a file with .test.tsx extetion under **test** directory.
64+
65+
```
66+
67+
```

Diff for: hound.yml

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
eslint:
2+
enabled: true
3+
file_patterns:
4+
- "*.js"
5+
- "*.ts"
6+
enabled_plugins:
7+
- eslint-plugin-import
8+
- eslint-plugin-prettier
9+
- eslint-plugin:@typescript-eslint

Diff for: jest.config.ts

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
export default {
2-
preset: 'ts-jest',
3-
testEnvironment: 'jest-environment-jsdom',
2+
preset: "ts-jest",
3+
testEnvironment: "jest-environment-jsdom",
44
transform: {
5-
"^.+\\.tsx?$": "ts-jest"
5+
"^.+\\.tsx?$": "ts-jest",
66
},
77
moduleNameMapper: {
8-
'\\.(gif|ttf|eot|svg|png)$': '<rootDir>/test/__ mocks __/fileMock.js',
8+
"\\.(gif|ttf|eot|svg|png)$": "<rootDir>/test/__ mocks __/fileMock.js",
99
},
10-
}
10+
};

0 commit comments

Comments
 (0)