Skip to content

Commit d3d01ca

Browse files
Format code with prettier
This commit fixes the style issues introduced in 663c251 according to the output from prettier. Details: https://deepsource.io/gh/moulik-deepsource/demo-javascript/transform/eb2a9492-6672-4f1d-9d88-19d88503c2cf/
1 parent 663c251 commit d3d01ca

File tree

16 files changed

+141
-146
lines changed

16 files changed

+141
-146
lines changed

index.js

Lines changed: 48 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -1,73 +1,69 @@
1-
function isEven(x){
2-
if(x = 2 || x % 2 == 0){
3-
console.log(`${x} is even`)
4-
} else
5-
console.log(`${x} is odd`)
1+
function isEven(x) {
2+
if ((x = 2 || x % 2 == 0)) {
3+
console.log(`${x} is even`);
4+
} else console.log(`${x} is odd`);
65
}
76

8-
function isNumber(num){
9-
let x = undefined
10-
x= num % 2
11-
if(false) {
12-
console.log("Number is false")
13-
} else if (!!x) {
14-
console.log(`Number: ${x}`)
15-
} else if(2 == x){}
7+
function isNumber(num) {
8+
let x = undefined;
9+
x = num % 2;
10+
if (false) {
11+
console.log("Number is false");
12+
} else if (!!x) {
13+
console.log(`Number: ${x}`);
14+
} else if (2 == x) {
15+
}
1616
}
1717

1818
function isTruthy(x) {
19-
debugger;
20-
return Boolean(x);
21-
};
19+
debugger;
20+
return Boolean(x);
21+
}
2222

2323
function area(r) {
24-
let math = Math()
25-
return math.PI * r * r;
24+
let math = Math();
25+
return math.PI * r * r;
2626
}
2727

28-
function isFooAvailable(obj){
29-
console.log(`Value of obj[foo]: ${obj['foo']}`)
30-
return obj.hasOwnProperty('foo')
28+
function isFooAvailable(obj) {
29+
console.log(`Value of obj[foo]: ${obj["foo"]}`);
30+
return obj.hasOwnProperty("foo");
3131
}
3232

33-
function findFooBar(){
34-
var re = /=foo bar/;
35-
re.test('foobar')
33+
function findFooBar() {
34+
var re = /=foo bar/;
35+
re.test("foobar");
3636
}
3737

38-
function consoleFoo(num){
39-
while((num != 3)){
40-
break;
41-
console.log(num--)
42-
}
43-
38+
function consoleFoo(num) {
39+
while (num != 3) {
40+
break;
41+
console.log(num--);
42+
}
4443
}
4544

46-
function isGreaterThan(arr, x){
47-
if(Array.isArray(arr)){
48-
arr.map((n) => {
49-
return !(n > x) ? n : arguments.callee(n-1) * n;
50-
});
51-
};
45+
function isGreaterThan(arr, x) {
46+
if (Array.isArray(arr)) {
47+
arr.map((n) => {
48+
return !(n > x) ? n : arguments.callee(n - 1) * n;
49+
});
50+
}
5251
}
5352

54-
function callHiEveryMinutes(x){
55-
if(!window && x){
56-
setTimeout("alert('Hi')", x * 1000)
57-
58-
} else window.setTimeout("alert('Hi')", x * 1000)
53+
function callHiEveryMinutes(x) {
54+
if (!window && x) {
55+
setTimeout("alert('Hi')", x * 1000);
56+
} else window.setTimeout("alert('Hi')", x * 1000);
5957
}
6058

6159
let result = isFooAvailable({
62-
'bar': 'bar',
63-
'z': 'z'
64-
})
60+
bar: "bar",
61+
z: "z",
62+
})((function () {})(), 0);
6563

66-
(function(){ }(), 0);
67-
68-
function checkYoda(){
69-
let yoda = true;
70-
if(true == yoda){
71-
console.log("I am yoda")
72-
}
73-
}
64+
function checkYoda() {
65+
let yoda = true;
66+
if (true == yoda) {
67+
console.log("I am yoda");
68+
}
69+
}

packages/demo-react/src/App.test.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
import { render, screen } from '@testing-library/react';
2-
import App from './App';
1+
import { render, screen } from "@testing-library/react";
2+
import App from "./App";
33

4-
test('renders learn react link', () => {
4+
test("renders learn react link", () => {
55
render(<App />);
66
const linkElement = screen.getByText(/learn react/i);
77
expect(linkElement).toBeInTheDocument();
Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,23 @@
11
import React from "react";
2-
import propTypes from 'prop-types'
2+
import propTypes from "prop-types";
33

44
class TestingComponent extends React.Component {
5-
6-
handleClick(){
7-
console.log('We must not use bind in JSX props')
8-
9-
}
5+
handleClick() {
6+
console.log("We must not use bind in JSX props");
7+
}
108

119
render() {
12-
<div onClick={() => this.handleClick.bind(this)} class={this.props.class_name}>Welcome to {this.props.title} TestingComponent Component</div>;
10+
<div
11+
onClick={() => this.handleClick.bind(this)}
12+
class={this.props.class_name}
13+
>
14+
Welcome to {this.props.title} TestingComponent Component
15+
</div>;
1316
}
1417
}
1518

1619
TestingComponent.propTypes = {
17-
title: propTypes.string.isRequired
20+
title: propTypes.string.isRequired,
1821
};
1922

2023
export default TestingComponent;
Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,16 @@
11
import { Component } from "react";
2-
import propTypes from 'prop-types'
2+
import propTypes from "prop-types";
33

44
class Footer extends Component {
55
render() {
6-
<div class={this.props.class_name}>Footer Component is {this.props.title}</div>;
6+
<div class={this.props.class_name}>
7+
Footer Component is {this.props.title}
8+
</div>;
79
}
810
}
911

1012
Footer.propTypes = {
11-
title: propTypes.string.isRequired
13+
title: propTypes.string.isRequired,
1214
};
1315

1416
export default Footer;
Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,16 @@
11
import { Component } from "react";
2-
import propTypes from 'prop-types'
2+
import propTypes from "prop-types";
33

44
class Header extends Component {
55
render() {
6-
<div class={this.props.class_name}>Header Component is {this.props.title}</div>;
6+
<div class={this.props.class_name}>
7+
Header Component is {this.props.title}
8+
</div>;
79
}
810
}
911

1012
Header.propTypes = {
11-
title: propTypes.string.isRequired
13+
title: propTypes.string.isRequired,
1214
};
1315

1416
export default Header;
Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,16 @@
11
import { Component } from "react";
2-
import propTypes from 'prop-types'
2+
import propTypes from "prop-types";
33

44
class Hero extends Component {
55
render() {
6-
<div class={this.props.class_name}>Welcome to {this.props.title} Hero Component</div>;
6+
<div class={this.props.class_name}>
7+
Welcome to {this.props.title} Hero Component
8+
</div>;
79
}
810
}
911

1012
Hero.propTypes = {
11-
title: propTypes.string.isRequired
13+
title: propTypes.string.isRequired,
1214
};
1315

1416
export default Hero;

packages/demo-react/src/components/home.js

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ import { Component } from "react";
22

33
type Props = {
44
title: string,
5-
isHero: boolean
6-
}
5+
isHero: boolean,
6+
};
77

88
class Hello extends Component<Props> {
99
constructor(props) {
@@ -14,13 +14,15 @@ class Hello extends Component<Props> {
1414
}
1515
render() {
1616
return (
17-
<h1 class="no-unknown-property" font-size="24" onClick={() => console.log('Should not use bind in JSX props')}>
17+
<h1
18+
class="no-unknown-property"
19+
font-size="24"
20+
onClick={() => console.log("Should not use bind in JSX props")}
21+
>
1822
{this.isTitleAvailable ? this.title : `Welcome to DeepSource`}
1923
</h1>
2024
);
2125
}
2226
}
2327

24-
25-
2628
export default Hello;

packages/demo-react/src/index.css

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
body {
22
margin: 0;
3-
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen',
4-
'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue',
3+
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Roboto", "Oxygen",
4+
"Ubuntu", "Cantarell", "Fira Sans", "Droid Sans", "Helvetica Neue",
55
sans-serif;
66
-webkit-font-smoothing: antialiased;
77
-moz-osx-font-smoothing: grayscale;
88
}
99

1010
code {
11-
font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New',
11+
font-family: source-code-pro, Menlo, Monaco, Consolas, "Courier New",
1212
monospace;
1313
}

packages/demo-react/src/index.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
1-
import React from 'react';
2-
import ReactDOM from 'react-dom';
3-
import './index.css';
4-
import App from './App';
5-
import reportWebVitals from './reportWebVitals';
1+
import React from "react";
2+
import ReactDOM from "react-dom";
3+
import "./index.css";
4+
import App from "./App";
5+
import reportWebVitals from "./reportWebVitals";
66

77
ReactDOM.render(
88
<React.StrictMode>
99
<App />
1010
</React.StrictMode>,
11-
document.getElementById('root')
11+
document.getElementById("root")
1212
);
1313

1414
// If you want to start measuring performance in your app, pass a function

packages/demo-react/src/reportWebVitals.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
const reportWebVitals = onPerfEntry => {
1+
const reportWebVitals = (onPerfEntry) => {
22
if (onPerfEntry && onPerfEntry instanceof Function) {
3-
import('web-vitals').then(({ getCLS, getFID, getFCP, getLCP, getTTFB }) => {
3+
import("web-vitals").then(({ getCLS, getFID, getFCP, getLCP, getTTFB }) => {
44
getCLS(onPerfEntry);
55
getFID(onPerfEntry);
66
getFCP(onPerfEntry);

packages/demo-react/src/setupTests.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22
// allows you to do things like:
33
// expect(element).toHaveTextContent(/react/i)
44
// learn more: https://github.com/testing-library/jest-dom
5-
import '@testing-library/jest-dom';
5+
import "@testing-library/jest-dom";

packages/demo-typescript/src/IType.ts

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
interface SomeType {
2-
prop: string;
3-
}
4-
5-
2+
prop: string;
3+
}
4+
65
export function foo() {
7-
if (false) {
8-
// @ts-ignore: Unreachable code error
9-
console.log('hello');
10-
}
11-
this.prop;
12-
}
6+
if (false) {
7+
// @ts-ignore: Unreachable code error
8+
console.log("hello");
9+
}
10+
this.prop;
11+
}
Lines changed: 13 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,17 @@
11
class defaultParamLast {
2-
constructor(public a = 10, private b: number) {
3-
this.a = a
4-
this.b = b
5-
}
6-
sum(a: number = 0,b: number ){
7-
8-
return a + b
9-
10-
}
2+
constructor(public a = 10, private b: number) {
3+
this.a = a;
4+
this.b = b;
5+
}
6+
sum(a: number = 0, b: number) {
7+
return a + b;
8+
}
119

12-
getPercentage(c?: number,a: number, b = 0) {
13-
if(c){
14-
return (a * b * 100)/c
15-
} else {
16-
return;
17-
}
18-
10+
getPercentage(c?: number, a: number, b = 0) {
11+
if (c) {
12+
return (a * b * 100) / c;
13+
} else {
14+
return;
1915
}
2016
}
21-
17+
}

0 commit comments

Comments
 (0)