Skip to content

Commit

Permalink
ESLint Configuration PreCommit format and Test
Browse files Browse the repository at this point in the history
  • Loading branch information
IRUMVAEmmanuel1 committed Apr 23, 2024
1 parent b9bd13e commit 6ed0a57
Show file tree
Hide file tree
Showing 9 changed files with 150 additions and 47 deletions.
52 changes: 52 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
{
"root": true,
"extends": ["airbnb-base"],
"env": {
"node": true,
"es6": true,
"mocha": true
},
"rules": {
"quotes": ["error", "double"],
"one-var": 0,
"one-var-declaration-per-line": 0,
"new-cap": 0,
"no-unused-vars": "off",
"import/no-dynamic-require": "off",
"operator-linebreak": "off",
"arrow-body-style": "off",
"global-require": "off",
"consistent-return": 0,
"no-param-reassign": 0,
"comma-dangle": 0,
"semi": 0,
"curly": ["error", "multi-line"],
"import/no-unresolved": [
2,
{ "commonjs": true, "amd": true }
],
"no-shadow": [
"error",
{ "allow": ["req", "res", "err"] }
],
"valid-jsdoc": [
"error",
{
"requireReturn": true,
"requireReturnType": true,
"requireParamDescription": false,
"requireReturnDescription": true
}
],
"require-jsdoc": [
"error",
{
"require": {
"FunctionDeclaration": true,
"MethodDefinition": true,
"ClassDeclaration": true
}
}
]
}
}
8 changes: 8 additions & 0 deletions .prettierrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"semi": false,
"singleQuote": false,
"tabWidth": 2,
"useTabs": false,
"trailingComma": "all",
"printWidth": 50
}
3 changes: 3 additions & 0 deletions .stylelintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"extends": "@thoughtbot/stylelint-config"
}
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# eagles-ec-be

<div style="display: flex; justify-content: center;" align="center">
[![Code Style](https://img.shields.io/badge/style-hound-brightgreen.svg)](https://houndci.com)
<img src="https://codecov.io/gh/soleil00/eagles-ec-be/branch/dev/graph/badge.svg?token=9c1e8e93-1062-4e49-a58d-b2777a75fb70" alt="Codecov" >
<img alt="GitHub Actions Workflow Status" src="https://img.shields.io/github/actions/workflow/status/atlp-rwanda/eagles-ec-be/deploy.yml" >
<a href="https://codeclimate.com/github/atlp-rwanda/eagles-ec-be/maintainability"><img src="https://api.codeclimate.com/v1/badges/dfe8454356fb9da65407/maintainability" /></a>
Expand Down
13 changes: 13 additions & 0 deletions hound.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
fail_on_violations: true

scss:
enabled: false

stylelint:
config_file: .stylelintrc.json
enabled: true

eslint:
enabled: true
version: 8.57.0
config_file: .eslintrc
16 changes: 8 additions & 8 deletions index.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import sequelize, { connect } from "./src/config/dbConnection";
import { env } from "./src/utils/env";
import app from "./src/utils/server";
import sequelize, { connect } from "./src/config/dbConnection"
import { env } from "./src/utils/env"
import app from "./src/utils/server"

app.listen(env.port, async () => {
await connect();
await connect()
await sequelize
.sync()
.then(() => {
console.log(` db synced and server is running on port ${env.port}`);
console.log(" db synced and server is running")
})
.catch((error: any) => {
console.log(error.message);
});
});
console.log(error.message)
})
})
23 changes: 22 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,24 @@
"lint:fix": "npx eslint --fix .",
"test": "cross-env NODE_ENV=test jest --detectOpenHandles --coverage"
},
"lint-staged": {
".ts": [
"npm run lint:fix"
],
"**/*": "prettier --write"
},
"eslintConfig": {
"extends": [
"react-app",
"react-app/jest",
"prettier"
]
},
"husky": {
"hooks": {
"pre-commit": "npm run lint-staged"
}
},
"author": "atlp",
"license": "MIT",
"devDependencies": {
Expand Down Expand Up @@ -58,6 +76,9 @@
"pg": "^8.11.5",
"pg-hstore": "^2.3.4",
"sequelize": "^6.37.2",
"swagger-ui-express": "^5.0.0"
"swagger-ui-express": "^5.0.0",
"prettier": "3.2.5",
"lint-staged": "^15.2.2",
"husky": "^9.0.11"
}
}
6 changes: 3 additions & 3 deletions src/sequelize/migrations/20240416115110-create-user.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,10 @@ module.exports = {
allowNull: false,
type: Sequelize.DATE,
},
});
})
},

async down(queryInterface, Sequelize) {
await queryInterface.describeTable("users");
await queryInterface.describeTable("users")
},
};
}
75 changes: 40 additions & 35 deletions src/sequelize/migrations/20240418083442-UserTests.js
Original file line number Diff line number Diff line change
@@ -1,44 +1,49 @@
/** @type {import('sequelize-cli').Migration} */
module.exports = {
async up(queryInterface, Sequelize) {
await queryInterface.createTable("usersTests", {
id: {
allowNull: false,
autoIncrement: true,
primaryKey: true,
type: Sequelize.INTEGER,
},
name: {
type: Sequelize.STRING,
allowNull: false,
},
username: {
type: Sequelize.STRING,
allowNull: false,
},
email: {
type: Sequelize.STRING,
allowNull: false,
validate: {
isEmail: true,
await queryInterface.createTable(
"usersTests",
{
id: {
allowNull: false,
autoIncrement: true,
primaryKey: true,
type: Sequelize.INTEGER,
},
name: {
type: Sequelize.STRING,
allowNull: false,
},
username: {
type: Sequelize.STRING,
allowNull: false,
},
email: {
type: Sequelize.STRING,
allowNull: false,
validate: {
isEmail: true,
},
},
password: {
type: Sequelize.STRING,
allowNull: false,
},
createdAt: {
allowNull: false,
type: Sequelize.DATE,
},
updatedAt: {
allowNull: false,
type: Sequelize.DATE,
},
},
password: {
type: Sequelize.STRING,
allowNull: false,
},
createdAt: {
allowNull: false,
type: Sequelize.DATE,
},
updatedAt: {
allowNull: false,
type: Sequelize.DATE,
},
});
)
},

async down(queryInterface, Sequelize) {
await queryInterface.describeTable("usersTests");
await queryInterface.describeTable(
"usersTests",
)
},
};
}

0 comments on commit 6ed0a57

Please sign in to comment.