linting fix

pull/1862/head
aniket-engg 3 years ago committed by Aniket
parent 458732ae83
commit fb8af63bcd
  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"], "extends": ["plugin:@nrwl/nx/react", "../../../.eslintrc.json"],
"ignorePatterns": ["!**/*"], "ignorePatterns": ["!**/*"],
"rules": {
"@typescript-eslint/no-explicit-any": "off"
},
"overrides": [ "overrides": [
{ {
"files": ["*.ts", "*.tsx", "*.js", "*.jsx"], "files": ["*.ts", "*.tsx", "*.js", "*.jsx"],

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

Loading…
Cancel
Save