Skip to content

Commit 09284ef

Browse files
authored
feat(eslint): properly ignore paths in ignores config (#957)
* 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]>
1 parent fce8f74 commit 09284ef

16 files changed

+75
-57
lines changed

packages/eslint-graph-config/README.md

+6
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,12 @@ module.exports = [
4040
'@typescript-eslint/no-unsafe-argument': 'off',
4141
},
4242
},
43+
{
44+
ignores: [
45+
'library/*', // ignore its contents
46+
'!node_modules/mylibrary/' // unignore `node_modules/mylibrary` directory
47+
]
48+
}
4349
]
4450
```
4551

packages/eslint-graph-config/index.ts

+3-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ export default [
3131
'no-only-tests': noOnlyTests,
3232
'no-secrets': noSecrets,
3333
},
34-
ignores: ['dist/*', 'node_modules/*', 'build/*'],
3534
rules: {
3635
'prefer-const': 'warn',
3736
'@typescript-eslint/no-inferrable-types': 'warn',
@@ -47,4 +46,7 @@ export default [
4746
'@stylistic/brace-style': ['error', '1tbs'],
4847
},
4948
},
49+
{
50+
ignores: ['**/dist/*', '**/node_modules/*', '**/build/*', '**/cache/*', '**/.graphclient/*'],
51+
},
5052
]

packages/token-distribution/deploy/1_test.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,14 @@ import { utils } from 'ethers'
22
import consola from 'consola'
33

44
import { HardhatRuntimeEnvironment } from 'hardhat/types'
5-
import { DeployFunction } from 'hardhat-deploy/types'
5+
import { DeployFunction, DeployOptions } from 'hardhat-deploy/types'
66

77
const { parseEther } = utils
88

99
const logger = consola.create({})
1010

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

1515
// -- Fake Graph Token --

packages/token-distribution/deploy/2_l1_manager_wallet.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { utils } from 'ethers'
33

44
import '@nomiclabs/hardhat-ethers'
55
import { HardhatRuntimeEnvironment } from 'hardhat/types'
6-
import { DeployFunction } from 'hardhat-deploy/types'
6+
import { DeployFunction, DeployOptions } from 'hardhat-deploy/types'
77

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

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

2020
// -- Graph Token --

packages/token-distribution/deploy/3_l2_wallet.ts

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,14 @@
11
import consola from 'consola'
22
import '@nomiclabs/hardhat-ethers'
33
import { HardhatRuntimeEnvironment } from 'hardhat/types'
4-
import { DeployFunction } from 'hardhat-deploy/types'
4+
import { DeployFunction, DeployOptions } from 'hardhat-deploy/types'
55

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

8-
98
const logger = consola.create({})
109

1110
const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
12-
const { deploy } = hre.deployments
11+
const deploy = (name: string, options: DeployOptions) => hre.deployments.deploy(name, options)
1312
const { deployer } = await hre.getNamedAccounts()
1413

1514
// Deploy the master copy of GraphTokenLockWallet

packages/token-distribution/deploy/4_l1_transfer_tool.ts

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import consola from 'consola'
2-
import { utils } from 'ethers'
32

43
import '@nomiclabs/hardhat-ethers'
54
import { HardhatRuntimeEnvironment } from 'hardhat/types'
@@ -50,12 +49,12 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
5049
owner = deployer
5150
logger.warn(`No owner address provided, will use the deployer address as owner: ${owner}`)
5251
}
53-
52+
5453
// Deploy the L1GraphTokenLockTransferTool with a proxy.
5554
// hardhat-deploy doesn't get along with constructor arguments in the implementation
5655
// combined with an OpenZeppelin transparent proxy, so we need to do this using
5756
// the OpenZeppelin hardhat-upgrades tooling, and save the deployment manually.
58-
57+
5958
// TODO modify this to use upgradeProxy if a deployment already exists?
6059
logger.info('Deploying L1GraphTokenLockTransferTool proxy...')
6160
const transferToolFactory = await ethers.getContractFactory('L1GraphTokenLockTransferTool')

packages/token-distribution/deploy/5_l2_manager.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { utils } from 'ethers'
33

44
import '@nomiclabs/hardhat-ethers'
55
import { HardhatRuntimeEnvironment } from 'hardhat/types'
6-
import { DeployFunction } from 'hardhat-deploy/types'
6+
import { DeployFunction, DeployOptions } from 'hardhat-deploy/types'
77

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

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

2020
// -- Graph Token --

packages/token-distribution/deploy/6_l2_transfer_tool.ts

+2-5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import consola from 'consola'
2-
import { utils } from 'ethers'
32

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

2019
const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
21-
const { deployer } = await hre.getNamedAccounts()
22-
2320
// -- Graph Token --
2421

2522
// Get the addresses we will use
@@ -40,12 +37,12 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
4037
logger.warn('No L1 GRT address provided')
4138
process.exit(1)
4239
}
43-
40+
4441
// Deploy the L2GraphTokenLockTransferTool with a proxy.
4542
// hardhat-deploy doesn't get along with constructor arguments in the implementation
4643
// combined with an OpenZeppelin transparent proxy, so we need to do this using
4744
// the OpenZeppelin hardhat-upgrades tooling, and save the deployment manually.
48-
45+
4946
// TODO modify this to use upgradeProxy if a deployment already exists?
5047
logger.info('Deploying L2GraphTokenLockTransferTool proxy...')
5148
const transferToolFactory = await ethers.getContractFactory('L2GraphTokenLockTransferTool')

packages/token-distribution/deploy/lib/utils.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@ export const askConfirm = async (message: string) => {
1212
type: 'confirm',
1313
message,
1414
})
15-
return res.confirm
15+
return res.confirm ? res.confirm as boolean : false
1616
}
1717

18-
export const promptContractAddress = async (name: string, logger: Consola): Promise<string|null> => {
18+
export const promptContractAddress = async (name: string, logger: Consola): Promise<string | null> => {
1919
const res1 = await inquirer.prompt({
2020
name: 'contract',
2121
type: 'input',
@@ -37,5 +37,5 @@ export const getDeploymentName = async (defaultName: string): Promise<string> =>
3737
default: defaultName,
3838
message: 'Save deployment as?',
3939
})
40-
return res['deployment-name']
40+
return res['deployment-name'] as string
4141
}

packages/token-distribution/hardhat.config.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ function setupNetworkConfig(config) {
8080

8181
// Env
8282

83+
// eslint-disable-next-line @typescript-eslint/no-misused-promises
8384
extendEnvironment(async (hre) => {
8485
const accounts = await hre.ethers.getSigners()
8586
try {
@@ -152,7 +153,6 @@ const config = {
152153
},
153154
},
154155
etherscan: {
155-
//url: process.env.ETHERSCAN_API_URL,
156156
apiKey: process.env.ETHERSCAN_API_KEY,
157157
customChains: [
158158
{
@@ -163,7 +163,7 @@ const config = {
163163
browserURL: 'https://sepolia.arbiscan.io',
164164
},
165165
},
166-
]
166+
],
167167
},
168168
typechain: {
169169
outDir: 'build/typechain/contracts',

packages/token-distribution/ops/create.ts

+9-9
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import PQueue from 'p-queue'
22
import fs from 'fs'
33
import consola from 'consola'
44
import inquirer from 'inquirer'
5-
import { utils, BigNumber, Event, ContractTransaction, ContractReceipt, Contract, ContractFactory } from 'ethers'
5+
import { BigNumber, Contract, ContractFactory, ContractReceipt, ContractTransaction, Event, utils } from 'ethers'
66

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

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

6969
const loadDeployData = (filepath: string): TokenLockConfigEntry[] => {
7070
const data = fs.readFileSync(filepath, 'utf8')
71-
const entries = data.split('\n').map((e) => e.trim())
71+
const entries = data.split('\n').map(e => e.trim())
7272
entries.shift() // remove the title from the csv
7373
return entries
74-
.filter((entryData) => !!entryData)
74+
.filter(entryData => !!entryData)
7575
.map((entryData) => {
7676
const entry = entryData.split(',')
7777
return {
@@ -89,9 +89,9 @@ const loadDeployData = (filepath: string): TokenLockConfigEntry[] => {
8989

9090
const loadResultData = (filepath: string): TokenLockConfigEntry[] => {
9191
const data = fs.readFileSync(filepath, 'utf8')
92-
const entries = data.split('\n').map((e) => e.trim())
92+
const entries = data.split('\n').map(e => e.trim())
9393
return entries
94-
.filter((entryData) => !!entryData)
94+
.filter(entryData => !!entryData)
9595
.map((entryData) => {
9696
const entry = entryData.split(',')
9797
return {
@@ -246,7 +246,7 @@ const populateEntries = async (
246246
tokenAddress: string,
247247
ownerAddress: string,
248248
) => {
249-
const results = []
249+
const results: TokenLockConfigEntry[] = []
250250
for (const entry of entries) {
251251
entry.owner = ownerAddress
252252
entry.salt = await calculateSalt(hre, entry, managerAddress, tokenAddress)
@@ -323,7 +323,7 @@ task('create-token-locks', 'Create token lock contracts from file')
323323
entries = await populateEntries(hre, entries, manager.address, tokenAddress, taskArgs.ownerAddress)
324324

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

380380
for (const entry of entries) {
381-
queue.add(async () => {
381+
await queue.add(async () => {
382382
logger.log('')
383383
logger.info(`Creating contract...`)
384384
logger.log(prettyConfigEntry(entry))

packages/token-distribution/ops/delete.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { task } from 'hardhat/config'
22
import { HardhatRuntimeEnvironment } from 'hardhat/types'
3-
import { prettyEnv, askConfirm, waitTransaction } from './create'
3+
import { askConfirm, prettyEnv, waitTransaction } from './create'
44
import consola from 'consola'
55
import { TxBuilder } from './tx-builder'
66

0 commit comments

Comments
 (0)