Skip to content

Commit

Permalink
fix inquirer and eslint issues
Browse files Browse the repository at this point in the history
  • Loading branch information
sangeetha5491 committed Apr 12, 2023
1 parent 8562006 commit 29742ef
Show file tree
Hide file tree
Showing 6 changed files with 48 additions and 31 deletions.
21 changes: 0 additions & 21 deletions .eslintrc

This file was deleted.

8 changes: 8 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"extends": "@adobe/eslint-config-aio-lib-config",
"settings": {
"jsdoc": {
"ignorePrivate": true
}
}
}
5 changes: 5 additions & 0 deletions e2e/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"rules": {
"node/no-unpublished-require": 0
}
}
23 changes: 14 additions & 9 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,30 +9,35 @@
"@adobe/aio-lib-events": "^3.0.0",
"@adobe/aio-lib-ims": "^6.0.1",
"@oclif/core": "^1.5.2",
"js-yaml": "^3.13.1"
"js-yaml": "^3.13.1",
"inquirer": "^8.2.5"
},
"repository": "adobe/aio-cli-plugin-events",
"devDependencies": {
"@adobe/eslint-config-aio-lib-config": "^2.0.0",
"@types/jest": "^27.4.1",
"acorn": "^7.2.0",
"babel-runtime": "^6.26.0",
"chalk": "^4.0.0",
"eol": "^0.9.1",
"eslint": "^7.1.0",
"eslint": "^8.38.0",
"execa": "^4.0.2",
"eslint-config-oclif": "^3.1.0",
"eslint-config-standard": "^16.0.3",
"eslint-plugin-import": "^2.20.2",
"eslint-plugin-jest": "23.13.1",
"eslint-config-standard": "^17.0.0",
"eslint-plugin-import": "^2.27.5",
"eslint-plugin-jest": "^23.20.0",
"eslint-plugin-jsdoc": "^37.9.7",
"eslint-plugin-n": "^15.7.0",
"eslint-plugin-node": "^11.1.0",
"eslint-plugin-promise": "^4.2.1",
"eslint-plugin-promise": "^6.1.1",
"eslint-plugin-standard": "^4.0.1",
"inquirer": "^7.1.0",
"jest": "^27.5.1",
"jest-haste-map": "^27.5.1",
"jest-junit": "^10.0.0",
"jest-resolve": "^27.5.1",
"oclif": "^3.2.0",
"stdout-stderr": "^0.1.13"
"stdout-stderr": "^0.1.13",
"typescript": "^5.0.4"
},
"engines": {
"node": "^14.18 || ^16.13 || >=18"
Expand All @@ -55,7 +60,7 @@
},
"main": "src/index.js",
"scripts": {
"posttest": "eslint src test e2e",
"pretest": "eslint src test e2e",
"test": "npm run unit-tests",
"unit-tests": "jest --ci",
"prepack": "oclif manifest && oclif readme --no-aliases",
Expand Down
20 changes: 20 additions & 0 deletions src/utils/validator.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,14 @@ OF ANY KIND, either express or implied. See the License for the specific languag
governing permissions and limitations under the License.
*/

/**
* Validate input against a regular expression
*
* @param {string} input to be validated
* @param {object} regex the regular expression to validate the input against
* @param {string} message error message in case of a failed validation
* @returns {string|boolean} message or error message
*/
function validator (input, regex, message) {
// eslint-disable-next-line no-useless-escape
const valid = regex
Expand All @@ -19,16 +27,28 @@ function validator (input, regex, message) {
return message
}

/**
* @param {string} input validate input for sentence type of minimum one character and maximum of 255 characters
* @returns {string|boolean} message or error message
*/
function sentenceValidatorWithMinOneChar (input) {
return validator(input, /^[\w\s-_.(),@:'`?#!]{1,255}$/,
`The input: ${input} is invalid, please use < 255 characters string with a combination of alphanumeric characters, spaces and special characters in '-_.(),@:'\`?#!'`)
}

/**
* @param {string} input validate input for sentence type
* @returns {string|boolean} message or error message
*/
function sentenceValidatorWithMinZeroChar (input) {
if (input === undefined || input === '') { return true }
return sentenceValidatorWithMinOneChar(input)
}

/**
* @param {string} input event code to be validated
* @returns {string|boolean} message or error message
*/
function eventCodeValidator (input) {
return validator(input, /^[\w-_.]{1,255}$/,
`The input: ${input} is invalid, please use at least one and < 255 characters string with a combination of alphanumeric characters and special characters in '-_.'`)
Expand Down
2 changes: 1 addition & 1 deletion test/mocks.js
Original file line number Diff line number Diff line change
Expand Up @@ -387,5 +387,5 @@ const data = {
}

module.exports = {
data: data
data
}

0 comments on commit 29742ef

Please sign in to comment.