Skip to content

Commit

Permalink
eslint file added
Browse files Browse the repository at this point in the history
  • Loading branch information
rakesh-paulraj committed Jan 16, 2024
1 parent ac2681c commit 813e566
Show file tree
Hide file tree
Showing 2 changed files with 117 additions and 79 deletions.
38 changes: 38 additions & 0 deletions src/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
{
"env": {
"browser": true,
"es2021": true
},
"extends": [
"eslint:recommended",
"plugin:@typescript-eslint/recommended"
],
"overrides": [
{
"env": {
"node": true
},
"files": [
".eslintrc.{js,cjs}"
],
"parserOptions": {
"sourceType": "script"
}
}
],
"parser": "@typescript-eslint/parser",
"parserOptions": {
"ecmaVersion": "latest",
"sourceType": "module"
},
"plugins": [
"@typescript-eslint"
],
"rules": {
"indent": ["error", 4],
"linebreak-style": ["error", "windows"],
"quotes": ["error", "double"],
"semi": ["error", "always"]
}
}

158 changes: 79 additions & 79 deletions src/utils/utilityFunctions.ts
Original file line number Diff line number Diff line change
@@ -1,79 +1,79 @@
export const isIdentical = (strOne: string, strTwo: string) => {
strOne = strOne.trim();
strTwo = strTwo.trim();
if (strOne.toLowerCase() === strTwo.toLowerCase()) {
return true;
}
return false;
};

export const isAlpha = (str: string) => {
if (/^[a-zA-Z]+$/.test(str)) {
return true;
}
return false;
};

export const isEmpty = (value: string) => {
value = value.trim();
return value.length == 0;
};

export const isAlphaNumeric = (str: string) => {
if (/^[a-zA-Z0-9]+$/.test(str)) {
return true;
}
return false;
};

export const isValidEmail = (email: string) => {
// regular expression to match valid email addresses
var pattern = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
// match the pattern against the email string
return pattern.test(email);
};

export const countWords = (str: string) => {
// split the string into an array of words
var words = str.split(" ");
// return the length of the array
return words.length;
};

export const isAvailable = (str: string, word: string) => {
if (str.indexOf(word) !== -1) {
return true;
}
return false;
};

export const countOccurrences = (str: string, word: string) => {
// split the string into an array of words
var words = str.split(" ");
// initialize a counter variable
var count = 0;
// loop through the array of words
for (var i = 0; i < words.length; i++) {
// if the current word matches the target word, increment the counter
if (words[i] === word) {
count++;
}
}
// return the count
return count;
};

export const isPasswordStrong = (password: string) => {
// define a regular expression that matches a strong password
var strongRegex =
/^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[@$!%*?&])[A-Za-z\d@$!%*?&]{8,}$/;
// test the password against the regular expression
return strongRegex.test(password);
};

export const isURL = (str: string) => {
// define a regular expression that matches a URL format
var urlRegex = /^(?:\w+:)?\/\/([^\s\.]+\.\S{2}|localhost[\:?\d]*)\S*$/;
// test the string against the regular expression
return urlRegex.test(str);
};
export const isIdentical = (strOne: string, strTwo: string) => {
strOne = strOne.trim();
strTwo = strTwo.trim();
if (strOne.toLowerCase() === strTwo.toLowerCase()) {
return true;
}
return false;
};

export const isAlpha = (str: string) => {
if (/^[a-zA-Z]+$/.test(str)) {
return true;
}
return false;
};

export const isEmpty = (value: string) => {
value = value.trim();
return value.length == 0;
};

export const isAlphaNumeric = (str: string) => {
if (/^[a-zA-Z0-9]+$/.test(str)) {
return true;
}
return false;
};

export const isValidEmail = (email: string) => {
// regular expression to match valid email addresses
const pattern = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
// match the pattern against the email string
return pattern.test(email);
};

export const countWords = (str: string) => {
// split the string into an array of words
const words = str.split(" ");
// return the length of the array
return words.length;
};

export const isAvailable = (str: string, word: string) => {
if (str.indexOf(word) !== -1) {
return true;
}
return false;
};

export const countOccurrences = (str: string, word: string) => {
// split the string into an array of words
const words = str.split(" ");
// initialize a counter variable
let count = 0;
// loop through the array of words
for (let i = 0; i < words.length; i++) {
// if the current word matches the target word, increment the counter
if (words[i] === word) {
count++;
}
}
// return the count
return count;
};

export const isPasswordStrong = (password: string) => {
// define a regular expression that matches a strong password
const strongRegex =
/^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[@$!%*?&])[A-Za-z\d@$!%*?&]{8,}$/;
// test the password against the regular expression
return strongRegex.test(password);
};

export const isURL = (str: string) => {
// define a regular expression that matches a URL format
const urlRegex = /^(?:\w+:)?\/\/([^\s\.]+\.\S{2}|localhost[\:?\d]*)\S*$/;
// test the string against the regular expression
return urlRegex.test(str);
};

0 comments on commit 813e566

Please sign in to comment.