Skip to content
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

feat: add eslint to be run pre commit #3261

Merged
merged 7 commits into from
Nov 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 19 additions & 20 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,53 +17,52 @@
* limitations under the License.
*
*/
const path = require('path');

module.exports = {
"env": {
"node": true,
"es2021": true
"es2021": true,
},
"extends": [
"eslint:recommended",
"plugin:@typescript-eslint/recommended",
"prettier"
"prettier",
],
"plugins": ["simple-import-sort"],
"overrides": [
{
"env": {
"node": true
"node": true,
},
"files": [
".eslintrc.{js,cjs}"
".eslintrc.{js,cjs}",
],
"parserOptions": {
"sourceType": "script"
}
}
"sourceType": "script",
},
},
],
"parserOptions": {
"ecmaVersion": "latest",
"sourceType": "module"
"sourceType": "module",
},
"rules": {
"@typescript-eslint/ban-ts-comment": "off",
"@typescript-eslint/no-empty-interface": "off",
"@typescript-eslint/no-explicit-any": "off",
"@typescript-eslint/semi": "off",
"@typescript-eslint/no-var-requires": "warn",
"@typescript-eslint/no-unused-vars": "warn",
"@typescript-eslint/ban-types": "warn",
"no-trailing-spaces": "error",
"no-prototype-builtins": "warn",
"no-useless-escape": "warn",
"prefer-const": "error",
"no-unsafe-optional-chaining": "warn",
"comma-dangle": [2, "only-multiline"],
"semi": [2, "always"],
"sort-imports": ["error", {
"ignoreCase": true,
"ignoreDeclarationSort": true,
"ignoreMemberSort": false,
"memberSyntaxSortOrder": ["none", "all", "multiple", "single"],
"comma-dangle": ["error", {
"arrays": "always-multiline",
"objects": "always-multiline",
"imports": "always-multiline",
"exports": "always-multiline",
"functions": "always-multiline",
}],
"simple-import-sort/imports": "error",
"simple-import-sort/exports": "off",
},
};
2 changes: 1 addition & 1 deletion .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"

npx lint-staged
npx lint-staged --verbose
18 changes: 18 additions & 0 deletions package-lock.json

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

5 changes: 5 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
"eslint-config-standard-with-typescript": "^43.0.1",
"eslint-plugin-import": "^2.28.1",
"eslint-plugin-n": "^15.7.0",
"eslint-plugin-simple-import-sort": "^12.1.1",
"ethereum-waffle": "^4.0.7",
"husky": "^8.0.3",
"ioredis": "^5.3.2",
Expand Down Expand Up @@ -104,15 +105,19 @@
},
"lint-staged": {
"packages/**/src/**/*.ts": [
"eslint --fix",
"prettier --write"
],
"packages/**/tests/**/*.ts": [
"eslint --fix",
"prettier --write"
],
"!(packages/**/dist/)*.ts": [
"eslint --fix",
"prettier --write"
],
"!(packages/**/node_modules/)*.ts": [
"eslint --fix",
"prettier --write"
]
},
Expand Down
59 changes: 30 additions & 29 deletions packages/relay/tests/lib/sdkClient.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,32 +18,6 @@
*
*/

import pino from 'pino';
import Long from 'long';
import { expect } from 'chai';
import * as sinon from 'sinon';
import EventEmitter from 'events';
import { Utils } from '../../src/utils';
import axios, { AxiosInstance } from 'axios';
import MockAdapter from 'axios-mock-adapter';
import constants from '../../src/lib/constants';
import { register, Registry } from 'prom-client';
import { RequestDetails } from '../../src/lib/types';
import { formatTransactionId } from '../../src/formatters';
import { MirrorNodeClient, SDKClient } from '../../src/lib/clients';
import HAPIService from '../../src/lib/services/hapiService/hapiService';
import { HbarLimitService } from '../../src/lib/services/hbarLimitService';
import MetricService from '../../src/lib/services/metricService/metricService';
import { CacheService } from '../../src/lib/services/cacheService/cacheService';
import {
calculateTxRecordChargeAmount,
overrideEnvsInMochaDescribe,
random20BytesAddress,
withOverriddenEnvsInMochaTest,
} from '../helpers';
import { HbarSpendingPlanRepository } from '../../src/lib/db/repositories/hbarLimiter/hbarSpendingPlanRepository';
import { IPAddressHbarSpendingPlanRepository } from '../../src/lib/db/repositories/hbarLimiter/ipAddressHbarSpendingPlanRepository';
import { EthAddressHbarSpendingPlanRepository } from '../../src/lib/db/repositories/hbarLimiter/ethAddressHbarSpendingPlanRepository';
import { ConfigService } from '@hashgraph/json-rpc-config-service/dist/services';
import {
AccountId,
Expand All @@ -64,7 +38,34 @@ import {
TransactionRecordQuery,
TransactionResponse,
} from '@hashgraph/sdk';
import axios, { AxiosInstance } from 'axios';
import MockAdapter from 'axios-mock-adapter';
import { expect } from 'chai';
import EventEmitter from 'events';
import Long from 'long';
import { Context } from 'mocha';
import pino from 'pino';
import { register, Registry } from 'prom-client';
import * as sinon from 'sinon';

import { formatTransactionId } from '../../src/formatters';
import { MirrorNodeClient, SDKClient } from '../../src/lib/clients';
import constants from '../../src/lib/constants';
import { EthAddressHbarSpendingPlanRepository } from '../../src/lib/db/repositories/hbarLimiter/ethAddressHbarSpendingPlanRepository';
import { HbarSpendingPlanRepository } from '../../src/lib/db/repositories/hbarLimiter/hbarSpendingPlanRepository';
import { IPAddressHbarSpendingPlanRepository } from '../../src/lib/db/repositories/hbarLimiter/ipAddressHbarSpendingPlanRepository';
import { CacheService } from '../../src/lib/services/cacheService/cacheService';
import HAPIService from '../../src/lib/services/hapiService/hapiService';
import { HbarLimitService } from '../../src/lib/services/hbarLimitService';
import MetricService from '../../src/lib/services/metricService/metricService';
import { RequestDetails } from '../../src/lib/types';
import { Utils } from '../../src/utils';
import {
calculateTxRecordChargeAmount,
overrideEnvsInMochaDescribe,
random20BytesAddress,
withOverriddenEnvsInMochaTest,
} from '../helpers';

const registry = new Registry();
const logger = pino();
Expand Down Expand Up @@ -181,7 +182,7 @@ describe('SdkClient', async function () {

it('executes the query', async () => {
queryStub.returns(successResponse);
let { resp, cost } = await sdkClient.increaseCostAndRetryExecution(
const { resp, cost } = await sdkClient.increaseCostAndRetryExecution(
contractCallQuery,
baseCost,
client,
Expand All @@ -200,7 +201,7 @@ describe('SdkClient', async function () {
});

queryStub.onCall(1).returns(successResponse);
let { resp, cost } = await sdkClient.increaseCostAndRetryExecution(
const { resp, cost } = await sdkClient.increaseCostAndRetryExecution(
contractCallQuery,
baseCost,
client,
Expand All @@ -224,7 +225,7 @@ describe('SdkClient', async function () {

queryStub.onCall(2).returns(successResponse);

let { resp, cost } = await sdkClient.increaseCostAndRetryExecution(
const { resp, cost } = await sdkClient.increaseCostAndRetryExecution(
contractCallQuery,
baseCost,
client,
Expand Down
Loading