Skip to content

Commit

Permalink
Run Prettier and fix ESLint complaints (#28)
Browse files Browse the repository at this point in the history
* Apply ESLint & Prettier on `src/`

* Fix more ESLint complaints

* No error on unmatched pattern

* Fix null assertion warnings

* Remove ts-ignore directive

Co-authored-by: George Watkins <gwwatkin@sfu.ca>
  • Loading branch information
alexnguyenn and gwwatkin committed Dec 5, 2021
1 parent 9226d0e commit 3335f3b
Show file tree
Hide file tree
Showing 14 changed files with 710 additions and 559 deletions.
4 changes: 2 additions & 2 deletions package.json
Expand Up @@ -34,8 +34,8 @@
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject",
"lint": "eslint src/**/*.{js,jsx,ts,tsx}",
"lint:fix": "eslint --fix src/**/*.{js,jsx,ts,tsx}"
"lint": "eslint --no-error-on-unmatched-pattern src/**/*.{js,jsx,ts,tsx}",
"lint:fix": "eslint --no-error-on-unmatched-pattern --fix src/**/*.{js,jsx,ts,tsx}"
},
"browserslist": {
"production": [
Expand Down
16 changes: 8 additions & 8 deletions src/App.test.tsx
@@ -1,10 +1,10 @@
import React from 'react';
import { render, screen } from '@testing-library/react';
import App from './App';
import React from "react"
import { render, screen } from "@testing-library/react"
import App from "./App"

// TODO this needs to be populated with real tests
test('renders learn react link', () => {
render(<App />);
const linkElement = screen.getByText(/learn react/i);
expect(linkElement).toBeInTheDocument();
});
test("renders learn react link", () => {
render(<App />)
const linkElement = screen.getByText(/learn react/i)
expect(linkElement).toBeInTheDocument()
})
9 changes: 4 additions & 5 deletions src/App.tsx
@@ -1,8 +1,7 @@
import React from 'react';
import React from "react"

import BaseTemplate from "./pages/BaseTemplate";
import BaseTemplate from "./pages/BaseTemplate"

const App = () => <BaseTemplate />

const App = () => <BaseTemplate />;

export default App;
export default App
70 changes: 38 additions & 32 deletions src/apiResponses.ts
@@ -1,51 +1,57 @@
import {Slices} from "./slices";
import { Slices } from "./slices"

// Different classes representing possible Api Response outcomes
class JsonParseError {
msg: string
constructor(msg : string) {
this.msg = msg
}
msg: string
constructor(msg: string) {
this.msg = msg
}
}

class ApiHttpError {
code: number
msg: string
headers: string
constructor(code: number, msg : string, headers: string) {
this.code = code
this.msg = msg
this.headers = headers
}
code: number
msg: string
headers: string
constructor(code: number, msg: string, headers: string) {
this.code = code
this.msg = msg
this.headers = headers
}
}

class CompilerError {
msg: string
errortype: string
constructor(msg: string, errortype: string){
this.msg = msg
this.errortype = errortype;
}
msg: string
errortype: string
constructor(msg: string, errortype: string) {
this.msg = msg
this.errortype = errortype
}
}

class CompilationResultSuccess {
slices: Slices
compilation_text: string
constructor(slices : Slices, compilation_text : string) {
this.slices = slices
this.compilation_text = compilation_text
}
slices: Slices
compilation_text: string
constructor(slices: Slices, compilation_text: string) {
this.slices = slices
this.compilation_text = compilation_text
}
}

class NoServerResponse {
response: string
constructor(response: string) {
this.response = response
}
response: string
constructor(response: string) {
this.response = response
}
}

type ApiResponse = null | JsonParseError | ApiHttpError | CompilationResultSuccess | CompilerError | NoServerResponse;
type ApiResponse =
| null
| JsonParseError
| ApiHttpError
| CompilationResultSuccess
| CompilerError
| NoServerResponse

export type {ApiResponse}
export type { ApiResponse }

export {JsonParseError,ApiHttpError,CompilationResultSuccess,NoServerResponse,CompilerError}
export { JsonParseError, ApiHttpError, CompilationResultSuccess, NoServerResponse, CompilerError }
11 changes: 5 additions & 6 deletions src/appState.ts
@@ -1,16 +1,15 @@
import React from "react";
import {ApiResponse} from "./apiResponses";
import React from "react"
import { ApiResponse } from "./apiResponses"

class AppState {
compilationIsLoading : boolean = false
compilationIsLoading: boolean = false
apiResponse: ApiResponse = null
}

interface AppStateProps {
appState : AppState;
setAppState : React.Dispatch<AppState>
appState: AppState
setAppState: React.Dispatch<AppState>
}

export { AppState }
export type { AppStateProps }

0 comments on commit 3335f3b

Please sign in to comment.