Skip to content

Commit

Permalink
complete manual linting of files in project
Browse files Browse the repository at this point in the history
  • Loading branch information
joeizang committed Oct 20, 2023
1 parent 7487a5a commit 97ba784
Show file tree
Hide file tree
Showing 28 changed files with 566 additions and 566 deletions.
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;

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);
}

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(', ')})`;
}

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
14 changes: 7 additions & 7 deletions apps/etherscan/src/app/utils/verify.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export const verify = async (
compilationResultParam: CompilerAbstract,
chainRef: number | string,
isProxyContract: boolean,
expectedImplAddress: string,
expectedImplAddress: string,
client: PluginClient,
onVerifiedContract: (value: EtherScanReturn) => void,
setResults: (value: string) => void
Expand All @@ -47,7 +47,7 @@ export const verify = async (
etherscanApi = getEtherScanApi(networkChainId)
}
}

try {
const contractMetadata = getContractMetadata(
// cast from the remix-plugin interface to the solidity one. Should be fixed when remix-plugin move to the remix-project repository
Expand All @@ -61,7 +61,7 @@ export const verify = async (
message: "Please recompile contract"
}
}

const contractMetadataParsed = JSON.parse(contractMetadata)

const fileName = getContractFileName(
Expand Down Expand Up @@ -146,9 +146,9 @@ export const verify = async (
title: result,
})
const returnValue = {
message: result,
succeed: false,
isProxyContract
message: result,
succeed: false,
isProxyContract
}
resetAfter10Seconds(client, setResults)
return returnValue
Expand Down Expand Up @@ -184,7 +184,7 @@ export const getContractFileName = (
}
return fileName
}

export const getContractMetadata = (
compilationResult: CompilationResult,
contractName: string
Expand Down
12 changes: 6 additions & 6 deletions build-changelog.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ const prCount = inDone.filter((card) => {
console.log(prCount, 'PRs found!\n')
data = prCount + ' PRs found!\n\n'
for (let card of inDone) {
if (card.node.content.url && card.node.content.merged) {
data += ` - [${card.node.content.title}](${card.node.content.url}) (@${card.node.content.author.login})\n`
data += ` participants: (${card.node.content.participants.edges.map((p) => { return ` @${p.node.login}` })})`
data += '\n\n'
}
if (card.node.content.url && card.node.content.merged) {
data += ` - [${card.node.content.title}](${card.node.content.url}) (@${card.node.content.author.login})\n`
data += ` participants: (${card.node.content.participants.edges.map((p) => { return ` @${p.node.login}` })})`
data += '\n\n'
}
}
console.log('change-log.txt updated')
fs.writeFileSync('./change-log.txt', data)
Expand Down Expand Up @@ -51,7 +51,7 @@ fs.writeFileSync('./change-log.txt', data)
cursor
node {
id
note
note
state
content {
... on PullRequest {
Expand Down
72 changes: 36 additions & 36 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,53 +12,53 @@ var packageJSON = require('./package.json');
* @dev Task to create git tag using version from package.json and pushing this specific tag
*/
task('publishTag', async function () {
const tag = "v" + packageJSON.version
await promisifyExec(`git tag ${tag}; git push origin ${tag}`);
const tag = "v" + packageJSON.version
await promisifyExec(`git tag ${tag}; git push origin ${tag}`);
});

/**
* @dev Task to update changelog for latest release
*/
task('updateChangelog', async function () {
const previous_version = process.argv[4];
const next_version = "v" + packageJSON.version;
const previous_version = process.argv[4];
const next_version = "v" + packageJSON.version;

// Create changes.md with latest release changelog temporarily
await promisifyExec(`github-changes -o ethereum -r remix -a --file changes.md --only-pulls --use-commit-body --only-merges --between-tags ${previous_version} ... ${next_version}`);
const latestChangelog = fs.readFileSync(__dirname + '/changes.md', 'utf8')
const oldChangelog = fs.readFileSync(__dirname + '/CHANGELOG.md', 'utf8')
// Concatenate latest changelog content to the top of old changelog file content
const data = latestChangelog + '\n\n' + oldChangelog
// Delete current changelog file CHANGELOG.md
fs.unlinkSync(__dirname + '/CHANGELOG.md');
// Delete changes.md
fs.unlinkSync(__dirname + '/changes.md');
// Write the concatenated content to CHANGELOG.md (We delete and create file to place the new data on top)
fs.writeFileSync(__dirname + '/CHANGELOG.md', data);
await Promise.resolve();
// Create changes.md with latest release changelog temporarily
await promisifyExec(`github-changes -o ethereum -r remix -a --file changes.md --only-pulls --use-commit-body --only-merges --between-tags ${previous_version} ... ${next_version}`);
const latestChangelog = fs.readFileSync(__dirname + '/changes.md', 'utf8')
const oldChangelog = fs.readFileSync(__dirname + '/CHANGELOG.md', 'utf8')
// Concatenate latest changelog content to the top of old changelog file content
const data = latestChangelog + '\n\n' + oldChangelog
// Delete current changelog file CHANGELOG.md
fs.unlinkSync(__dirname + '/CHANGELOG.md');
// Delete changes.md
fs.unlinkSync(__dirname + '/changes.md');
// Write the concatenated content to CHANGELOG.md (We delete and create file to place the new data on top)
fs.writeFileSync(__dirname + '/CHANGELOG.md', data);
await Promise.resolve();
});

/**
* @dev Task to sync libs version from 'dist' folder as lerna published from there
*/
task('syncLibVersions', async function () {
const libs = [
'remix-analyzer',
'remix-astwalker',
'remix-debug',
'remix-lib',
'remix-simulator',
'remix-solidity',
'remix-tests',
'remix-url-resolver',
'remix-ws-templates',
'remixd',
'ghaction-helper'
]
const libs = [
'remix-analyzer',
'remix-astwalker',
'remix-debug',
'remix-lib',
'remix-simulator',
'remix-solidity',
'remix-tests',
'remix-url-resolver',
'remix-ws-templates',
'remixd',
'ghaction-helper'
]

libs.forEach(lib => {
const distPackageJSON = require(__dirname + '/dist/libs/' + lib + '/package.json')
fs.writeFileSync(__dirname + '/libs/' + lib + '/package.json', JSON.stringify(distPackageJSON, null, 2), 'utf8')
})
await Promise.resolve();
});
libs.forEach(lib => {
const distPackageJSON = require(__dirname + '/dist/libs/' + lib + '/package.json')
fs.writeFileSync(__dirname + '/libs/' + lib + '/package.json', JSON.stringify(distPackageJSON, null, 2), 'utf8')
})
await Promise.resolve();
});
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@ const ModalWrapper = (props: ModalWrapperProps) => {
} else if (ref.current) {
props.okFn
? // @ts-ignore: Object is possibly 'null'.
props.okFn(ref.current.value)
props.okFn(ref.current.value)
: // @ts-ignore: Object is possibly 'null'.
props.resolve(ref.current.value)
props.resolve(ref.current.value)
}
}

Expand Down Expand Up @@ -100,30 +100,30 @@ const ModalWrapper = (props: ModalWrapperProps) => {
data.current = props.data
if (props.modalType) {
switch (props.modalType) {
case ModalTypes.prompt:
case ModalTypes.password:
setState({
...props,
okFn: onFinishPrompt,
cancelFn: onCancelFn,
message: createModalMessage(props.defaultValue, { valid: true }),
})
break
case ModalTypes.form:
setState({
...props,
okFn: onFinishPrompt,
cancelFn: onCancelFn,
message: createForm({ valid: true }),
})
break
default:
setState({
...props,
okFn: onOkFn,
cancelFn: onCancelFn,
})
break
case ModalTypes.prompt:
case ModalTypes.password:
setState({
...props,
okFn: onFinishPrompt,
cancelFn: onCancelFn,
message: createModalMessage(props.defaultValue, { valid: true }),
})
break
case ModalTypes.form:
setState({
...props,
okFn: onFinishPrompt,
cancelFn: onCancelFn,
message: createForm({ valid: true }),
})
break
default:
setState({
...props,
okFn: onOkFn,
cancelFn: onCancelFn,
})
break
}
} else {
setState({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,15 @@ export const FileDecorationIcons = (props: fileDecorationProps) => {

for (const [index, state] of states.entries()) {
switch (state.fileStateType) {
case fileDecorationType.Error:
elements.push(<FileDecorationTooltip key={index} index={index} fileDecoration={state} icon={<FileDecorationErrorIcon fileDecoration={state} key={index} />} />)
break
case fileDecorationType.Warning:
elements.push(<FileDecorationTooltip key={index} index={index} fileDecoration={state} icon={<FileDecorationWarningIcon fileDecoration={state} key={index} />} />)
break
case fileDecorationType.Custom:
elements.push(<FileDecorationTooltip key={index} index={index} fileDecoration={state} icon={<FileDecorationCustomIcon fileDecoration={state} key={index} />} />)
break
case fileDecorationType.Error:
elements.push(<FileDecorationTooltip key={index} index={index} fileDecoration={state} icon={<FileDecorationErrorIcon fileDecoration={state} key={index} />} />)
break
case fileDecorationType.Warning:
elements.push(<FileDecorationTooltip key={index} index={index} fileDecoration={state} icon={<FileDecorationWarningIcon fileDecoration={state} key={index} />} />)
break
case fileDecorationType.Custom:
elements.push(<FileDecorationTooltip key={index} index={index} fileDecoration={state} icon={<FileDecorationCustomIcon fileDecoration={state} key={index} />} />)
break
}
}
return elements
Expand Down
Loading

0 comments on commit 97ba784

Please sign in to comment.