remix-solidity linting fixed

pull/861/head
aniket-engg 4 years ago
parent ed562f01d0
commit 84d0bac2fd
  1. 5
      libs/remix-solidity/.eslintrc
  2. 3
      libs/remix-solidity/src/compiler/compiler-input.ts
  3. 2
      libs/remix-solidity/src/compiler/compiler-worker.ts
  4. 30
      libs/remix-solidity/src/compiler/compiler.ts
  5. 4
      libs/remix-solidity/src/compiler/txHelper.ts
  6. 5
      libs/remix-solidity/src/compiler/types.ts
  7. 2
      package.json

@ -1,9 +1,8 @@
{
"extends": "../../.eslintrc",
"rules": {
"@typescript-eslint/no-explicit-any": "off",
"@typescript-eslint/no-var-requires": "off",
"@typescript-eslint/no-unused-vars": "off"
"dot-notation": "off",
"no-unused-vars": "off"
},
"env": {
"browser": true,

@ -27,8 +27,7 @@ export default (sources: Source, opts: CompilerInputOptions): string => {
o.language = opts.language
}
if (opts.language === 'Yul' && o.settings.optimizer.enabled) {
if (!o.settings.optimizer.details)
o.settings.optimizer.details = {}
if (!o.settings.optimizer.details) { o.settings.optimizer.details = {} }
o.settings.optimizer.details.yul = true
}
return JSON.stringify(o)

@ -24,7 +24,7 @@ export default function (self) { // eslint-disable-line @typescript-eslint/expli
try {
const missingInputsCallback = (path) => {
missingInputs.push(path)
return { 'error': 'Deferred import' }
return { error: 'Deferred import' }
}
return compiler.compile(input, { import: missingInputsCallback })
} catch (exception) {

@ -4,11 +4,13 @@ import { update } from 'solc/abi'
import * as webworkify from 'webworkify-webpack'
import compilerInput from './compiler-input'
import EventManager from '../lib/eventManager'
import { default as txHelper } from './txHelper';
import { Source, SourceWithTarget, MessageFromWorker, CompilerState, CompilationResult,
import txHelper from './txHelper'
import {
Source, SourceWithTarget, MessageFromWorker, CompilerState, CompilationResult,
visitContractsCallbackParam, visitContractsCallbackInterface, CompilationError,
gatherImportsCallbackInterface,
isFunctionDescription } from './types'
isFunctionDescription
} from './types'
/*
trigger compilationFinished, compilerLoaded, compilationStarted, compilationDuration
@ -68,9 +70,8 @@ export class Compiler {
this.gatherImports(files, missingInputs, (error, input) => {
if (error) {
this.state.lastCompilationResult = null
this.event.trigger('compilationFinished', [false, {'error': { formattedMessage: error, severity: 'error' }}, files])
} else if(this.state.compileJSON && input)
this.state.compileJSON(input)
this.event.trigger('compilationFinished', [false, { error: { formattedMessage: error, severity: 'error' } }, files])
} else if (this.state.compileJSON && input) { this.state.compileJSON(input) }
})
}
@ -151,9 +152,8 @@ export class Compiler {
this.internalCompile(source.sources, missingInputs)
} else {
data = this.updateInterface(data)
if(source)
{
source.target = this.state.target;
if (source) {
source.target = this.state.target
this.state.lastCompilationResult = {
data: data,
source: source
@ -340,8 +340,7 @@ export class Compiler {
}
return
}
if(cb)
cb(null, { 'sources': files })
if (cb) { cb(null, { sources: files }) }
}
/**
@ -366,9 +365,9 @@ export class Compiler {
// yul compiler does not return any abi,
// we default to accept the fallback function (which expect raw data as argument).
contract.object.abi.push({
'payable': true,
'stateMutability': 'payable',
'type': 'fallback'
payable: true,
stateMutability: 'payable',
type: 'fallback'
})
}
if (data && data.contracts && this.state.currentVersion) {
@ -379,7 +378,7 @@ export class Compiler {
for (const item of data.contracts[contract.file][contract.name].abi) {
if (isFunctionDescription(item) && item.constant) {
item.payable = false
item.stateMutability = 'view';
item.stateMutability = 'view'
}
}
}
@ -457,4 +456,3 @@ export class Compiler {
return null
}
}

@ -9,7 +9,7 @@ export default {
* @param contracts 'contracts' object from last compilation result
*/
getContract: (contractName: string, contracts: CompilationResult["contracts"]) : Record<string, any> | null => {
getContract: (contractName: string, contracts: CompilationResult['contracts']) : Record<string, any> | null => {
for (const file in contracts) {
if (contracts[file][contractName]) {
return { object: contracts[file][contractName], file: file }
@ -24,7 +24,7 @@ export default {
* @param cb - callback
*/
visitContracts: (contracts: CompilationResult["contracts"], cb: visitContractsCallbackInterface) : void => {
visitContracts: (contracts: CompilationResult['contracts'], cb: visitContractsCallbackInterface) : void => {
for (const file in contracts) {
for (const name in contracts[file]) {
const param: visitContractsCallbackParam = {

@ -129,7 +129,6 @@ export interface CompilerInput {
}
}
export interface Source {
[fileName: string]:
{
@ -355,10 +354,10 @@ export interface CompilationResult {
export type ABIDescription = FunctionDescription | EventDescription
export const isFunctionDescription = (item: ABIDescription): item is FunctionDescription =>
(item as FunctionDescription).stateMutability !== undefined;
(item as FunctionDescription).stateMutability !== undefined
export const isEventDescription = (item: ABIDescription): item is EventDescription =>
(item as EventDescription).type === 'event';
(item as EventDescription).type === 'event'
export interface FunctionDescription {
/** Type of the method. default is 'function' */

@ -41,7 +41,7 @@
"workspace-schematic": "nx workspace-schematic",
"dep-graph": "nx dep-graph",
"help": "nx help",
"lint:libs": "nx run-many --target=lint --projects=remix-analyzer,remix-astwalker,remix-debug,remix-lib,remixd,remix-ui-tree-view,remix-ui-modal-dialog,remix-ui-toaster,remix-ui-file-explorer,remix-ui-debugger-ui",
"lint:libs": "nx run-many --target=lint --projects=remix-analyzer,remix-astwalker,remix-debug,remix-lib,remix-simulator,remix-solidity,remixd,remix-ui-tree-view,remix-ui-modal-dialog,remix-ui-toaster,remix-ui-file-explorer,remix-ui-debugger-ui",
"build:libs": "nx run-many --target=build --parallel=false --with-deps=true --projects=remix-analyzer,remix-astwalker,remix-debug,remix-lib,remix-simulator,remix-solidity,remix-tests,remix-url-resolver,remixd",
"test:libs": "nx run-many --target=test --projects=remix-analyzer,remix-astwalker,remix-debug,remix-lib,remix-simulator,remix-solidity,remix-tests,remix-url-resolver,remixd",
"publish:libs": "npm run build:libs & lerna publish --skip-git & npm run bumpVersion:libs",

Loading…
Cancel
Save