Skip to content

Commit 950e526

Browse files
Shadi Abu HilalShadi Abu Hilal
Shadi Abu Hilal
authored and
Shadi Abu Hilal
committed
Add eslint and semantic-release
1 parent f273319 commit 950e526

13 files changed

+9575
-1479
lines changed

.eslintignore

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
node_modules
2+
coverage
3+
docs
4+
.editorconfig
5+
.DS_Store
6+
.gitignore
7+
index.cjs

.eslintrc.json

+168
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,168 @@
1+
{
2+
"env": {
3+
"node": true,
4+
"es6": true
5+
},
6+
"parserOptions": {
7+
"ecmaVersion": "latest",
8+
"sourceType": "module"
9+
},
10+
"extends": "eslint:recommended",
11+
"rules": {
12+
"camelcase": "off",
13+
"consistent-return": "off",
14+
"vars-on-top": "off",
15+
"new-cap": "off",
16+
"no-console": "off",
17+
"no-constant-condition": "error",
18+
"no-empty": "off",
19+
"no-native-reassign": "off",
20+
"no-underscore-dangle": "off",
21+
"no-undef": [
22+
"error",
23+
{
24+
"typeof": false
25+
}
26+
],
27+
"no-process-exit": "off",
28+
"no-unused-expressions": "off",
29+
"no-regex-spaces": "off",
30+
"no-catch-shadow": "off",
31+
"no-lonely-if": "off",
32+
"brace-style": [
33+
"warn",
34+
"stroustrup"
35+
],
36+
"no-shadow": [
37+
"warn",
38+
{
39+
"allow": [
40+
"err",
41+
"done"
42+
]
43+
}
44+
],
45+
"no-unused-vars": [
46+
"warn",
47+
{
48+
"vars": "all",
49+
"varsIgnorePattern": "^internals$",
50+
"args": "none"
51+
}
52+
],
53+
"one-var": [
54+
"error",
55+
"never"
56+
],
57+
"handle-callback-err": [
58+
"error",
59+
"^(e|err|error)$"
60+
],
61+
"array-bracket-spacing": "warn",
62+
"dot-notation": "warn",
63+
"eol-last": "warn",
64+
"no-trailing-spaces": "warn",
65+
"no-eq-null": "warn",
66+
"no-extend-native": "warn",
67+
"no-redeclare": "warn",
68+
"no-loop-func": "warn",
69+
"yoda": [
70+
"warn",
71+
"never"
72+
],
73+
"sort-vars": "warn",
74+
"arrow-parens": [
75+
"error",
76+
"always"
77+
],
78+
"arrow-spacing": [
79+
"error",
80+
{
81+
"before": true,
82+
"after": true
83+
}
84+
],
85+
"quotes": [
86+
"error",
87+
"single"
88+
],
89+
"consistent-this": [
90+
"error",
91+
"self"
92+
],
93+
"new-parens": "error",
94+
"no-array-constructor": "error",
95+
"no-new-object": "error",
96+
"no-spaced-func": "error",
97+
"no-mixed-spaces-and-tabs": "error",
98+
"keyword-spacing": [
99+
"error",
100+
{
101+
"before": true,
102+
"after": true
103+
}
104+
],
105+
"semi": [
106+
"error",
107+
"always"
108+
],
109+
"semi-spacing": [
110+
"error",
111+
{
112+
"before": false,
113+
"after": true
114+
}
115+
],
116+
"space-infix-ops": "error",
117+
"space-unary-ops": [
118+
"warn",
119+
{
120+
"words": true,
121+
"nonwords": false
122+
}
123+
],
124+
"strict": [
125+
"error",
126+
"global"
127+
],
128+
"eqeqeq": "error",
129+
"curly": [
130+
"error",
131+
"all"
132+
],
133+
"no-eval": "error",
134+
"no-else-return": "error",
135+
"no-return-assign": "error",
136+
"no-new-wrappers": "error",
137+
"comma-dangle": [
138+
"error",
139+
"never"
140+
],
141+
"no-sparse-arrays": "error",
142+
"no-ex-assign": "error",
143+
"indent": [
144+
"error",
145+
4,
146+
{
147+
"SwitchCase": 1
148+
}
149+
],
150+
"space-before-function-paren": [
151+
"error",
152+
{
153+
"anonymous": "always",
154+
"named": "never"
155+
}
156+
],
157+
"func-style": [
158+
"error",
159+
"expression"
160+
],
161+
"object-curly-spacing": [
162+
"error",
163+
"always"
164+
],
165+
"no-unsafe-finally": "error",
166+
"no-useless-computed-key": "error"
167+
}
168+
}

.npmignore

+1
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,4 @@ docs/
44
.nyc_output
55
.jsdoc.json
66
README.md
7+
.releaserc.json

.releaserc.json

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"plugins": [
3+
"@semantic-release/commit-analyzer",
4+
"@semantic-release/release-notes-generator",
5+
"@semantic-release/changelog",
6+
"@semantic-release/npm",
7+
"@semantic-release/git",
8+
"@semantic-release/github"
9+
]
10+
}
11+

.vscode/extensions.json

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"recommendations": [
3+
"dbaeumer.vscode-eslint"
4+
]
5+
}

.vscode/settings.json

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"editor.codeActionsOnSave": {
3+
"source.fixAll.eslint": true
4+
},
5+
"editor.formatOnSave": false,
6+
"editor.tabSize": 4,
7+
"editor.detectIndentation": false
8+
}

docs/global.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -1286,7 +1286,7 @@ <h5 class="h5-returns">Returns:</h5>
12861286
<br class="clear">
12871287

12881288
<footer>
1289-
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.2</a> on Wed Dec 06 2023 17:48:30 GMT-0800 (Pacific Standard Time) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
1289+
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.2</a> on Wed Dec 06 2023 18:05:11 GMT-0800 (Pacific Standard Time) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
12901290
</footer>
12911291

12921292
<script>prettyPrint();</script>

docs/index.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ <h3> </h3>
7676
<br class="clear">
7777

7878
<footer>
79-
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.2</a> on Wed Dec 06 2023 17:48:30 GMT-0800 (Pacific Standard Time) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
79+
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.2</a> on Wed Dec 06 2023 18:05:11 GMT-0800 (Pacific Standard Time) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
8080
</footer>
8181

8282
<script>prettyPrint();</script>

docs/index.js.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ <h1 class="page-title">index.js</h1>
135135
<br class="clear">
136136

137137
<footer>
138-
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.2</a> on Wed Dec 06 2023 17:48:30 GMT-0800 (Pacific Standard Time) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
138+
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.2</a> on Wed Dec 06 2023 18:05:11 GMT-0800 (Pacific Standard Time) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
139139
</footer>
140140

141141
<script>prettyPrint();</script>

index.js

+13-13
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33
* @description Supported JSON content type values ['application/json', 'application/problem+json', 'application/vnd.api+json', 'application/hal+json'].
44
*/
55
const jsonContentTypes = [
6-
'application/json',
7-
'application/problem+json',
8-
'application/vnd.api+json',
6+
'application/json',
7+
'application/problem+json',
8+
'application/vnd.api+json',
99
'application/hal+json'
1010
];
1111

@@ -17,21 +17,21 @@ const jsonContentTypes = [
1717
* @param {string} req.headers."content-type" - Http request content-type header
1818
* @returns {boolean}
1919
*/
20-
export const isJsonReq = (req)=> {
20+
export const isJsonReq = (req) => {
2121
const contentType = req && req.headers && req.headers['content-type'];
2222

2323
const normalizedContentType = contentType && contentType.toLowerCase();
2424

25-
if (normalizedContentType && jsonContentTypes.some((value)=> normalizedContentType.includes(value))) {
25+
if (normalizedContentType && jsonContentTypes.some((value) => normalizedContentType.includes(value))) {
2626
return true;
2727
}
2828

2929
return false;
3030
};
3131

32-
const checkMethod = (req, method)=> {
32+
const checkMethod = (req, method) => {
3333
const normalizedReqMethod = req && req.method && req.method && req.method.toLowerCase();
34-
34+
3535
if (normalizedReqMethod === method) {
3636
return true;
3737
}
@@ -46,16 +46,16 @@ const checkMethod = (req, method)=> {
4646
* @param {string} req.method - Http request method string
4747
* @returns {boolean}
4848
*/
49-
export const isGetReq = (req)=> checkMethod(req, 'get');
49+
export const isGetReq = (req) => checkMethod(req, 'get');
5050

5151
/**
52-
* @function
52+
* @function
5353
* @description Function that check if current request is a http POST method request or not.
5454
* @param {Object} req - Http request object
5555
* @param {string} req.method - Http request method string
5656
* @returns {boolean}
5757
*/
58-
export const isPostReq = (req)=> checkMethod(req, 'post');
58+
export const isPostReq = (req) => checkMethod(req, 'post');
5959

6060
/**
6161
* @function
@@ -64,13 +64,13 @@ export const isPostReq = (req)=> checkMethod(req, 'post');
6464
* @param {string} req.method - Http request method string
6565
* @returns {boolean}
6666
*/
67-
export const isPutReq = (req)=> checkMethod(req, 'put');
67+
export const isPutReq = (req) => checkMethod(req, 'put');
6868

6969
/**
70-
* @function
70+
* @function
7171
* @description Function that check if current request is a http DELETE method request or not.
7272
* @param {Object} req - Http request object
7373
* @param {string} req.method - Http request method string
7474
* @returns {boolean}
7575
*/
76-
export const isDeleteReq = (req)=> checkMethod(req, 'delete');
76+
export const isDeleteReq = (req) => checkMethod(req, 'delete');

0 commit comments

Comments
 (0)