Skip to content

#187419115 Configure ESLint and Git Pre commit hook to run tests and ESlint format #2

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

Merged
merged 1 commit into from
Jun 10, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
2 changes: 2 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# jest
jest.config.*
58 changes: 56 additions & 2 deletions .eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -1,18 +1,72 @@
module.exports = {
root: true,
env: { browser: true, es2020: true },
env: {
browser: true,
es2020: true,
node: true,
},
extends: [
"eslint:recommended",
"airbnb",
"airbnb-typescript",
"airbnb/hooks",
"plugin:@typescript-eslint/recommended",
"plugin:react-hooks/recommended",
],
ignorePatterns: ["dist", ".eslintrc.cjs"],
parser: "@typescript-eslint/parser",
parserOptions: {
project: "./tsconfig.eslint.json",
tsconfigRootDir: __dirname,
},
plugins: ["react-refresh"],
rules: {
"react/react-in-jsx-scope": "off",
"react/function-component-definition": [
"warn",
{
namedComponents: "arrow-function",
unnamedComponents: "arrow-function",
},
],
"no-undef": "off",
"react-refresh/only-export-components": [
"warn",
{ allowConstantExport: true },
],
"@typescript-eslint/quotes": ["off"],
"arrow-body-style": ["warn", "as-needed"],
"import/order": [
"warn",
{
groups: [
"builtin",
"external",
"internal",
"parent",
"sibling",
"index",
],
"newlines-between": "always",
},
],
"@typescript-eslint/comma-dangle": ["warn", "always-multiline"],
"import/no-extraneous-dependencies": [
"error",
{
devDependencies: [
"vite.config.ts",
"postcss.config.js",
"tailwind.config.js",
],
},
],
"import/extensions": ["off"],
},
settings: {
"import/resolver": {
node: {
extensions: [".js", ".jsx", ".ts", ".tsx"],
},
},
},
};
3 changes: 1 addition & 2 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

name: Eagle e-commerce CI/CD

on:
Expand Down Expand Up @@ -33,7 +32,7 @@ jobs:

- name: Running test
run: npm run test --coverage

- name: Build application
run: npm run build

Expand Down
1 change: 1 addition & 0 deletions .husky/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
_
4 changes: 4 additions & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"

npm run test
10 changes: 10 additions & 0 deletions .prettierrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"tabWidth": 2,
"useTabs": false,
"singleQuote": false,
"semi": true,
"bracketSpacing": true,
"arrowParens": "always",
"bracketSameLine": true,
"endOfLine": "auto"
}
44 changes: 32 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# EAGLE E-commerce

<img alt="Static Badge" src="https://img.shields.io/badge/Reviewed_By-HoundCI-blue?style=flat-square">

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

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

1. **Clone the repository:**

```bash
git clone https://github.com/atlp-rwanda/eagles-ec-fe.git
```
```

2. **Change working dir to cloned repo:**

```bash
cd eagle-ec-fe
```

3. **Install dependencies:**

```bash
npm install
```

4. **Run developmnt server:**

```bash
npm run dev
```
```

## How to run test

1. **Run unit test:**
```bash

```bash
npm run test
```
2. **Tun test in watch mode
```bash
npm run test:watch
```
3. **Generate test coverage
```bash
```

2. \*\*Tun test in watch mode

```bash
npm run test:watch
```

3. \*\*Generate test coverage

```bash
npm run test:coverage
```
Write your test by creating a file with .test.tsx extetion under __test__ directory.
```

Write your test by creating a file with .test.tsx extetion under **test** directory.

```

```
9 changes: 9 additions & 0 deletions hound.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
eslint:
enabled: true
file_patterns:
- "*.js"
- "*.ts"
enabled_plugins:
- eslint-plugin-import
- eslint-plugin-prettier
- eslint-plugin:@typescript-eslint
10 changes: 5 additions & 5 deletions jest.config.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
export default {
preset: 'ts-jest',
testEnvironment: 'jest-environment-jsdom',
preset: "ts-jest",
testEnvironment: "jest-environment-jsdom",
transform: {
"^.+\\.tsx?$": "ts-jest"
"^.+\\.tsx?$": "ts-jest",
},
moduleNameMapper: {
'\\.(gif|ttf|eot|svg|png)$': '<rootDir>/test/__ mocks __/fileMock.js',
"\\.(gif|ttf|eot|svg|png)$": "<rootDir>/test/__ mocks __/fileMock.js",
},
}
};
Loading
Loading