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 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
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
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
74 changes: 37 additions & 37 deletions apps/doc-gen/src/app/docgen/common/properties.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,47 +36,47 @@ export function fullName ({ item, contract }: DocItemContext): string {

export function signature ({ item }: DocItemContext): string | undefined {
switch (item.nodeType) {
case 'ContractDefinition':
return undefined;

case 'FunctionDefinition': {
const { kind, name } = item;
const params = item.parameters.parameters;
const returns = item.returnParameters.parameters;
const head = (kind === 'function' || kind === 'freeFunction') ? [kind, name].join(' ') : kind;
const res = [
`${head}(${params.map(formatVariable).join(', ')})`,
item.visibility,
];
if (item.stateMutability !== 'nonpayable') {
res.push(item.stateMutability);
}
if (item.virtual) {
res.push('virtual');
}
if (returns.length > 0) {
res.push(`returns (${returns.map(formatVariable).join(', ')})`);
}
return res.join(' ');
case 'ContractDefinition':
return undefined;
Copy link
Collaborator

Choose a reason for hiding this comment

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

semicolon should be removed


case 'FunctionDefinition': {
const { kind, name } = item;
Copy link
Collaborator

Choose a reason for hiding this comment

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

semicolon should be removed

const params = item.parameters.parameters;
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

const returns = item.returnParameters.parameters;
const head = (kind === 'function' || kind === 'freeFunction') ? [kind, name].join(' ') : kind;
const res = [
`${head}(${params.map(formatVariable).join(', ')})`,
item.visibility,
];
if (item.stateMutability !== 'nonpayable') {
res.push(item.stateMutability);
}

case 'EventDefinition': {
const params = item.parameters.parameters;
return `event ${item.name}(${params.map(formatVariable).join(', ')})`;
if (item.virtual) {
res.push('virtual');
}

case 'ErrorDefinition': {
const params = item.parameters.parameters;
return `error ${item.name}(${params.map(formatVariable).join(', ')})`;
if (returns.length > 0) {
res.push(`returns (${returns.map(formatVariable).join(', ')})`);
}
return res.join(' ');
}

case 'ModifierDefinition': {
const params = item.parameters.parameters;
return `modifier ${item.name}(${params.map(formatVariable).join(', ')})`;
}
case 'EventDefinition': {
const params = item.parameters.parameters;
return `event ${item.name}(${params.map(formatVariable).join(', ')})`;
}

case 'VariableDeclaration':
return formatVariable(item);
case 'ErrorDefinition': {
const params = item.parameters.parameters;
return `error ${item.name}(${params.map(formatVariable).join(', ')})`;
}

case 'ModifierDefinition': {
const params = item.parameters.parameters;
return `modifier ${item.name}(${params.map(formatVariable).join(', ')})`;
Copy link
Collaborator

Choose a reason for hiding this comment

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

semicolon should be removed. Please check all such places

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

resolved

}

case 'VariableDeclaration':
return formatVariable(item);
}
}

Expand Down Expand Up @@ -177,4 +177,4 @@ export function inheritedfunctions ({ item }: DocItemContext) {
contract,
functions: contract.functions.filter(f => !baseFunctions.has(f.id) && (f.name !== 'constructor' || i === 0)),
}))
}
}
18 changes: 9 additions & 9 deletions apps/doc-gen/src/app/docgen/utils/memoized-getter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,17 @@ export function defineGetterMemoized<K extends keyof any, T, O extends { [k in K
enumerable: true,
get() {
switch (state) {
case 'done':
return value;
case 'done':
return value;

case 'doing':
throw new Error("Detected recursion");
case 'doing':
throw new Error("Detected recursion");

case 'todo':
state = 'doing';
value = getter();
state = 'done';
return value;
case 'todo':
state = 'doing';
value = getter();
state = 'done';
return value;
}
}
});
Expand Down
8 changes: 4 additions & 4 deletions apps/doc-gen/src/app/docgen/utils/natspec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,10 @@ export function parseNatspec(item: DocItemWithContext): NatSpec {
const docString = docSource !== undefined
? cleanUpDocstringFromSource(docSource)
: 'documentation' in item && item.documentation
? typeof item.documentation === 'string'
? item.documentation
: cleanUpDocstringFromSolc(item.documentation.text)
: '';
? typeof item.documentation === 'string'
? item.documentation
: cleanUpDocstringFromSolc(item.documentation.text)
: '';

const tagMatches = execAll(
/^(?:@(\w+|custom:[a-z][a-z-]*) )?((?:(?!^@(?:\w+|custom:[a-z][a-z-]*) )[^])*)/m,
Expand Down
4 changes: 2 additions & 2 deletions apps/doc-viewer/src/app/App.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React, {useEffect, useState} from 'react'
import {DocViewer} from './docviewer'
import React, { useEffect, useState } from 'react'
import { DocViewer } from './docviewer'
import ReactMarkdown from 'react-markdown'
import remarkGfm from 'remark-gfm'

Expand Down
18 changes: 9 additions & 9 deletions apps/doc-viewer/webpack.config.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const {composePlugins, withNx} = require('@nrwl/webpack')
const {withReact} = require('@nrwl/react')
const { composePlugins, withNx } = require('@nrwl/webpack')
const { withReact } = require('@nrwl/react')
const webpack = require('webpack')
const TerserPlugin = require('terser-webpack-plugin')
const CssMinimizerPlugin = require('css-minimizer-webpack-plugin')
Expand All @@ -12,7 +12,7 @@ module.exports = composePlugins(withNx(), withReact(), (config) => {
// add externals
config.externals = {
...config.externals,
solc: 'solc'
solc: 'solc',
}

// add public path
Expand All @@ -23,7 +23,7 @@ module.exports = composePlugins(withNx(), withReact(), (config) => {
new webpack.ProvidePlugin({
Buffer: ['buffer', 'Buffer'],
url: ['url', 'URL'],
process: 'process/browser'
process: 'process/browser',
}),
new webpack.DefinePlugin({})
)
Expand All @@ -32,7 +32,7 @@ module.exports = composePlugins(withNx(), withReact(), (config) => {
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 @@ -46,12 +46,12 @@ module.exports = composePlugins(withNx(), withReact(), (config) => {
compress: false,
mangle: false,
format: {
comments: false
}
comments: false,
},
},
extractComments: false
extractComments: false,
}),
new CssMinimizerPlugin()
new CssMinimizerPlugin(),
]

return config
Expand Down
Loading
Loading