Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lint entire codebase #4156

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
10 changes: 3 additions & 7 deletions apps/circuit-compiler/src/app/app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,11 @@ import React, { useEffect } from 'react'
import { CircomPluginClient } from './services/circomPluginClient'

function App() {

useEffect(() => {
new CircomPluginClient()
}, [])

return (
<div className="App">
</div>
)

return <div className="App"></div>
}

export default App
export default App
5 changes: 1 addition & 4 deletions apps/circuit-compiler/src/main.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,4 @@ import React from 'react'
import ReactDOM from 'react-dom'
import App from './app/app'

ReactDOM.render(
<App />,
document.getElementById('root')
)
ReactDOM.render(<App />, document.getElementById('root'))
52 changes: 25 additions & 27 deletions apps/circuit-compiler/webpack.config.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const { composePlugins, withNx } = require('@nrwl/webpack')
const webpack = require('webpack')
const TerserPlugin = require("terser-webpack-plugin")
const CssMinimizerPlugin = require("css-minimizer-webpack-plugin")
const TerserPlugin = require('terser-webpack-plugin')
const CssMinimizerPlugin = require('css-minimizer-webpack-plugin')

// Nx plugins for webpack.
module.exports = composePlugins(withNx(), (config) => {
Expand All @@ -10,25 +10,24 @@ module.exports = composePlugins(withNx(), (config) => {
// add fallback for node modules
config.resolve.fallback = {
...config.resolve.fallback,
"crypto": require.resolve("crypto-browserify"),
"stream": require.resolve("stream-browserify"),
"path": require.resolve("path-browserify"),
"http": require.resolve("stream-http"),
"https": require.resolve("https-browserify"),
"constants": require.resolve("constants-browserify"),
"os": false, //require.resolve("os-browserify/browser"),
"timers": false, // require.resolve("timers-browserify"),
"zlib": require.resolve("browserify-zlib"),
"fs": false,
"module": false,
"tls": false,
"net": false,
"readline": false,
"child_process": false,
"buffer": require.resolve("buffer/"),
"vm": require.resolve('vm-browserify'),
crypto: require.resolve('crypto-browserify'),
stream: require.resolve('stream-browserify'),
path: require.resolve('path-browserify'),
http: require.resolve('stream-http'),
https: require.resolve('https-browserify'),
constants: require.resolve('constants-browserify'),
os: false, //require.resolve("os-browserify/browser"),
timers: false, // require.resolve("timers-browserify"),
zlib: require.resolve('browserify-zlib'),
fs: false,
module: false,
tls: false,
net: false,
readline: false,
child_process: false,
buffer: require.resolve('buffer/'),
vm: require.resolve('vm-browserify'),
}


// add externals
config.externals = {
Expand Down Expand Up @@ -58,13 +57,12 @@ module.exports = composePlugins(withNx(), (config) => {
// souce-map loader
config.module.rules.push({
test: /\.js$/,
use: ["source-map-loader"],
enforce: "pre"
use: ['source-map-loader'],
enforce: 'pre',
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure if we should use comma for last item in JSON . See https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Trailing_commas

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This isn't a json file. its a js file

})

config.ignoreWarnings = [/Failed to parse source map/] // ignore source-map-loader warnings


// set minimizer
config.optimization.minimizer = [
new TerserPlugin({
Expand All @@ -80,13 +78,13 @@ module.exports = composePlugins(withNx(), (config) => {
extractComments: false,
}),
new CssMinimizerPlugin(),
];
]

config.watchOptions = {
ignored: /node_modules/
ignored: /node_modules/,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here

}

config.experiments.syncWebAssembly = true

return config;
});
return config
})
6 changes: 3 additions & 3 deletions apps/debugger/src/app/app.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import React, {useState, useEffect} from 'react'
import React, { useState, useEffect } from 'react'

import {DebuggerUI} from '@remix-ui/debugger-ui' // eslint-disable-line
import { DebuggerUI } from '@remix-ui/debugger-ui' // eslint-disable-line

import {DebuggerClientApi} from './debugger'
import { DebuggerClientApi } from './debugger'

const remix = new DebuggerClientApi()

Expand Down
12 changes: 6 additions & 6 deletions apps/debugger/src/app/debugger.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import { PluginClient } from "@remixproject/plugin";
import { createClient } from "@remixproject/plugin-webview";
import { IDebuggerApi, LineColumnLocation,
import { PluginClient } from "@remixproject/plugin"
import { createClient } from "@remixproject/plugin-webview"
import { IDebuggerApi, LineColumnLocation,
onBreakpointClearedListener, onBreakpointAddedListener, onEditorContentChanged, onEnvChangedListener, TransactionReceipt } from '@remix-ui/debugger-ui'
import { DebuggerApiMixin } from '@remix-ui/debugger-ui'
import { CompilerAbstract } from '@remix-project/remix-solidity'

export class DebuggerClientApi extends DebuggerApiMixin(PluginClient) {
export class DebuggerClientApi extends DebuggerApiMixin(PluginClient) {
constructor () {
super()
super()
createClient(this as any)
this.initDebuggerApi()
}
Expand All @@ -27,4 +27,4 @@ export class DebuggerClientApi extends DebuggerApiMixin(PluginClient) {
web3: () => any // returns an instance of web3.js
onStartDebugging: (debuggerBackend: any) => void // called when debug starts
onStopDebugging: () => void // called when debug stops
}
}
2 changes: 1 addition & 1 deletion apps/debugger/src/environments/environment.prod.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
export const environment = {
production: true
};
}
2 changes: 1 addition & 1 deletion apps/debugger/src/environments/environment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@

export const environment = {
production: false
};
}
4 changes: 2 additions & 2 deletions apps/debugger/src/polyfills.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
*
* See: https://github.com/zloirock/core-js#babel
*/
import 'core-js/stable';
import 'regenerator-runtime/runtime';
import 'core-js/stable'
import 'regenerator-runtime/runtime'
20 changes: 10 additions & 10 deletions apps/debugger/webpack.config.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const {composePlugins, withNx} = require('@nrwl/webpack')
const { composePlugins, withNx } = require('@nrwl/webpack')
const webpack = require('webpack')
const TerserPlugin = require('terser-webpack-plugin')
const CssMinimizerPlugin = require('css-minimizer-webpack-plugin')
Expand Down Expand Up @@ -27,13 +27,13 @@ module.exports = composePlugins(withNx(), (config) => {
readline: false,
child_process: false,
buffer: require.resolve('buffer/'),
vm: require.resolve('vm-browserify')
vm: require.resolve('vm-browserify'),
}

// add externals
config.externals = {
...config.externals,
solc: 'solc'
solc: 'solc',
}

// add public path
Expand All @@ -44,15 +44,15 @@ module.exports = composePlugins(withNx(), (config) => {
new webpack.ProvidePlugin({
Buffer: ['buffer', 'Buffer'],
url: ['url', 'URL'],
process: 'process/browser'
process: 'process/browser',
})
)

// souce-map loader
config.module.rules.push({
test: /\.js$/,
use: ['source-map-loader'],
enforce: 'pre'
enforce: 'pre',
})

config.ignoreWarnings = [/Failed to parse source map/] // ignore source-map-loader warnings
Expand All @@ -66,16 +66,16 @@ module.exports = composePlugins(withNx(), (config) => {
compress: false,
mangle: false,
format: {
comments: false
}
comments: false,
},
},
extractComments: false
extractComments: false,
}),
new CssMinimizerPlugin()
new CssMinimizerPlugin(),
]

config.watchOptions = {
ignored: /node_modules/
ignored: /node_modules/,
}

return config
Expand Down
6 changes: 3 additions & 3 deletions apps/doc-gen/src/app/docgen-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export class DocGenClient extends PluginClient {
public docs: string[] = []
private fileName: string = ''
private contractPath: string = ''

constructor() {
super()
this.eventEmitter = new EventEmitter()
Expand All @@ -30,11 +30,11 @@ export class DocGenClient extends PluginClient {

async setListeners() {
this.currentTheme = await this.call('theme', 'currentTheme')

this.on('theme', 'themeChanged', (theme: any) => {
this.currentTheme = theme
this.eventEmitter.emit('themeChanged', this.currentTheme)
});
})
this.eventEmitter.emit('themeChanged', this.currentTheme)

this.on('solidity', 'compilationFinished', (fileName: string, source: SourceWithTarget, languageVersion: string, data: CompilationResult) => {
Expand Down
20 changes: 10 additions & 10 deletions apps/doc-gen/src/app/docgen/common/helpers.ts
Original file line number Diff line number Diff line change
@@ -1,35 +1,35 @@
import { VariableDeclaration } from "solidity-ast";
import { VariableDeclaration } from "solidity-ast"

export function trim(text: string) {
if (typeof text === 'string') {
return text.trim();
return text.trim()
}
}

export function joinLines(text?: string) {
if (typeof text === 'string') {
return text.replace(/\n+/g, ' ');
return text.replace(/\n+/g, ' ')
}
}

/**
* Format a variable as its type followed by its name, if available.
*/
export function formatVariable(v: VariableDeclaration): string {
return [v.typeName?.typeDescriptions.typeString].concat(v.name || []).join(' ');
return [v.typeName?.typeDescriptions.typeString].concat(v.name || []).join(' ')
}

export const eq = (a: unknown, b: unknown) => a === b;
export const eq = (a: unknown, b: unknown) => a === b

export const slug = (str) => {
if (str === undefined) {
throw new Error('Missing argument');
throw new Error('Missing argument')
}
return str.replace(/\W/g, '-');
return str.replace(/\W/g, '-')
}

export const names = params => params.map(p => p.name).join(', ');
export const names = params => params.map(p => p.name).join(', ')

export const typedParams = params => {
return params?.map(p => `${p.type}${p.indexed ? ' indexed' : ''}${p.name ? ' ' + p.name : ''}`).join(', ');
};
return params?.map(p => `${p.type}${p.indexed ? ' indexed' : ''}${p.name ? ' ' + p.name : ''}`).join(', ')
}
Loading
Loading