linting fix

pull/5370/head
aniket-engg 3 years ago committed by Aniket
parent d1609a4ed9
commit a3e32d1baa
  1. 3
      libs/remix-ui/solidity-unit-testing/.eslintrc.json
  2. 2
      libs/remix-ui/solidity-unit-testing/src/lib/actions/solidityUnitTestingAction.ts
  3. 5
      libs/remix-ui/solidity-unit-testing/src/lib/logic/testTabLogic.ts
  4. 1
      libs/remix-ui/solidity-unit-testing/src/lib/reducers/solidityUnitTestingReducer.ts
  5. 44
      libs/remix-ui/solidity-unit-testing/src/lib/solidity-unit-testing.tsx

@ -1,6 +1,9 @@
{
"extends": ["plugin:@nrwl/nx/react", "../../../.eslintrc.json"],
"ignorePatterns": ["!**/*"],
"rules": {
"@typescript-eslint/no-explicit-any": "off"
},
"overrides": [
{
"files": ["*.ts", "*.tsx", "*.js", "*.jsx"],

@ -1,5 +1,4 @@
// const modalDialogCustom = require('../../ui/modal-dialog-custom')
const remixPath = require('path')
import remixPath from 'path'
export class TestTabLogic {
@ -75,7 +74,7 @@ export class TestTabLogic {
} catch (e: any) {
cb(e.message)
}
for (var file in files) {
for (const file in files) {
const filepath = provider && provider.type ? provider.type + '/' + file : file
if (/.(_test.sol)$/.exec(file)) tests.push(filepath)
}

@ -1 +0,0 @@
export const solidityUnitTestingReducer = (state, action) => {}

@ -1,11 +1,11 @@
import React, { useState, useRef, useEffect } from 'react' // eslint-disable-line
import { eachOfSeries } from 'async'
import { eachOfSeries } from 'async' // eslint-disable-line
import { canUseWorker, urlFromVersion } from '@remix-project/remix-solidity'
import { Renderer } from '@remix-ui/renderer' // eslint-disable-line
import { format } from 'util'
import './css/style.css'
const _paq = (window as any)._paq = (window as any)._paq || []
const _paq = (window as any)._paq = (window as any)._paq || [] // eslint-disable-line
/* eslint-disable-next-line */
export interface SolidityUnitTestingProps {}
@ -15,10 +15,9 @@ interface TestObject {
checked: boolean
}
export const SolidityUnitTesting = (props: any) => {
export const SolidityUnitTesting = (props: Record<string, any>) => {
const {helper, testTab} = props
const { testTabLogic } = testTab
const [defaultPath, setDefaultPath] = useState('tests')
@ -36,16 +35,16 @@ export const SolidityUnitTesting = (props: any) => {
const [progressBarHidden, setProgressBarHidden] = useState(true)
const [testsExecutionStoppedErrorHidden, setTestsExecutionStoppedErrorHidden] = useState(true)
let [testFiles, setTestFiles] = useState<TestObject[]>([])
const [testFiles, setTestFiles] = useState<TestObject[]>([])
const [pathOptions, setPathOptions] = useState([''])
let [selectedTests, setSelectedTests] = useState<string[]>([])
let [selectedTests, setSelectedTests] = useState<string[]>([]) // eslint-disable-line
const [inputPathValue, setInputPathValue] = useState('tests')
let [readyTestsNumber, setReadyTestsNumber] = useState(0)
let [runningTestsNumber, setRunningTestsNumber] = useState(0)
const [readyTestsNumber, setReadyTestsNumber] = useState(0)
const [runningTestsNumber, setRunningTestsNumber] = useState(0)
let hasBeenStopped = useRef(false)
const hasBeenStopped = useRef(false)
let areTestsRunning = false
let isDebugging = false
@ -53,9 +52,9 @@ export const SolidityUnitTesting = (props: any) => {
let currentErrors: any
let runningTestFileName: any
let filesContent: any = {}
const filesContent: any = {}
let testsResultByFilename:Record<string, any> = {}
const testsResultByFilename:Record<string, any> = {}
const trimTestDirInput = (input:string) => {
if (input.includes('/')) return input.split('/').map(e => e.trim()).join('/')
@ -75,7 +74,7 @@ export const SolidityUnitTesting = (props: any) => {
// Test result, which is compilation error in this case, is not cleared
if (currentErrors) {
if (Array.isArray(currentErrors) && currentErrors.length > 0) {
const errFiles = currentErrors.map(err => { if (err.sourceLocation && err.sourceLocation.file) return err.sourceLocation.file })
const errFiles = currentErrors.map(err => { if (err.sourceLocation && err.sourceLocation.file) return err.sourceLocation.file }) // eslint-disable-line
if (errFiles.includes(file)) return
} else if (currentErrors.sourceLocation && currentErrors.sourceLocation.file && currentErrors.sourceLocation.file === file) return
}
@ -102,7 +101,7 @@ export const SolidityUnitTesting = (props: any) => {
useEffect(() => {
updateDirList('/')
updateForNewCurrent()
}, [])
})
const updateDirList = (path: string) => {
testTabLogic.dirList(path).then((options: any) => {
@ -211,21 +210,21 @@ export const SolidityUnitTesting = (props: any) => {
await testTab.call('editor', 'discardHighlight')
}
const highlightLocation = async (location: any, fileName: any) => {
const highlightLocation = async (location: string, fileName: string) => {
if (location) {
var split = location.split(':')
var file = split[2]
location = {
const split = location.split(':')
const file = split[2]
const parsedLocation = {
start: parseInt(split[0]),
length: parseInt(split[1])
}
location = testTab.offsetToLineColumnConverter.offsetToLineColumnWithContent(
location,
const locationToHighlight = testTab.offsetToLineColumnConverter.offsetToLineColumnWithContent(
parsedLocation,
parseInt(file),
filesContent[fileName].content
)
await testTab.call('editor', 'discardHighlight')
await testTab.call('editor', 'highlight', location, fileName, '', { focus: true })
await testTab.call('editor', 'highlight', locationToHighlight, fileName, '', { focus: true })
}
}
@ -351,7 +350,7 @@ export const SolidityUnitTesting = (props: any) => {
}
const showTestsResult = () => {
let filenames = Object.keys(testsResultByFilename)
const filenames = Object.keys(testsResultByFilename)
for(const filename of filenames) {
const fileTestsResult = testsResultByFilename[filename]
const contracts = Object.keys(fileTestsResult)
@ -544,7 +543,7 @@ export const SolidityUnitTesting = (props: any) => {
}
const getCurrentSelectedTests = () => {
let selectedTestsList: TestObject[] = testFiles.filter(testFileObj => testFileObj.checked)
const selectedTestsList: TestObject[] = testFiles.filter(testFileObj => testFileObj.checked)
return selectedTestsList.map(testFileObj => testFileObj.fileName)
}
@ -663,7 +662,6 @@ export const SolidityUnitTesting = (props: any) => {
data-id="testTabCheckAllTests"
onClick={checkAll}
checked={checkSelectAll}
onChange={() => {}}
/>
<label className="text-nowrap pl-2 mb-0" htmlFor="checkAllTests"> Select all </label>
</div>

Loading…
Cancel
Save