Skip to content

Commit

Permalink
Linter update and fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
chudilka1 committed Oct 13, 2023
2 parents b999ab1 + 1a046ab commit d5ed5fb
Show file tree
Hide file tree
Showing 12 changed files with 33 additions and 71 deletions.
4 changes: 3 additions & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,7 @@ module.exports = {
sourceType: 'module',
},
plugins: ['@typescript-eslint'],
rules: {},
rules: {
'@typescript-eslint/ban-ts-comment': 'off',
},
}
Original file line number Diff line number Diff line change
@@ -1,21 +1,16 @@
name: Lint Check

on:
pull_request:

jobs:
lint:
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v2

- name: Set up Node.js
uses: actions/setup-node@v2
with:
node-version: 18

- name: Install dependencies
run: npm install # npm install instead of npm ci is used to prevent unsupported platform errors due to the fsevents sub-dependency --no-optional

Expand Down
10 changes: 1 addition & 9 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 5 additions & 13 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@
"test": "jest",
"test:ci": "jest --coverage",
"test:package": "jest --config jest.config.package.js",
"lint:check": "eslint --ext js,jsx,ts,tsx .",
"lint:ci": "eslint --ext js,jsx,ts,tsx . -f json -o eslint-report.json",
"lint:fix": "eslint --ext js,jsx,ts,tsx . --fix",
"lint:check": "eslint '{src,test}/**/*.ts'",
"lint:fix": "eslint '{src,test}/**/*.ts' --fix",
"lint:ci": "eslint '{src,test}/**/*.ts' --max-warnings=0 -f json -o eslint-report.json",
"prettier:check": "prettier --check . && tsc --noEmit",
"prettier:fix": "npx prettier -w ."
},
Expand All @@ -36,29 +36,21 @@
],
"homepage": "https://github.com/smartcontractkit/functions-toolkit#readme",
"devDependencies": {
"@babel/core": "7.21.8",
"@babel/preset-env": "7.21.5",
"@babel/preset-typescript": "7.21.5",
"@changesets/changelog-github": "^0.4.8",
"@changesets/cli": "^2.26.2",
"@types/jest": "^29.5.1",
"@types/node": "^18.16.3",
"@types/prettier": "^2.7.2",
"cpy-cli": "^5.0.0",
"@typescript-eslint/eslint-plugin": "^6.7.5",
"@typescript-eslint/parser": "^6.7.5",
"babel-loader": "9.1.2",
"browserify": "17.0.0",
"cpy-cli": "^5.0.0",
"eslint": "^8.51.0",
"esmify": "2.1.1",
"jest": "^29.5.0",
"nock": "^13.3.1",
"prettier": "^2.8.8",
"rimraf": "^5.0.1",
"ts-jest": "^29.1.0",
"typescript": "^5.0.4",
"webpack": "5.82.1",
"webpack-cli": "5.1.1"
"typescript": "^5.0.4"
},
"prettier": {
"printWidth": 100,
Expand Down
4 changes: 2 additions & 2 deletions sonar-project.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ sonar.projectKey=smartcontractkit_functions-toolkit
sonar.sources=.

# Full exclusions from the static analysis
sonar.exclusions=**/node_modules/**/*, **/mocks/**/*, **/testdata/**/*, **/demo/**/*, **/contracts/**/*, **/generated/**/*, **/fixtures/**/*, **/docs/**/*, **/tools/**/*, **/*.fixtures.ts, **/apiFixture.ts, **/*report.xml, **/*.config.ts, **/*.txt, **/*.abi, **/*.bin, **/decodeResult.ts, **/types.ts
sonar.exclusions=**/node_modules/**/*, **/mocks/**/*, **/testdata/**/*, **/demo/**/*, **/contracts/**/*, **/generated/**/*, **/fixtures/**/*, **/docs/**/*, **/tools/**/*, **/*.fixtures.ts, **/apiFixture.ts, **/*report.xml, **/*.config.ts, **/*.config.js, **/*.txt, **/*.abi, **/*.bin
# Coverage exclusions
sonar.coverage.exclusions=**/*.test.ts, **/test/**/*, **/contracts/**/*, **/testutils/**/*, **/test/integration/**/*, **/*.config.js, **/*.config.ts,
sonar.coverage.exclusions=**/*.test.ts, **/test/**/*

# Tests' root folder, inclusions (tests to check and count) and exclusions
sonar.tests=.
Expand Down
4 changes: 1 addition & 3 deletions test/integration/fetchRequestCommitment.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { fetchRequestCommitment, RequestCommitment, SubscriptionManager } from '../../src'
import { fetchRequestCommitment, SubscriptionManager } from '../../src'
import { setupLocalTestnetFixture } from '../utils'

import { Contract, Wallet, utils, providers } from 'ethers'
Expand All @@ -7,7 +7,6 @@ describe('fetchRequestCommitment', () => {
let donId: string
let linkTokenAddress: string
let functionsRouterAddress: string
let functionsCoordinatorAddress: string
let exampleClient: Contract
let close: () => Promise<void>
let allowlistedUser_A: Wallet
Expand All @@ -17,7 +16,6 @@ describe('fetchRequestCommitment', () => {
donId = testSetup.donId
linkTokenAddress = testSetup.linkTokenAddress
functionsRouterAddress = testSetup.functionsRouterAddress
functionsCoordinatorAddress = testSetup.functionsCoordinator.address
exampleClient = testSetup.exampleConsumer
close = testSetup.close
allowlistedUser_A = testSetup.user_A
Expand Down
8 changes: 5 additions & 3 deletions test/integration/integration.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ describe('Functions toolkit classes', () => {

const subscriptionId = await subscriptionManager.createSubscription()

const addTx = await subscriptionManager.addConsumer({
await subscriptionManager.addConsumer({
subscriptionId,
consumerAddress,
txOptions: {
Expand All @@ -197,7 +197,7 @@ describe('Functions toolkit classes', () => {

const subscriptionIdBigInt = await subscriptionManager.createSubscription()
const subscriptionId = subscriptionIdBigInt.toString()
const addConsumerTxReceipt = await subscriptionManager.addConsumer({
await subscriptionManager.addConsumer({
subscriptionId,
consumerAddress,
})
Expand Down Expand Up @@ -279,7 +279,7 @@ describe('Functions toolkit classes', () => {
await subscriptionManager_B.initialize()

const unOwnedSubId = await subscriptionManager_A.createSubscription()
const _ = await subscriptionManager_B.createSubscription()
await subscriptionManager_B.createSubscription()

await expect(async () => {
await subscriptionManager_B.addConsumer({ subscriptionId: unOwnedSubId, consumerAddress })
Expand Down Expand Up @@ -1393,6 +1393,7 @@ describe('Functions toolkit classes', () => {
const sm = new SecretsManager({ signer: allowlistedUser_A, functionsRouterAddress, donId })
expect(() =>
sm.buildDONHostedEncryptedSecretsReference({
// eslint-disable-next-line @typescript-eslint/no-explicit-any
slotId: 'invalid' as any,
version: 1,
}),
Expand All @@ -1418,6 +1419,7 @@ describe('Functions toolkit classes', () => {
expect(() =>
sm.buildDONHostedEncryptedSecretsReference({
slotId: 1,
// eslint-disable-next-line @typescript-eslint/no-explicit-any
version: 'invalid' as any,
}),
).toThrow('Invalid version')
Expand Down
7 changes: 7 additions & 0 deletions test/unit/buildRequestCBOR.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ describe('buildRequestCBOR', () => {
codeLocation: 'invalid',
codeLanguage: 0,
source: 'test',
// eslint-disable-next-line @typescript-eslint/no-explicit-any
} as any),
).toThrow('Invalid codeLocation')

Expand All @@ -40,6 +41,7 @@ describe('buildRequestCBOR', () => {
codeLocation: 0,
codeLanguage: 'invalid',
source: 'test',
// eslint-disable-next-line @typescript-eslint/no-explicit-any
} as any),
).toThrow('Invalid codeLanguage')

Expand All @@ -48,6 +50,7 @@ describe('buildRequestCBOR', () => {
codeLocation: 0,
codeLanguage: 1,
source: 'test',
// eslint-disable-next-line @typescript-eslint/no-explicit-any
} as any),
).toThrow('Invalid codeLanguage')
})
Expand All @@ -57,6 +60,7 @@ describe('buildRequestCBOR', () => {
buildRequestCBOR({
codeLocation: 0,
codeLanguage: 0,
// eslint-disable-next-line @typescript-eslint/no-explicit-any
source: 123 as any,
}),
).toThrow('Invalid source')
Expand All @@ -82,6 +86,7 @@ describe('buildRequestCBOR', () => {
source: 'test',
encryptedSecretsReference: '0xabcdef',
secretsLocation: 3,
// eslint-disable-next-line @typescript-eslint/no-explicit-any
} as any),
).toThrow('Invalid secretsLocation')
})
Expand All @@ -92,6 +97,7 @@ describe('buildRequestCBOR', () => {
codeLocation: 0,
codeLanguage: 0,
source: 'test',
// eslint-disable-next-line @typescript-eslint/no-explicit-any
args: [123 as any],
}),
).toThrow('Invalid args')
Expand All @@ -101,6 +107,7 @@ describe('buildRequestCBOR', () => {
codeLocation: 0,
codeLanguage: 0,
source: 'test',
// eslint-disable-next-line @typescript-eslint/no-explicit-any
args: ['valid', 123 as any],
}),
).toThrow('Invalid args')
Expand Down
3 changes: 2 additions & 1 deletion test/unit/decode_result.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,8 @@ describe('decodeResult', () => {
it('throws error if expectedDataType is invalid', () => {
// @ts-ignore
expect(() => decodeResult('0x123ABC', 'invalid')).toThrow(
/not valid. Must be one of the following/,
// eslint-disable-next-line no-regex-spaces
/not valid. Must be one of the following/,
)
})
it('throws with invalid hex', () => {
Expand Down
6 changes: 6 additions & 0 deletions test/unit/simulateScript.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,7 @@ describe('simulateScript', () => {
describe('validation errors', () => {
it('should throw error for invalid source', async () => {
const result = simulateScript({
// eslint-disable-next-line @typescript-eslint/no-explicit-any
source: 123 as any,
})

Expand All @@ -248,6 +249,7 @@ describe('simulateScript', () => {
it('should throw error for invalid secrets', async () => {
const result = simulateScript({
source: `return`,
// eslint-disable-next-line @typescript-eslint/no-explicit-any
secrets: { bad: 1 } as any,
})

Expand All @@ -257,6 +259,7 @@ describe('simulateScript', () => {
it('should throw error for invalid args', async () => {
const result = simulateScript({
source: `return`,
// eslint-disable-next-line @typescript-eslint/no-explicit-any
args: 123 as any,
})

Expand All @@ -266,6 +269,7 @@ describe('simulateScript', () => {
it('should throw error when an element of args is not a string', async () => {
const result = simulateScript({
source: `return`,
// eslint-disable-next-line @typescript-eslint/no-explicit-any
args: [123] as any,
})

Expand All @@ -275,6 +279,7 @@ describe('simulateScript', () => {
it('should throw error for invalid bytesArgs', async () => {
const result = simulateScript({
source: `return`,
// eslint-disable-next-line @typescript-eslint/no-explicit-any
bytesArgs: 123 as any,
})

Expand All @@ -284,6 +289,7 @@ describe('simulateScript', () => {
it('should throw error when an element of bytesArgs is not a hex string', async () => {
const result = simulateScript({
source: `return`,
// eslint-disable-next-line @typescript-eslint/no-explicit-any
bytesArgs: ['invalid'] as any,
})

Expand Down
1 change: 1 addition & 0 deletions test/utils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ export const setupLocalTestnetFixture = async (
utils.formatBytes32String(localFunctionsTestnet.donId),
)

// eslint-disable-next-line @typescript-eslint/no-unused-vars
const [_admin, user_A, user_B_NoLINK, subFunder, _] = createTestWallets(
localFunctionsTestnet.server,
port,
Expand Down
34 changes: 0 additions & 34 deletions webpack.config.js

This file was deleted.

0 comments on commit d5ed5fb

Please sign in to comment.