From 739ca37de3d8c3cb09ca215ae09ced57ef62ef27 Mon Sep 17 00:00:00 2001
From: "deepsource-autofix[bot]"
<62050782+deepsource-autofix[bot]@users.noreply.github.com>
Date: Sun, 9 May 2021 10:47:22 +0000
Subject: [PATCH] Format code with prettier
This commit fixes the style issues introduced in 663c251 according to the output
from prettier.
Details: https://deepsource.io/gh/srijan-deepsource/demo-javascript/transform/ea1020ee-5e3a-4393-a4d1-e11f9926a7b1/
---
index.js | 100 +++++++++---------
packages/demo-react/src/App.test.js | 6 +-
packages/demo-react/src/components/bind.js | 19 ++--
packages/demo-react/src/components/footer.js | 8 +-
packages/demo-react/src/components/header.js | 8 +-
packages/demo-react/src/components/hero.js | 8 +-
packages/demo-react/src/components/home.js | 12 ++-
packages/demo-react/src/index.css | 6 +-
packages/demo-react/src/index.js | 12 +--
packages/demo-react/src/reportWebVitals.js | 4 +-
packages/demo-react/src/setupTests.js | 2 +-
packages/demo-typescript/src/IType.ts | 19 ++--
packages/demo-typescript/src/function.ts | 30 +++---
packages/demo-typescript/src/index.ts | 31 +++---
packages/demo-typescript/tsconfig.json | 12 +--
.../demo-vue/src/components/HelloWorld.vue | 10 +-
16 files changed, 141 insertions(+), 146 deletions(-)
diff --git a/index.js b/index.js
index 6c6d6b10..86cbae45 100644
--- a/index.js
+++ b/index.js
@@ -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")
- }
-}
\ No newline at end of file
+function checkYoda() {
+ let yoda = true;
+ if (true == yoda) {
+ console.log("I am yoda");
+ }
+}
diff --git a/packages/demo-react/src/App.test.js b/packages/demo-react/src/App.test.js
index 1f03afee..9382b9ad 100644
--- a/packages/demo-react/src/App.test.js
+++ b/packages/demo-react/src/App.test.js
@@ -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();
const linkElement = screen.getByText(/learn react/i);
expect(linkElement).toBeInTheDocument();
diff --git a/packages/demo-react/src/components/bind.js b/packages/demo-react/src/components/bind.js
index 512f6315..2d000b1e 100644
--- a/packages/demo-react/src/components/bind.js
+++ b/packages/demo-react/src/components/bind.js
@@ -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() {
-
this.handleClick.bind(this)} class={this.props.class_name}>Welcome to {this.props.title} TestingComponent Component
;
+ this.handleClick.bind(this)}
+ class={this.props.class_name}
+ >
+ Welcome to {this.props.title} TestingComponent Component
+
;
}
}
TestingComponent.propTypes = {
- title: propTypes.string.isRequired
+ title: propTypes.string.isRequired,
};
export default TestingComponent;
diff --git a/packages/demo-react/src/components/footer.js b/packages/demo-react/src/components/footer.js
index 5eb089b8..30e3a8d3 100644
--- a/packages/demo-react/src/components/footer.js
+++ b/packages/demo-react/src/components/footer.js
@@ -1,14 +1,16 @@
import { Component } from "react";
-import propTypes from 'prop-types'
+import propTypes from "prop-types";
class Footer extends Component {
render() {
- Footer Component is {this.props.title}
;
+
+ Footer Component is {this.props.title}
+
;
}
}
Footer.propTypes = {
- title: propTypes.string.isRequired
+ title: propTypes.string.isRequired,
};
export default Footer;
diff --git a/packages/demo-react/src/components/header.js b/packages/demo-react/src/components/header.js
index 499d5dd1..77a4567a 100644
--- a/packages/demo-react/src/components/header.js
+++ b/packages/demo-react/src/components/header.js
@@ -1,14 +1,16 @@
import { Component } from "react";
-import propTypes from 'prop-types'
+import propTypes from "prop-types";
class Header extends Component {
render() {
- Header Component is {this.props.title}
;
+
+ Header Component is {this.props.title}
+
;
}
}
Header.propTypes = {
- title: propTypes.string.isRequired
+ title: propTypes.string.isRequired,
};
export default Header;
diff --git a/packages/demo-react/src/components/hero.js b/packages/demo-react/src/components/hero.js
index 3859e281..8141845f 100644
--- a/packages/demo-react/src/components/hero.js
+++ b/packages/demo-react/src/components/hero.js
@@ -1,14 +1,16 @@
import { Component } from "react";
-import propTypes from 'prop-types'
+import propTypes from "prop-types";
class Hero extends Component {
render() {
- Welcome to {this.props.title} Hero Component
;
+
+ Welcome to {this.props.title} Hero Component
+
;
}
}
Hero.propTypes = {
- title: propTypes.string.isRequired
+ title: propTypes.string.isRequired,
};
export default Hero;
diff --git a/packages/demo-react/src/components/home.js b/packages/demo-react/src/components/home.js
index 9b05f17b..a550ca4e 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,13 +14,15 @@ class Hello extends Component {
}
render() {
return (
- console.log('Should not use bind in JSX props')}>
+ console.log("Should not use bind in JSX props")}
+ >
{this.isTitleAvailable ? this.title : `Welcome to DeepSource`}
);
}
}
-
-
export default Hello;
diff --git a/packages/demo-react/src/index.css b/packages/demo-react/src/index.css
index ec2585e8..4a1df4db 100644
--- a/packages/demo-react/src/index.css
+++ b/packages/demo-react/src/index.css
@@ -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;
}
diff --git a/packages/demo-react/src/index.js b/packages/demo-react/src/index.js
index ef2edf8e..ad9cbbbf 100644
--- a/packages/demo-react/src/index.js
+++ b/packages/demo-react/src/index.js
@@ -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(
,
- document.getElementById('root')
+ document.getElementById("root")
);
// If you want to start measuring performance in your app, pass a function
diff --git a/packages/demo-react/src/reportWebVitals.js b/packages/demo-react/src/reportWebVitals.js
index 5253d3ad..9ecd33f9 100644
--- a/packages/demo-react/src/reportWebVitals.js
+++ b/packages/demo-react/src/reportWebVitals.js
@@ -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);
diff --git a/packages/demo-react/src/setupTests.js b/packages/demo-react/src/setupTests.js
index 8f2609b7..1dd407a6 100644
--- a/packages/demo-react/src/setupTests.js
+++ b/packages/demo-react/src/setupTests.js
@@ -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";
diff --git a/packages/demo-typescript/src/IType.ts b/packages/demo-typescript/src/IType.ts
index 8a8c0cd7..55ddc35d 100644
--- a/packages/demo-typescript/src/IType.ts
+++ b/packages/demo-typescript/src/IType.ts
@@ -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;
- }
\ No newline at end of file
+ if (false) {
+ // @ts-ignore: Unreachable code error
+ console.log("hello");
+ }
+ this.prop;
+}
diff --git a/packages/demo-typescript/src/function.ts b/packages/demo-typescript/src/function.ts
index 9708cf97..b5aec580 100644
--- a/packages/demo-typescript/src/function.ts
+++ b/packages/demo-typescript/src/function.ts
@@ -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;
}
}
-
+}
diff --git a/packages/demo-typescript/src/index.ts b/packages/demo-typescript/src/index.ts
index 00639d23..854cce1e 100644
--- a/packages/demo-typescript/src/index.ts
+++ b/packages/demo-typescript/src/index.ts
@@ -1,20 +1,19 @@
class SampleClass {
- files = {}
- public static get myField1() {
- return 1;
+ files = {};
+ public static get myField1() {
+ return 1;
+ }
+
+ private get ["myField2"]() {
+ const x = { ...this.files } as T;
+ if (false) {
+ // @ts-ignore: Unreachable code error
+ return "hello world";
}
-
- private get ['myField2']() {
- const x = { ...this.files } as T;
- if (false) {
- // @ts-ignore: Unreachable code error
- return 'hello world';
- } if(x){
- return x
- }else {
- return 'hello world'
- }
-
+ if (x) {
+ return x;
+ } else {
+ return "hello world";
}
}
-
\ No newline at end of file
+}
diff --git a/packages/demo-typescript/tsconfig.json b/packages/demo-typescript/tsconfig.json
index 0eeaea84..85f56e9a 100644
--- a/packages/demo-typescript/tsconfig.json
+++ b/packages/demo-typescript/tsconfig.json
@@ -4,8 +4,8 @@
/* Basic Options */
// "incremental": true, /* Enable incremental compilation */
- "target": "es5", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019', 'ES2020', or 'ESNEXT'. */
- "module": "commonjs", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', 'es2020', or 'ESNext'. */
+ "target": "es5" /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019', 'ES2020', or 'ESNEXT'. */,
+ "module": "commonjs" /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', 'es2020', or 'ESNext'. */,
// "lib": [], /* Specify library files to be included in the compilation. */
// "allowJs": true, /* Allow javascript files to be compiled. */
// "checkJs": true, /* Report errors in .js files. */
@@ -25,7 +25,7 @@
// "isolatedModules": true, /* Transpile each file as a separate module (similar to 'ts.transpileModule'). */
/* Strict Type-Checking Options */
- "strict": true, /* Enable all strict type-checking options. */
+ "strict": true /* Enable all strict type-checking options. */,
// "noImplicitAny": true, /* Raise error on expressions and declarations with an implied 'any' type. */
// "strictNullChecks": true, /* Enable strict null checks. */
// "strictFunctionTypes": true, /* Enable strict checking of function types. */
@@ -50,7 +50,7 @@
// "typeRoots": [], /* List of folders to include type definitions from. */
// "types": [], /* Type declaration files to be included in compilation. */
// "allowSyntheticDefaultImports": true, /* Allow default imports from modules with no default export. This does not affect code emit, just typechecking. */
- "esModuleInterop": true, /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */
+ "esModuleInterop": true /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */,
// "preserveSymlinks": true, /* Do not resolve the real path of symlinks. */
// "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */
@@ -65,7 +65,7 @@
// "emitDecoratorMetadata": true, /* Enables experimental support for emitting type metadata for decorators. */
/* Advanced Options */
- "skipLibCheck": true, /* Skip type checking of declaration files. */
- "forceConsistentCasingInFileNames": true /* Disallow inconsistently-cased references to the same file. */
+ "skipLibCheck": true /* Skip type checking of declaration files. */,
+ "forceConsistentCasingInFileNames": true /* Disallow inconsistently-cased references to the same file. */
}
}
diff --git a/packages/demo-vue/src/components/HelloWorld.vue b/packages/demo-vue/src/components/HelloWorld.vue
index 288a05d4..793a5b33 100644
--- a/packages/demo-vue/src/components/HelloWorld.vue
+++ b/packages/demo-vue/src/components/HelloWorld.vue
@@ -58,20 +58,14 @@
vue-devtools
- vue-loader
+ vue-loader
- awesome-vue