Skip to content

Commit

Permalink
Merge pull request #275 from trojs/feature/update-20240725
Browse files Browse the repository at this point in the history
Update linting, fix types
  • Loading branch information
w3nl authored Jul 25, 2024
2 parents 8055a86 + 0ea624c commit f551733
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 48 deletions.
22 changes: 20 additions & 2 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -1,7 +1,15 @@
{
"settings": {
"jsdoc": {
"mode": "typescript"
}
},
"root": true,
"extends": [
"@hckrnews/eslint-config"
"@hckrnews/eslint-config",
"plugin:import/recommended",
"plugin:n/recommended",
"plugin:jsdoc/recommended"
],
"plugins": [
"import"
Expand All @@ -15,7 +23,16 @@
}
],
"consistent-return": "warn",
"eqeqeq": "warn"
"eqeqeq": "warn",
"jsdoc/require-param-description": "off",
"jsdoc/require-property-description": "off",
"jsdoc/require-returns-description": "off",
"max-len": [
"warn",
{
"code": 120
}
]
},
"env": {
"es6": true,
Expand All @@ -24,6 +41,7 @@
"browser": true
},
"parserOptions": {
"ecmaVersion": "latest",
"sourceType": "module"
},
}
33 changes: 6 additions & 27 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,9 @@
"eslint-config-prettier": "^9.0.0",
"eslint-plugin-html": "^8.0.0",
"eslint-plugin-import": "^2.26.0",
"eslint-plugin-jsdoc": "^48.8.3",
"eslint-plugin-jsx-a11y": "^6.6.0",
"eslint-plugin-n": "^16.0.0",
"eslint-plugin-prettier": "^5.1.3",
"jscpd": "^4.0.0",
"prettier": "^3.2.5"
Expand All @@ -55,4 +57,4 @@
"type": "github",
"url": "https://github.com/sponsors/w3nl"
}
}
}
25 changes: 7 additions & 18 deletions src/validator.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ const types = {
class Validator {
/**
* Set the schema for the validator.
*
* @param {object} schema
*/
constructor(schema) {
Expand All @@ -28,10 +27,8 @@ class Validator {

/**
* Validate the an array of items.
*
* @param {array} input
*
* @return {boolean}
* @param {Array} input
* @returns {boolean}
*/
validateAll(input) {
this.errors = [];
Expand All @@ -44,10 +41,8 @@ class Validator {

/**
* Validate the input.
*
* @param {object} input
*
* @return {boolean}
* @returns {boolean}
*/
validate(input) {
this.errors = [];
Expand All @@ -56,10 +51,8 @@ class Validator {

/**
* Validate an item.
*
* @param {object} item
*
* @return {boolean}
* @returns {boolean}
*/
validateItem(item) {
this.errors = Object.entries(this.schema).filter(
Expand Down Expand Up @@ -90,7 +83,7 @@ class Validator {
* @param {string} fieldNameRaw
* @param {any} fieldType
* @param {object} item
* @return {boolean}
* @returns {boolean}
*/
filterItems(fieldNameRaw, fieldType, item) {
if (!item) {
Expand Down Expand Up @@ -147,23 +140,19 @@ class Validator {

/**
* Validate an array
*
* @param {any} value
* @param {string} fieldType
*
* @return {boolean}
* @returns {boolean}
*/
validateArray(value, fieldType) {
return value.every((item) => this.validateObject(item, fieldType));
}

/**
* Validate an object
*
* @param {any} value
* @param {string} fieldType
*
* @return {boolean}
* @returns {boolean}
*/
validateObject(value, fieldType) {
const validator = new Validator(fieldType);
Expand Down

0 comments on commit f551733

Please sign in to comment.