fixing linting for learneth

pull/4771/head
lianahus 7 months ago
parent 46fed5488b
commit d0dd8a27a2
  1. 4
      apps/learneth/src/redux/hooks.ts
  2. 8
      apps/learneth/src/redux/models/loading.ts
  3. 40
      apps/learneth/src/redux/models/remixide.ts
  4. 26
      apps/learneth/src/redux/models/workshop.ts
  5. 6
      apps/learneth/src/redux/store.ts
  6. 8
      apps/learneth/src/remix-client.ts

@ -1,5 +1,5 @@
import {useDispatch, type TypedUseSelectorHook, useSelector} from 'react-redux'
import {type AppDispatch, type RootState} from './store'
import { useDispatch, type TypedUseSelectorHook, useSelector } from 'react-redux'
import { type AppDispatch, type RootState } from './store'
export const useAppDispatch: () => AppDispatch = useDispatch
export const useAppSelector: TypedUseSelectorHook<RootState> = useSelector

@ -1,11 +1,11 @@
import {type ModelType} from '../store'
import { type ModelType } from '../store'
const Model: ModelType = {
namespace: 'loading',
state: {screen: true},
state: { screen: true },
reducers: {
save(state, {payload}) {
return {...state, ...payload}
save(state, { payload }) {
return { ...state, ...payload }
},
},
effects: {},

@ -1,7 +1,7 @@
import {toast} from 'react-toastify'
import {type ModelType} from '../store'
import { toast } from 'react-toastify'
import { type ModelType } from '../store'
import remixClient from '../../remix-client'
import {router} from '../../App'
import { router } from '../../App'
function getFilePath(file: string): string {
const name = file.split('/')
@ -17,12 +17,12 @@ const Model: ModelType = {
// theme: '',
},
reducers: {
save(state, {payload}) {
return {...state, ...payload}
save(state, { payload }) {
return { ...state, ...payload }
},
},
effects: {
*connect(_, {put}) {
*connect(_, { put }) {
toast.info('connecting to the REMIX IDE')
yield put({
@ -45,7 +45,7 @@ const Model: ModelType = {
yield router.navigate('/home')
},
*displayFile({payload: step}, {select, put}) {
*displayFile({ payload: step }, { select, put }) {
let content = ''
let path = ''
if (step.solidity?.file) {
@ -73,7 +73,7 @@ const Model: ModelType = {
},
})
const {detail, selectedId} = yield select((state) => state.workshop)
const { detail, selectedId } = yield select((state) => state.workshop)
const workshop = detail[selectedId]
console.log('loading ', step, workshop)
@ -87,7 +87,7 @@ const Model: ModelType = {
yield remixClient.call('fileManager', 'switchFile', `${path}`)
yield put({
type: 'remixide/save',
payload: {errorLoadingFile: false},
payload: { errorLoadingFile: false },
})
toast.dismiss()
} catch (error) {
@ -95,7 +95,7 @@ const Model: ModelType = {
toast.error('File could not be loaded. Please try again.')
yield put({
type: 'remixide/save',
payload: {errorLoadingFile: true},
payload: { errorLoadingFile: true },
})
}
yield put({
@ -105,7 +105,7 @@ const Model: ModelType = {
},
})
},
*testStep({payload: step}, {select, put}) {
*testStep({ payload: step }, { select, put }) {
yield put({
type: 'loading/save',
payload: {
@ -116,9 +116,9 @@ const Model: ModelType = {
try {
yield put({
type: 'remixide/save',
payload: {success: false},
payload: { success: false },
})
const {detail, selectedId} = yield select((state) => state.workshop)
const { detail, selectedId } = yield select((state) => state.workshop)
const workshop = detail[selectedId]
@ -141,7 +141,7 @@ const Model: ModelType = {
if (!result) {
yield put({
type: 'remixide/save',
payload: {errors: ['Compiler failed to test this file']},
payload: { errors: ['Compiler failed to test this file']},
})
} else {
const success = result.totalFailing === 0
@ -149,7 +149,7 @@ const Model: ModelType = {
if (success) {
yield put({
type: 'remixide/save',
payload: {errors: [], success: true},
payload: { errors: [], success: true },
})
} else {
yield put({
@ -164,7 +164,7 @@ const Model: ModelType = {
console.log('TESTING ERROR', err)
yield put({
type: 'remixide/save',
payload: {errors: [String(err)]},
payload: { errors: [String(err)]},
})
}
yield put({
@ -174,7 +174,7 @@ const Model: ModelType = {
},
})
},
*showAnswer({payload: step}, {select, put}) {
*showAnswer({ payload: step }, { select, put }) {
yield put({
type: 'loading/save',
payload: {
@ -189,7 +189,7 @@ const Model: ModelType = {
const content = step.answer.content
let path = getFilePath(step.answer.file)
const {detail, selectedId} = yield select((state) => state.workshop)
const { detail, selectedId } = yield select((state) => state.workshop)
const workshop = detail[selectedId]
path = `.learneth/${workshop.name}/${step.name}/${path}`
@ -198,7 +198,7 @@ const Model: ModelType = {
} catch (err) {
yield put({
type: 'remixide/save',
payload: {errors: [String(err)]},
payload: { errors: [String(err)]},
})
}
@ -210,7 +210,7 @@ const Model: ModelType = {
},
})
},
*testSolidityCompiler(_, {put, select}) {
*testSolidityCompiler(_, { put, select }) {
try {
yield remixClient.call('solidity', 'getCompilationResult')
} catch (err) {

@ -1,10 +1,10 @@
import axios from 'axios'
import {toast} from 'react-toastify'
import { toast } from 'react-toastify'
import groupBy from 'lodash/groupBy'
import pick from 'lodash/pick'
import {type ModelType} from '../store'
import { type ModelType } from '../store'
import remixClient from '../../remix-client'
import {router} from '../../App'
import { router } from '../../App'
// const apiUrl = 'http://localhost:3001';
const apiUrl = 'https://static.220.14.12.49.clients.your-server.de:3000'
@ -17,12 +17,12 @@ const Model: ModelType = {
selectedId: '',
},
reducers: {
save(state, {payload}) {
return {...state, ...payload}
save(state, { payload }) {
return { ...state, ...payload }
},
},
effects: {
*init(_, {put}) {
*init(_, { put }) {
const cache = localStorage.getItem('workshop.state')
if (cache) {
@ -41,7 +41,7 @@ const Model: ModelType = {
})
}
},
*loadRepo({payload}, {put, select}) {
*loadRepo({ payload }, { put, select }) {
toast.info(`loading ${payload.name}/${payload.branch}`)
yield put({
@ -51,18 +51,18 @@ const Model: ModelType = {
},
})
const {list, detail} = yield select((state) => state.workshop)
const { list, detail } = yield select((state) => state.workshop)
const url = `${apiUrl}/clone/${encodeURIComponent(payload.name)}/${payload.branch}?${Math.random()}`
console.log('loading ', url)
const {data} = yield axios.get(url)
const { data } = yield axios.get(url)
const repoId = `${payload.name}-${payload.branch}`
for (let i = 0; i < data.ids.length; i++) {
const {
steps,
metadata: {
data: {steps: metadataSteps},
data: { steps: metadataSteps },
},
} = data.entities[data.ids[i]]
@ -130,8 +130,8 @@ const Model: ModelType = {
})
if (payload.id) {
const {detail, selectedId} = workshopState
const {ids, entities} = detail[selectedId]
const { detail, selectedId } = workshopState
const { ids, entities } = detail[selectedId]
for (let i = 0; i < ids.length; i++) {
const entity = entities[ids[i]]
if (entity.metadata.data.id === payload.id || i + 1 === payload.id) {
@ -141,7 +141,7 @@ const Model: ModelType = {
}
}
},
*resetAll(_, {put}) {
*resetAll(_, { put }) {
yield put({
type: 'workshop/save',
payload: {

@ -1,6 +1,6 @@
import {configureStore, createSlice, type PayloadAction, type Reducer} from '@reduxjs/toolkit'
import { configureStore, createSlice, type PayloadAction, type Reducer } from '@reduxjs/toolkit'
import createSagaMiddleware from 'redux-saga'
import {call, put, takeEvery, delay, select, all, fork, type ForkEffect} from 'redux-saga/effects'
import { call, put, takeEvery, delay, select, all, fork, type ForkEffect } from 'redux-saga/effects'
// @ts-expect-error
const context = require.context('./models', false, /\.ts$/)
@ -39,7 +39,7 @@ function createReducer(model: ModelType): Reducer {
}
const rootReducer = models.reduce((prev: any, model: ModelType) => {
return {...prev, [model.namespace]: createReducer(model)}
return { ...prev, [model.namespace]: createReducer(model) }
}, {})
function watchEffects(model: ModelType): ForkEffect {

@ -1,7 +1,7 @@
import {PluginClient} from '@remixproject/plugin'
import {createClient} from '@remixproject/plugin-webview'
import {store} from './redux/store'
import {router} from './App'
import { PluginClient } from '@remixproject/plugin'
import { createClient } from '@remixproject/plugin-webview'
import { store } from './redux/store'
import { router } from './App'
class RemixClient extends PluginClient {
constructor() {

Loading…
Cancel
Save