Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Format code with prettier #1

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
100 changes: 48 additions & 52 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,73 +1,69 @@
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'
})
bar: "bar",
z: "z",
})((function () {})(), 0);

(function(){ }(), 0);

function checkYoda(){
let yoda = true;
if(true == yoda){
console.log("I am yoda")
}
}
function checkYoda() {
let yoda = true;
if (true == yoda) {
console.log("I am yoda");
}
}
6 changes: 3 additions & 3 deletions packages/demo-react/src/App.test.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { render, screen } from '@testing-library/react';
import App from './App';
import { render, screen } from "@testing-library/react";
import App from "./App";

test('renders learn react link', () => {
test("renders learn react link", () => {
render(<App />);
const linkElement = screen.getByText(/learn react/i);
expect(linkElement).toBeInTheDocument();
Expand Down
19 changes: 11 additions & 8 deletions packages/demo-react/src/components/bind.js
Original file line number Diff line number Diff line change
@@ -1,20 +1,23 @@
import React from "react";
import propTypes from 'prop-types'
import propTypes from "prop-types";

class TestingComponent extends React.Component {

handleClick(){
console.log('We must not use bind in JSX props')

}
handleClick() {
console.log("We must not use bind in JSX props");
}

render() {
<div onClick={() => this.handleClick.bind(this)} class={this.props.class_name}>Welcome to {this.props.title} TestingComponent Component</div>;
<div
onClick={() => this.handleClick.bind(this)}
class={this.props.class_name}
>
Welcome to {this.props.title} TestingComponent Component
</div>;
}
}

TestingComponent.propTypes = {
title: propTypes.string.isRequired
title: propTypes.string.isRequired,
};

export default TestingComponent;
8 changes: 5 additions & 3 deletions packages/demo-react/src/components/footer.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
import { Component } from "react";
import propTypes from 'prop-types'
import propTypes from "prop-types";

class Footer extends Component {
render() {
<div class={this.props.class_name}>Footer Component is {this.props.title}</div>;
<div class={this.props.class_name}>
Footer Component is {this.props.title}
</div>;
}
}

Footer.propTypes = {
title: propTypes.string.isRequired
title: propTypes.string.isRequired,
};

export default Footer;
8 changes: 5 additions & 3 deletions packages/demo-react/src/components/header.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
import { Component } from "react";
import propTypes from 'prop-types'
import propTypes from "prop-types";

class Header extends Component {
render() {
<div class={this.props.class_name}>Header Component is {this.props.title}</div>;
<div class={this.props.class_name}>
Header Component is {this.props.title}
</div>;
}
}

Header.propTypes = {
title: propTypes.string.isRequired
title: propTypes.string.isRequired,
};

export default Header;
8 changes: 5 additions & 3 deletions packages/demo-react/src/components/hero.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
import { Component } from "react";
import propTypes from 'prop-types'
import propTypes from "prop-types";

class Hero extends Component {
render() {
<div class={this.props.class_name}>Welcome to {this.props.title} Hero Component</div>;
<div class={this.props.class_name}>
Welcome to {this.props.title} Hero Component
</div>;
}
}

Hero.propTypes = {
title: propTypes.string.isRequired
title: propTypes.string.isRequired,
};

export default Hero;
12 changes: 7 additions & 5 deletions packages/demo-react/src/components/home.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import { Component } from "react";

type Props = {
title: string,
isHero: boolean
}
isHero: boolean,
};

class Hello extends Component<Props> {
constructor(props) {
Expand All @@ -14,13 +14,15 @@ class Hello extends Component<Props> {
}
render() {
return (
<h1 class="no-unknown-property" font-size="24" onClick={() => console.log('Should not use bind in JSX props')}>
<h1
class="no-unknown-property"
font-size="24"
onClick={() => console.log("Should not use bind in JSX props")}
>
{this.isTitleAvailable ? this.title : `Welcome to DeepSource`}
</h1>
);
}
}



export default Hello;
6 changes: 3 additions & 3 deletions packages/demo-react/src/index.css
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
body {
margin: 0;
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen',
'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue',
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Roboto", "Oxygen",
"Ubuntu", "Cantarell", "Fira Sans", "Droid Sans", "Helvetica Neue",
sans-serif;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
}

code {
font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New',
font-family: source-code-pro, Menlo, Monaco, Consolas, "Courier New",
monospace;
}
12 changes: 6 additions & 6 deletions packages/demo-react/src/index.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import React from 'react';
import ReactDOM from 'react-dom';
import './index.css';
import App from './App';
import reportWebVitals from './reportWebVitals';
import React from "react";
import ReactDOM from "react-dom";
import "./index.css";
import App from "./App";
import reportWebVitals from "./reportWebVitals";

ReactDOM.render(
<React.StrictMode>
<App />
</React.StrictMode>,
document.getElementById('root')
document.getElementById("root")
);

// If you want to start measuring performance in your app, pass a function
Expand Down
4 changes: 2 additions & 2 deletions packages/demo-react/src/reportWebVitals.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const reportWebVitals = onPerfEntry => {
const reportWebVitals = (onPerfEntry) => {
if (onPerfEntry && onPerfEntry instanceof Function) {
import('web-vitals').then(({ getCLS, getFID, getFCP, getLCP, getTTFB }) => {
import("web-vitals").then(({ getCLS, getFID, getFCP, getLCP, getTTFB }) => {
getCLS(onPerfEntry);
getFID(onPerfEntry);
getFCP(onPerfEntry);
Expand Down
2 changes: 1 addition & 1 deletion packages/demo-react/src/setupTests.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
// allows you to do things like:
// expect(element).toHaveTextContent(/react/i)
// learn more: https://github.com/testing-library/jest-dom
import '@testing-library/jest-dom';
import "@testing-library/jest-dom";
19 changes: 9 additions & 10 deletions packages/demo-typescript/src/IType.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
interface SomeType {
prop: string;
}


prop: string;
}

export function foo() {
if (false) {
// @ts-ignore: Unreachable code error
console.log('hello');
}
this.prop;
}
if (false) {
// @ts-ignore: Unreachable code error
console.log("hello");
}
this.prop;
}
30 changes: 13 additions & 17 deletions packages/demo-typescript/src/function.ts
Original file line number Diff line number Diff line change
@@ -1,21 +1,17 @@
class defaultParamLast {
constructor(public a = 10, private b: number) {
this.a = a
this.b = b
}
sum(a: number = 0,b: number ){

return a + b

}
constructor(public a = 10, private b: number) {
this.a = a;
this.b = b;
}
sum(a: number = 0, b: number) {
return a + b;
}

getPercentage(c?: number,a: number, b = 0) {
if(c){
return (a * b * 100)/c
} else {
return;
}

getPercentage(c?: number, a: number, b = 0) {
if (c) {
return (a * b * 100) / c;
} else {
return;
}
}

}
Loading