Skip to content

Commit f551733

Browse files
authored
Merge pull request #275 from trojs/feature/update-20240725
Update linting, fix types
2 parents 8055a86 + 0ea624c commit f551733

File tree

4 files changed

+36
-48
lines changed

4 files changed

+36
-48
lines changed

.eslintrc

+20-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,15 @@
11
{
2+
"settings": {
3+
"jsdoc": {
4+
"mode": "typescript"
5+
}
6+
},
27
"root": true,
38
"extends": [
4-
"@hckrnews/eslint-config"
9+
"@hckrnews/eslint-config",
10+
"plugin:import/recommended",
11+
"plugin:n/recommended",
12+
"plugin:jsdoc/recommended"
513
],
614
"plugins": [
715
"import"
@@ -15,7 +23,16 @@
1523
}
1624
],
1725
"consistent-return": "warn",
18-
"eqeqeq": "warn"
26+
"eqeqeq": "warn",
27+
"jsdoc/require-param-description": "off",
28+
"jsdoc/require-property-description": "off",
29+
"jsdoc/require-returns-description": "off",
30+
"max-len": [
31+
"warn",
32+
{
33+
"code": 120
34+
}
35+
]
1936
},
2037
"env": {
2138
"es6": true,
@@ -24,6 +41,7 @@
2441
"browser": true
2542
},
2643
"parserOptions": {
44+
"ecmaVersion": "latest",
2745
"sourceType": "module"
2846
},
2947
}

package-lock.json

+6-27
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+3-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,9 @@
3939
"eslint-config-prettier": "^9.0.0",
4040
"eslint-plugin-html": "^8.0.0",
4141
"eslint-plugin-import": "^2.26.0",
42+
"eslint-plugin-jsdoc": "^48.8.3",
4243
"eslint-plugin-jsx-a11y": "^6.6.0",
44+
"eslint-plugin-n": "^16.0.0",
4345
"eslint-plugin-prettier": "^5.1.3",
4446
"jscpd": "^4.0.0",
4547
"prettier": "^3.2.5"
@@ -55,4 +57,4 @@
5557
"type": "github",
5658
"url": "https://github.com/sponsors/w3nl"
5759
}
58-
}
60+
}

src/validator.js

+7-18
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ const types = {
1818
class Validator {
1919
/**
2020
* Set the schema for the validator.
21-
*
2221
* @param {object} schema
2322
*/
2423
constructor(schema) {
@@ -28,10 +27,8 @@ class Validator {
2827

2928
/**
3029
* Validate the an array of items.
31-
*
32-
* @param {array} input
33-
*
34-
* @return {boolean}
30+
* @param {Array} input
31+
* @returns {boolean}
3532
*/
3633
validateAll(input) {
3734
this.errors = [];
@@ -44,10 +41,8 @@ class Validator {
4441

4542
/**
4643
* Validate the input.
47-
*
4844
* @param {object} input
49-
*
50-
* @return {boolean}
45+
* @returns {boolean}
5146
*/
5247
validate(input) {
5348
this.errors = [];
@@ -56,10 +51,8 @@ class Validator {
5651

5752
/**
5853
* Validate an item.
59-
*
6054
* @param {object} item
61-
*
62-
* @return {boolean}
55+
* @returns {boolean}
6356
*/
6457
validateItem(item) {
6558
this.errors = Object.entries(this.schema).filter(
@@ -90,7 +83,7 @@ class Validator {
9083
* @param {string} fieldNameRaw
9184
* @param {any} fieldType
9285
* @param {object} item
93-
* @return {boolean}
86+
* @returns {boolean}
9487
*/
9588
filterItems(fieldNameRaw, fieldType, item) {
9689
if (!item) {
@@ -147,23 +140,19 @@ class Validator {
147140

148141
/**
149142
* Validate an array
150-
*
151143
* @param {any} value
152144
* @param {string} fieldType
153-
*
154-
* @return {boolean}
145+
* @returns {boolean}
155146
*/
156147
validateArray(value, fieldType) {
157148
return value.every((item) => this.validateObject(item, fieldType));
158149
}
159150

160151
/**
161152
* Validate an object
162-
*
163153
* @param {any} value
164154
* @param {string} fieldType
165-
*
166-
* @return {boolean}
155+
* @returns {boolean}
167156
*/
168157
validateObject(value, fieldType) {
169158
const validator = new Validator(fieldType);

0 commit comments

Comments
 (0)