diff --git a/index.js b/index.js index b4cf9bf8..dbdc1a87 100644 --- a/index.js +++ b/index.js @@ -1,85 +1,85 @@ -function isEven(x){ - if(x = 2 || x % 2 == 0){ - console.log(`${x} is even`) - } else - console.log(`${x} is odd`) +function isEven(x) { + if ((x = 2 || x % 2 == 0)) { + console.log(`${x} is even`); + } else console.log(`${x} is odd`); } -function isNumber(num){ - let x = undefined - x= num % 2 - if(false) { - console.log("Number is false") - } else if (!!x) { - console.log(`Number: ${x}`) - } else if(2 == x){} +function isNumber(num) { + let x = undefined; + x = num % 2; + if (false) { + console.log("Number is false"); + } else if (!!x) { + console.log(`Number: ${x}`); + } else if (2 == x) { + } } function isTruthy(x) { - debugger; - return Boolean(x); -}; + debugger; + return Boolean(x); +} function area(r) { - let math = Math() - return math.PI * r * r; + let math = Math(); + return math.PI * r * r; } -function isFooAvailable(obj){ - console.log(`Value of obj[foo]: ${obj['foo']}`) - return obj.hasOwnProperty('foo') +function isFooAvailable(obj) { + console.log(`Value of obj[foo]: ${obj["foo"]}`); + return obj.hasOwnProperty("foo"); } -function findFooBar(){ - var re = /=foo bar/; - re.test('foobar') +function findFooBar() { + var re = /=foo bar/; + re.test("foobar"); } -function consoleFoo(num){ - while((num != 3)){ - break; - console.log(num--) - } - +function consoleFoo(num) { + while (num != 3) { + break; + console.log(num--); + } } -function isGreaterThan(arr, x){ - if(Array.isArray(arr)){ - arr.map((n) => { - return !(n > x) ? n : arguments.callee(n-1) * n; - }); - }; +function isGreaterThan(arr, x) { + if (Array.isArray(arr)) { + arr.map((n) => { + return !(n > x) ? n : arguments.callee(n - 1) * n; + }); + } } -function callHiEveryMinutes(x){ - if(!window && x){ - setTimeout("alert('Hi')", x * 1000) - - } else window.setTimeout("alert('Hi')", x * 1000) +function callHiEveryMinutes(x) { + if (!window && x) { + setTimeout("alert('Hi')", x * 1000); + } else window.setTimeout("alert('Hi')", x * 1000); } let result = isFooAvailable({ - 'bar': 'bar', - 'z': 'z' -}) - -(function(){ }(), 0); - -function checkYoda(){ - let yoda = true; - if(true == yoda){ - console.log("I am yoda") - } + bar: "bar", + z: "z", +})((function () {})(), 0); + +function checkYoda() { + let yoda = true; + if (true == yoda) { + console.log("I am yoda"); + } } -const crypto = require('crypto') +const crypto = require("crypto"); -function getEncryptedKey(){ - const hash = crypto.createCipheriv('aes-192-ecb', Buffer.from(ENCRYPTION_KEY), iv); - return hash +function getEncryptedKey() { + const hash = crypto.createCipheriv( + "aes-192-ecb", + Buffer.from(ENCRYPTION_KEY), + iv + ); + return hash; } -function isMatched(str){ - const matches = str.match(/hasTheMagic/)[0] ? process(str) : null; - return matches +function isMatched(str) { + const matches = str.match(/hasTheMagic/)[0] ? process(str) : null; + return matches; } diff --git a/packages/demo-react/src/components/home.js b/packages/demo-react/src/components/home.js index 75d1bd81..4c15328f 100644 --- a/packages/demo-react/src/components/home.js +++ b/packages/demo-react/src/components/home.js @@ -2,8 +2,8 @@ import { Component } from "react"; type Props = { title: string, - isHero: boolean -} + isHero: boolean, +}; class Hello extends Component { constructor(props) { @@ -14,7 +14,11 @@ class Hello extends Component { } render() { return ( -

console.log('Should not use bind in JSX props')}> +

console.log("Should not use bind in JSX props")} + > Unsafe Linking in React {this.isTitleAvailable ? this.title : `Welcome to DeepSource`}

@@ -22,6 +26,4 @@ class Hello extends Component { } } - - export default Hello; diff --git a/packages/demo-typescript/src/function.ts b/packages/demo-typescript/src/function.ts index 6a13e674..319e2f5a 100644 --- a/packages/demo-typescript/src/function.ts +++ b/packages/demo-typescript/src/function.ts @@ -1,20 +1,19 @@ class Calculator { - constructor(public a: unknown, private b: any){ - this.a = a - this.b = b - } + constructor(public a: unknown, private b: any) { + this.a = a; + this.b = b; + } - sum(a: any = 0, b: number ){ + sum(a: any = 0, b: number) { return a + b; -} + } - getPercentage(c?: any,a: unknown, b = 0) { - if(c){ - // @ts-ignore - return (a * b * 100)/c - } else { - return; - } - + getPercentage(c?: any, a: unknown, b = 0) { + if (c) { + // @ts-ignore + return (a * b * 100) / c; + } else { + return; } -} \ No newline at end of file + } +}