-
Notifications
You must be signed in to change notification settings - Fork 1k
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
Lint entire codebase #4156
Changes from 3 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
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) => { | ||
|
@@ -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 = { | ||
|
@@ -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', | ||
}) | ||
|
||
config.ignoreWarnings = [/Failed to parse source map/] // ignore source-map-loader warnings | ||
|
||
|
||
// set minimizer | ||
config.optimization.minimizer = [ | ||
new TerserPlugin({ | ||
|
@@ -80,13 +78,13 @@ module.exports = composePlugins(withNx(), (config) => { | |
extractComments: false, | ||
}), | ||
new CssMinimizerPlugin(), | ||
]; | ||
] | ||
|
||
config.watchOptions = { | ||
ignored: /node_modules/ | ||
ignored: /node_modules/, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same here |
||
} | ||
|
||
config.experiments.syncWebAssembly = true | ||
|
||
return config; | ||
}); | ||
return config | ||
}) |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. semicolon should be removed |
||
|
||
case 'FunctionDefinition': { | ||
const { kind, name } = item; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. semicolon should be removed |
||
const params = item.parameters.parameters; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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(', ')})`; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. semicolon should be removed. Please check all such places There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. resolved |
||
} | ||
|
||
case 'VariableDeclaration': | ||
return formatVariable(item); | ||
} | ||
} | ||
|
||
|
@@ -177,4 +177,4 @@ export function inheritedfunctions ({ item }: DocItemContext) { | |
contract, | ||
functions: contract.functions.filter(f => !baseFunctions.has(f.id) && (f.name !== 'constructor' || i === 0)), | ||
})) | ||
} | ||
} |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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