@react-pakistan/util-functions 1.7.33 → 1.8.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,5 @@
1
1
  "use strict";
2
+ /* eslint-disable @typescript-eslint/no-explicit-any */
2
3
  var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
4
  function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
5
  return new (P || (P = Promise))(function (resolve, reject) {
@@ -11,7 +12,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
11
12
  Object.defineProperty(exports, "__esModule", { value: true });
12
13
  exports.basicGet = void 0;
13
14
  const basicGet = (url) => (opts = {}) => __awaiter(void 0, void 0, void 0, function* () {
14
- const headers = !!opts.headers ? opts.headers : {};
15
+ const headers = opts.headers ? opts.headers : {};
15
16
  headers['Content-Type'] = 'application/json';
16
17
  const response = yield fetch(url, Object.assign({ headers, method: 'GET' }, opts));
17
18
  return response.json();
@@ -1,4 +1,5 @@
1
1
  "use strict";
2
+ /* eslint-disable @typescript-eslint/no-explicit-any */
2
3
  var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
4
  function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
5
  return new (P || (P = Promise))(function (resolve, reject) {
@@ -11,7 +12,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
11
12
  Object.defineProperty(exports, "__esModule", { value: true });
12
13
  exports.basicPost = void 0;
13
14
  const basicPost = (url) => (payload, opts = {}) => () => __awaiter(void 0, void 0, void 0, function* () {
14
- const headers = !!opts.headers ? opts.headers : {};
15
+ const headers = opts.headers ? opts.headers : {};
15
16
  headers['Content-Type'] = 'application/json';
16
17
  const response = yield fetch(url, Object.assign(Object.assign({ method: 'POST' }, opts), { body: JSON.stringify(payload), headers }));
17
18
  return response.json();
@@ -11,5 +11,6 @@
11
11
  /** End file docs */
12
12
  Object.defineProperty(exports, "__esModule", { value: true });
13
13
  exports.checkEvenOddLength = void 0;
14
- const checkEvenOddLength = (arr) => arr.length % 2 === 0 ? 2 : 1;
14
+ /* eslint-disable @typescript-eslint/no-explicit-any */
15
+ const checkEvenOddLength = (arr) => (arr.length % 2 === 0 ? 2 : 1);
15
16
  exports.checkEvenOddLength = checkEvenOddLength;
@@ -11,6 +11,7 @@
11
11
  /** End file docs */
12
12
  Object.defineProperty(exports, "__esModule", { value: true });
13
13
  exports.generateGrid = void 0;
14
+ /* eslint-disable @typescript-eslint/no-explicit-any */
14
15
  const generateGrid = (array) => {
15
16
  const gridMap = {
16
17
  1: {
@@ -9,7 +9,5 @@
9
9
  /** End file docs */
10
10
  Object.defineProperty(exports, "__esModule", { value: true });
11
11
  exports.getHref = void 0;
12
- const getHref = () => {
13
- return window && window.location.href;
14
- };
12
+ const getHref = () => window && window.location.href;
15
13
  exports.getHref = getHref;
@@ -9,7 +9,5 @@
9
9
  /** End file docs */
10
10
  Object.defineProperty(exports, "__esModule", { value: true });
11
11
  exports.getPathname = void 0;
12
- const getPathname = () => {
13
- return window && window.location.pathname.substring(0, window.location.pathname.length - 1);
14
- };
12
+ const getPathname = () => (window && window.location.pathname.substring(0, window.location.pathname.length - 1));
15
13
  exports.getPathname = getPathname;
@@ -13,6 +13,7 @@
13
13
  /** End file docs */
14
14
  Object.defineProperty(exports, "__esModule", { value: true });
15
15
  exports.repeatTimes = void 0;
16
+ /* eslint-disable @typescript-eslint/no-explicit-any */
16
17
  const check_even_odd_length_1 = require("./check-even-odd-length");
17
18
  const repeatTimes = (str, arr) => {
18
19
  const stringToRepeat = str.repeat(arr.length / (0, check_even_odd_length_1.checkEvenOddLength)(arr));
@@ -17,7 +17,7 @@ const resolveCurrentDate = () => {
17
17
  weekday: 'long',
18
18
  year: 'numeric',
19
19
  month: '2-digit',
20
- day: '2-digit'
20
+ day: '2-digit',
21
21
  });
22
22
  };
23
23
  exports.resolveCurrentDate = resolveCurrentDate;
@@ -4,7 +4,7 @@
4
4
  *
5
5
  * @param array Array<any> - array of content
6
6
  * @param string string - string that needs to be repeated number of array length times
7
- * @returns string - formated grid column string as per array length
7
+ * @returns string - formatted grid column string as per array length
8
8
  * @author Taimoor Khan
9
9
  * @remarks React Storybook UI
10
10
  */
@@ -5,14 +5,13 @@
5
5
  *
6
6
  * @param array Array<any> - array of content
7
7
  * @param string string - string that needs to be repeated number of array length times
8
- * @returns string - formated grid column string as per array length
8
+ * @returns string - formatted grid column string as per array length
9
9
  * @author Taimoor Khan
10
10
  * @remarks React Storybook UI
11
11
  */
12
12
  /** End file docs */
13
13
  Object.defineProperty(exports, "__esModule", { value: true });
14
14
  exports.resolveGrid = void 0;
15
- const resolveGrid = (array, gridSize) => {
16
- return `repeat(${array.length}, ${gridSize})`;
17
- };
15
+ /* eslint-disable @typescript-eslint/no-explicit-any */
16
+ const resolveGrid = (array, gridSize) => `repeat(${array.length}, ${gridSize})`;
18
17
  exports.resolveGrid = resolveGrid;
@@ -12,7 +12,5 @@
12
12
  /** End file docs */
13
13
  Object.defineProperty(exports, "__esModule", { value: true });
14
14
  exports.truncateText = void 0;
15
- const truncateText = (string, length) => {
16
- return string.substring(0, length) + '...';
17
- };
15
+ const truncateText = (string, length) => `${string.substring(0, length)}...`;
18
16
  exports.truncateText = truncateText;
@@ -13,6 +13,7 @@
13
13
  /** End file docs */
14
14
  Object.defineProperty(exports, "__esModule", { value: true });
15
15
  exports.validateEmail = void 0;
16
+ /* eslint-disable max-len, no-useless-escape */
16
17
  const emailRegex = /^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/gi;
17
18
  const validateEmail = (email) => {
18
19
  if (email.match(emailRegex)) {
package/hooks/hooks.js CHANGED
@@ -10,6 +10,7 @@
10
10
  /** End file docs */
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.useSelector = void 0;
13
+ /* eslint-disable @typescript-eslint/no-explicit-any */
13
14
  const react_redux_1 = require("react-redux");
14
15
  const useSelector = (selector) => (0, react_redux_1.useSelector)(selector, react_redux_1.shallowEqual);
15
16
  exports.useSelector = useSelector;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@react-pakistan/util-functions",
3
- "version": "1.7.33",
3
+ "version": "1.8.1",
4
4
  "description": "A library of all util functions",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -11,7 +11,7 @@
11
11
  "generate:docs": "typedoc",
12
12
  "lint": "yarn lint:ts",
13
13
  "lint:staged": "lint-staged",
14
- "lint:ts": "eslint --config .eslintrc --fix",
14
+ "lint:ts": "eslint --config .eslintrc --fix .",
15
15
  "major": "npm version major",
16
16
  "minor": "npm version minor",
17
17
  "patch": "npm version patch",
@@ -43,15 +43,15 @@
43
43
  "@babel/core": "^7.16.0",
44
44
  "@babel/eslint-parser": "^7.16.3",
45
45
  "@babel/preset-typescript": "^7.16.0",
46
- "@react-pakistan/eslint-config-shared": "^1.2.53",
47
- "@types/jest": "^27.0.2",
48
- "@types/node": "^16.11.7",
46
+ "@react-pakistan/eslint-config-shared": "^1.4.2",
47
+ "@types/jest": "^27.0.3",
48
+ "@types/node": "^16.11.11",
49
49
  "@types/react-redux": "^7.1.20",
50
- "@types/styled-components": "^5.1.15",
51
- "eslint": "^8.2.0",
50
+ "@types/styled-components": "^5.1.16",
51
+ "eslint": "^8.3.0",
52
52
  "husky": "^7.0.4",
53
- "jest": "^27.3.1",
54
- "lint-staged": "^12.0.2",
53
+ "jest": "^27.4.3",
54
+ "lint-staged": "^12.1.2",
55
55
  "react-redux": "^7.2.6",
56
56
  "rimraf": "^3.0.2",
57
57
  "ts-jest": "^27.0.7",
@@ -11,4 +11,4 @@
11
11
  * React Emoji Collection
12
12
  */
13
13
  /** End file docs */
14
- export declare const generateSitemap: (baseUrl: string, fs: any, stories: Object) => void;
14
+ export declare const generateSitemap: (baseUrl: string, fs: any, stories: Record<string, unknown>) => void;
@@ -14,6 +14,7 @@
14
14
  /** End file docs */
15
15
  Object.defineProperty(exports, "__esModule", { value: true });
16
16
  exports.generateSitemap = void 0;
17
+ /* eslint-disable @typescript-eslint/no-explicit-any */
17
18
  const generateSitemap = (baseUrl, fs, stories) => {
18
19
  let generatedSitemap = '';
19
20
  Object.keys(stories).forEach((id) => {
@@ -11,6 +11,7 @@
11
11
  /** End file docs */
12
12
  Object.defineProperty(exports, "__esModule", { value: true });
13
13
  exports.generateReactEmojis = void 0;
14
+ /* eslint-disable @typescript-eslint/no-explicit-any */
14
15
  const react_emoji_story_template_1 = require("./react-emoji-story-template");
15
16
  const generateReactEmojis = (fs) => {
16
17
  const emojiDir = './assets/';
@@ -10,6 +10,7 @@
10
10
  /** End file docs */
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.generateReactEmojiScript = void 0;
13
+ /* eslint-disable @typescript-eslint/no-explicit-any */
13
14
  const generateReactEmojiScript = (fs) => {
14
15
  const svgDir = './assets/';
15
16
  const saveDir = './scripts/';
@@ -11,6 +11,7 @@
11
11
  /** End file docs */
12
12
  Object.defineProperty(exports, "__esModule", { value: true });
13
13
  exports.generateReactIcons = void 0;
14
+ /* eslint-disable @typescript-eslint/no-explicit-any */
14
15
  const react_icon_story_template_1 = require("./react-icon-story-template");
15
16
  const generateReactIcons = (fs) => {
16
17
  const iconDir = './assets/';
@@ -10,6 +10,7 @@
10
10
  /** End file docs */
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.generateReactIconScript = void 0;
13
+ /* eslint-disable @typescript-eslint/no-explicit-any */
13
14
  const generateReactIconScript = (fs) => {
14
15
  const svgDir = './assets/';
15
16
  const saveDir = './scripts/';
@@ -11,6 +11,7 @@
11
11
  /** End file docs */
12
12
  Object.defineProperty(exports, "__esModule", { value: true });
13
13
  exports.generateReactLogos = void 0;
14
+ /* eslint-disable @typescript-eslint/no-explicit-any */
14
15
  const react_logo_story_template_1 = require("./react-logo-story-template");
15
16
  const generateReactLogos = (fs) => {
16
17
  const logoDir = './assets/';
@@ -10,6 +10,7 @@
10
10
  /** End file docs */
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.generateReactLogoScript = void 0;
13
+ /* eslint-disable @typescript-eslint/no-explicit-any */
13
14
  const generateReactLogoScript = (fs) => {
14
15
  const svgDir = './assets/';
15
16
  const saveDir = './scripts/';
@@ -17,4 +17,3 @@ exports.tablet = '';
17
17
  exports.laptop = '';
18
18
  exports.laptopL = '';
19
19
  exports.desktop = '';
20
- ;
@@ -15,7 +15,7 @@ export interface IColors {
15
15
  [key: string]: string;
16
16
  }
17
17
  export interface IMisc {
18
- [key: string]: any;
18
+ [key: string]: string | number | boolean;
19
19
  }
20
20
  export interface IHeadingStyle {
21
21
  fontFamily: string;