Skip to content

Commit

Permalink
feat(eslint): properly ignore paths in ignores config (#957)
Browse files Browse the repository at this point in the history
* feat(eslint): properly ignore paths

Signed-off-by: Tomás Migone <[email protected]>

* chore(token-distribution): apply latest linting rules

Signed-off-by: Tomás Migone <[email protected]>

---------

Signed-off-by: Tomás Migone <[email protected]>
  • Loading branch information
tmigone authored Mar 8, 2024
1 parent fce8f74 commit 09284ef
Show file tree
Hide file tree
Showing 16 changed files with 75 additions and 57 deletions.
6 changes: 6 additions & 0 deletions packages/eslint-graph-config/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,12 @@ module.exports = [
'@typescript-eslint/no-unsafe-argument': 'off',
},
},
{
ignores: [
'library/*', // ignore its contents
'!node_modules/mylibrary/' // unignore `node_modules/mylibrary` directory
]
}
]
```

Expand Down
4 changes: 3 additions & 1 deletion packages/eslint-graph-config/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ export default [
'no-only-tests': noOnlyTests,
'no-secrets': noSecrets,
},
ignores: ['dist/*', 'node_modules/*', 'build/*'],
rules: {
'prefer-const': 'warn',
'@typescript-eslint/no-inferrable-types': 'warn',
Expand All @@ -47,4 +46,7 @@ export default [
'@stylistic/brace-style': ['error', '1tbs'],
},
},
{
ignores: ['**/dist/*', '**/node_modules/*', '**/build/*', '**/cache/*', '**/.graphclient/*'],
},
]
4 changes: 2 additions & 2 deletions packages/token-distribution/deploy/1_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@ import { utils } from 'ethers'
import consola from 'consola'

import { HardhatRuntimeEnvironment } from 'hardhat/types'
import { DeployFunction } from 'hardhat-deploy/types'
import { DeployFunction, DeployOptions } from 'hardhat-deploy/types'

const { parseEther } = utils

const logger = consola.create({})

const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
const { deploy } = hre.deployments
const deploy = (name: string, options: DeployOptions) => hre.deployments.deploy(name, options)
const { deployer } = await hre.getNamedAccounts()

// -- Fake Graph Token --
Expand Down
4 changes: 2 additions & 2 deletions packages/token-distribution/deploy/2_l1_manager_wallet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { utils } from 'ethers'

import '@nomiclabs/hardhat-ethers'
import { HardhatRuntimeEnvironment } from 'hardhat/types'
import { DeployFunction } from 'hardhat-deploy/types'
import { DeployFunction, DeployOptions } from 'hardhat-deploy/types'

import { GraphTokenMock } from '../build/typechain/contracts/GraphTokenMock'
import { GraphTokenLockManager } from '../build/typechain/contracts/GraphTokenLockManager'
Expand All @@ -14,7 +14,7 @@ const { parseEther, formatEther } = utils
const logger = consola.create({})

const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
const { deploy } = hre.deployments
const deploy = (name: string, options: DeployOptions) => hre.deployments.deploy(name, options)
const { deployer } = await hre.getNamedAccounts()

// -- Graph Token --
Expand Down
5 changes: 2 additions & 3 deletions packages/token-distribution/deploy/3_l2_wallet.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
import consola from 'consola'
import '@nomiclabs/hardhat-ethers'
import { HardhatRuntimeEnvironment } from 'hardhat/types'
import { DeployFunction } from 'hardhat-deploy/types'
import { DeployFunction, DeployOptions } from 'hardhat-deploy/types'

import { getDeploymentName } from './lib/utils'


const logger = consola.create({})

const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
const { deploy } = hre.deployments
const deploy = (name: string, options: DeployOptions) => hre.deployments.deploy(name, options)
const { deployer } = await hre.getNamedAccounts()

// Deploy the master copy of GraphTokenLockWallet
Expand Down
5 changes: 2 additions & 3 deletions packages/token-distribution/deploy/4_l1_transfer_tool.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import consola from 'consola'
import { utils } from 'ethers'

import '@nomiclabs/hardhat-ethers'
import { HardhatRuntimeEnvironment } from 'hardhat/types'
Expand Down Expand Up @@ -50,12 +49,12 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
owner = deployer
logger.warn(`No owner address provided, will use the deployer address as owner: ${owner}`)
}

// Deploy the L1GraphTokenLockTransferTool with a proxy.
// hardhat-deploy doesn't get along with constructor arguments in the implementation
// combined with an OpenZeppelin transparent proxy, so we need to do this using
// the OpenZeppelin hardhat-upgrades tooling, and save the deployment manually.

// TODO modify this to use upgradeProxy if a deployment already exists?
logger.info('Deploying L1GraphTokenLockTransferTool proxy...')
const transferToolFactory = await ethers.getContractFactory('L1GraphTokenLockTransferTool')
Expand Down
4 changes: 2 additions & 2 deletions packages/token-distribution/deploy/5_l2_manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { utils } from 'ethers'

import '@nomiclabs/hardhat-ethers'
import { HardhatRuntimeEnvironment } from 'hardhat/types'
import { DeployFunction } from 'hardhat-deploy/types'
import { DeployFunction, DeployOptions } from 'hardhat-deploy/types'

import { GraphTokenMock } from '../build/typechain/contracts/GraphTokenMock'
import { askConfirm, getDeploymentName, promptContractAddress } from './lib/utils'
Expand All @@ -14,7 +14,7 @@ const { parseEther, formatEther } = utils
const logger = consola.create({})

const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
const { deploy } = hre.deployments
const deploy = (name: string, options: DeployOptions) => hre.deployments.deploy(name, options)
const { deployer } = await hre.getNamedAccounts()

// -- Graph Token --
Expand Down
7 changes: 2 additions & 5 deletions packages/token-distribution/deploy/6_l2_transfer_tool.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import consola from 'consola'
import { utils } from 'ethers'

import '@nomiclabs/hardhat-ethers'
import { HardhatRuntimeEnvironment } from 'hardhat/types'
Expand All @@ -18,8 +17,6 @@ const artifacts = new Artifacts(ARTIFACTS_PATH)
const l2TransferToolAbi = artifacts.readArtifactSync('L2GraphTokenLockTransferTool').abi

const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
const { deployer } = await hre.getNamedAccounts()

// -- Graph Token --

// Get the addresses we will use
Expand All @@ -40,12 +37,12 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
logger.warn('No L1 GRT address provided')
process.exit(1)
}

// Deploy the L2GraphTokenLockTransferTool with a proxy.
// hardhat-deploy doesn't get along with constructor arguments in the implementation
// combined with an OpenZeppelin transparent proxy, so we need to do this using
// the OpenZeppelin hardhat-upgrades tooling, and save the deployment manually.

// TODO modify this to use upgradeProxy if a deployment already exists?
logger.info('Deploying L2GraphTokenLockTransferTool proxy...')
const transferToolFactory = await ethers.getContractFactory('L2GraphTokenLockTransferTool')
Expand Down
6 changes: 3 additions & 3 deletions packages/token-distribution/deploy/lib/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ export const askConfirm = async (message: string) => {
type: 'confirm',
message,
})
return res.confirm
return res.confirm ? res.confirm as boolean : false
}

export const promptContractAddress = async (name: string, logger: Consola): Promise<string|null> => {
export const promptContractAddress = async (name: string, logger: Consola): Promise<string | null> => {
const res1 = await inquirer.prompt({
name: 'contract',
type: 'input',
Expand All @@ -37,5 +37,5 @@ export const getDeploymentName = async (defaultName: string): Promise<string> =>
default: defaultName,
message: 'Save deployment as?',
})
return res['deployment-name']
return res['deployment-name'] as string
}
4 changes: 2 additions & 2 deletions packages/token-distribution/hardhat.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ function setupNetworkConfig(config) {

// Env

// eslint-disable-next-line @typescript-eslint/no-misused-promises
extendEnvironment(async (hre) => {
const accounts = await hre.ethers.getSigners()
try {
Expand Down Expand Up @@ -152,7 +153,6 @@ const config = {
},
},
etherscan: {
//url: process.env.ETHERSCAN_API_URL,
apiKey: process.env.ETHERSCAN_API_KEY,
customChains: [
{
Expand All @@ -163,7 +163,7 @@ const config = {
browserURL: 'https://sepolia.arbiscan.io',
},
},
]
],
},
typechain: {
outDir: 'build/typechain/contracts',
Expand Down
18 changes: 9 additions & 9 deletions packages/token-distribution/ops/create.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import PQueue from 'p-queue'
import fs from 'fs'
import consola from 'consola'
import inquirer from 'inquirer'
import { utils, BigNumber, Event, ContractTransaction, ContractReceipt, Contract, ContractFactory } from 'ethers'
import { BigNumber, Contract, ContractFactory, ContractReceipt, ContractTransaction, Event, utils } from 'ethers'

import { NonceManager } from '@ethersproject/experimental'
import { task } from 'hardhat/config'
Expand Down Expand Up @@ -47,7 +47,7 @@ export const askConfirm = async () => {
type: 'confirm',
message: `Are you sure you want to proceed?`,
})
return res.confirm
return res.confirm ? res.confirm as boolean : false
}

const isValidAddress = (address: string) => {
Expand All @@ -68,10 +68,10 @@ export const isValidAddressOrFail = (address: string) => {

const loadDeployData = (filepath: string): TokenLockConfigEntry[] => {
const data = fs.readFileSync(filepath, 'utf8')
const entries = data.split('\n').map((e) => e.trim())
const entries = data.split('\n').map(e => e.trim())
entries.shift() // remove the title from the csv
return entries
.filter((entryData) => !!entryData)
.filter(entryData => !!entryData)
.map((entryData) => {
const entry = entryData.split(',')
return {
Expand All @@ -89,9 +89,9 @@ const loadDeployData = (filepath: string): TokenLockConfigEntry[] => {

const loadResultData = (filepath: string): TokenLockConfigEntry[] => {
const data = fs.readFileSync(filepath, 'utf8')
const entries = data.split('\n').map((e) => e.trim())
const entries = data.split('\n').map(e => e.trim())
return entries
.filter((entryData) => !!entryData)
.filter(entryData => !!entryData)
.map((entryData) => {
const entry = entryData.split(',')
return {
Expand Down Expand Up @@ -246,7 +246,7 @@ const populateEntries = async (
tokenAddress: string,
ownerAddress: string,
) => {
const results = []
const results: TokenLockConfigEntry[] = []
for (const entry of entries) {
entry.owner = ownerAddress
entry.salt = await calculateSalt(hre, entry, managerAddress, tokenAddress)
Expand Down Expand Up @@ -323,7 +323,7 @@ task('create-token-locks', 'Create token lock contracts from file')
entries = await populateEntries(hre, entries, manager.address, tokenAddress, taskArgs.ownerAddress)

// Filter out already deployed ones
entries = entries.filter((entry) => !deployedEntries.find((deployedEntry) => deployedEntry.salt === entry.salt))
entries = entries.filter(entry => !deployedEntries.find(deployedEntry => deployedEntry.salt === entry.salt))
logger.success(`Total of ${entries.length} entries after removing already deployed. All good!`)
if (entries.length === 0) {
logger.warn('Nothing new to deploy')
Expand Down Expand Up @@ -378,7 +378,7 @@ task('create-token-locks', 'Create token lock contracts from file')
const queue = new PQueue({ concurrency: 6 })

for (const entry of entries) {
queue.add(async () => {
await queue.add(async () => {
logger.log('')
logger.info(`Creating contract...`)
logger.log(prettyConfigEntry(entry))
Expand Down
2 changes: 1 addition & 1 deletion packages/token-distribution/ops/delete.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { task } from 'hardhat/config'
import { HardhatRuntimeEnvironment } from 'hardhat/types'
import { prettyEnv, askConfirm, waitTransaction } from './create'
import { askConfirm, prettyEnv, waitTransaction } from './create'
import consola from 'consola'
import { TxBuilder } from './tx-builder'

Expand Down
Loading

0 comments on commit 09284ef

Please sign in to comment.