From 732f76a557e12892d2b3871fe78de9bd964f20d8 Mon Sep 17 00:00:00 2001 From: Akshay Nair Date: Sat, 17 Oct 2020 22:03:12 +0530 Subject: [PATCH] Cleanup --- .eslintrc.json | 6 ++++++ utils/constants.js | 8 +++++++- utils/helpers.js | 22 ++++++++++++++++++++-- utils/validations.js | 4 +--- 4 files changed, 34 insertions(+), 6 deletions(-) diff --git a/.eslintrc.json b/.eslintrc.json index 33dc25fe3..89af53aa3 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -9,6 +9,12 @@ }, "rules": { "indent": ["error", 2], + "max-len": ["error", { + "code": 100, + "ignoreStrings": true, + "ignoreTemplateLiterals": true, + "ignoreTrailingComments": true + }], "node/exports-style": ["error", "module.exports"], "node/file-extension-in-import": ["error", "always"], "node/prefer-global/buffer": ["error", "always"], diff --git a/utils/constants.js b/utils/constants.js index 086bb0f29..f3ef2b6ac 100644 --- a/utils/constants.js +++ b/utils/constants.js @@ -6,7 +6,13 @@ if (!CI) { require('dotenv').config({ path: path.resolve(`.env.${ENV}`) }); } -const { DOMAIN_USER, DOMAIN_API_KEY, DOMAIN_DOMAIN, DOMAIN_API_HOST, DOMAIN_API_PORT } = process.env; +const { + DOMAIN_USER, + DOMAIN_API_KEY, + DOMAIN_DOMAIN, + DOMAIN_API_HOST, + DOMAIN_API_PORT, +} = process.env; const IS_TEST = ENV === 'test'; diff --git a/utils/helpers.js b/utils/helpers.js index 2c1f61351..171dce8cc 100644 --- a/utils/helpers.js +++ b/utils/helpers.js @@ -8,7 +8,9 @@ const between = (min, max) => num => num >= min && num <= max; const testRegex = regex => str => !!(str && str.match(regex)); const validate = pattern => data => R.compose( - invalidPairs => invalidPairs.length ? { errors: invalidPairs, valid: false } : { errors: [], valid: true }, + invalidPairs => invalidPairs.length + ? { errors: invalidPairs, valid: false } + : { errors: [], valid: true }, R.filter(([key, { fn }]) => fn ? !fn(data[key]) : false), R.toPairs, )(pattern); @@ -30,5 +32,21 @@ const batchLazyTasks = count => tasks => tasks.reduce((batches, task) => { return [...full, [...last, task]]; }, []); -module.exports = { or, and, validate, between, testRegex, log, print, then, lazyTask, batchLazyTasks }; +const withLengthGte = n => R.compose(R.gte(R.__, n), R.length); +const withLengthEq = n => R.compose(R.equals(n), R.length); + +module.exports = { + or, + and, + validate, + between, + testRegex, + log, + print, + then, + lazyTask, + batchLazyTasks, + withLengthEq, + withLengthGte, +}; diff --git a/utils/validations.js b/utils/validations.js index ad32d88e1..cf0c872ec 100644 --- a/utils/validations.js +++ b/utils/validations.js @@ -1,8 +1,6 @@ const R = require('ramda'); const { VALID_RECORD_TYPES } = require('./constants'); -const { or, and, validate, between, testRegex } = require('./helpers'); -const withLengthGte = n => R.compose(R.gte(R.__, n), R.length); -const withLengthEq = n => R.compose(R.equals(n), R.length); +const { or, and, validate, between, testRegex, withLengthEq, withLengthGte } = require('./helpers'); const validateCnameRecord = key => and([ R.propSatisfies(R.is(String), key),