diff --git a/libs/remix-ui/solidity-unit-testing/.eslintrc.json b/libs/remix-ui/solidity-unit-testing/.eslintrc.json index 50e59482cf..5e100bf955 100644 --- a/libs/remix-ui/solidity-unit-testing/.eslintrc.json +++ b/libs/remix-ui/solidity-unit-testing/.eslintrc.json @@ -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"], diff --git a/libs/remix-ui/solidity-unit-testing/src/lib/actions/solidityUnitTestingAction.ts b/libs/remix-ui/solidity-unit-testing/src/lib/actions/solidityUnitTestingAction.ts deleted file mode 100644 index c5728e9dec..0000000000 --- a/libs/remix-ui/solidity-unit-testing/src/lib/actions/solidityUnitTestingAction.ts +++ /dev/null @@ -1,2 +0,0 @@ -import React from 'react' - diff --git a/libs/remix-ui/solidity-unit-testing/src/lib/logic/testTabLogic.ts b/libs/remix-ui/solidity-unit-testing/src/lib/logic/testTabLogic.ts index df19fb665d..31e34cf50f 100644 --- a/libs/remix-ui/solidity-unit-testing/src/lib/logic/testTabLogic.ts +++ b/libs/remix-ui/solidity-unit-testing/src/lib/logic/testTabLogic.ts @@ -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) } diff --git a/libs/remix-ui/solidity-unit-testing/src/lib/reducers/solidityUnitTestingReducer.ts b/libs/remix-ui/solidity-unit-testing/src/lib/reducers/solidityUnitTestingReducer.ts deleted file mode 100644 index bb73474209..0000000000 --- a/libs/remix-ui/solidity-unit-testing/src/lib/reducers/solidityUnitTestingReducer.ts +++ /dev/null @@ -1 +0,0 @@ -export const solidityUnitTestingReducer = (state, action) => {} \ No newline at end of file diff --git a/libs/remix-ui/solidity-unit-testing/src/lib/solidity-unit-testing.tsx b/libs/remix-ui/solidity-unit-testing/src/lib/solidity-unit-testing.tsx index 1dbdf5a5d2..ae4f89272b 100644 --- a/libs/remix-ui/solidity-unit-testing/src/lib/solidity-unit-testing.tsx +++ b/libs/remix-ui/solidity-unit-testing/src/lib/solidity-unit-testing.tsx @@ -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) => { 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([]) + const [testFiles, setTestFiles] = useState([]) const [pathOptions, setPathOptions] = useState(['']) - let [selectedTests, setSelectedTests] = useState([]) + let [selectedTests, setSelectedTests] = useState([]) // 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 = {} + const testsResultByFilename:Record = {} 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={() => {}} />