Skip to content

Commit

Permalink
build: eslint, tslint, prettier consolidation, purge from non-root pkgs
Browse files Browse the repository at this point in the history
1. We had dozens of different versions of ESLint, TSLint, Prettier
declard in package.json files. Most versions were so old that they had
ben EOL for several years too.
2. The presence of these and their scripts/config files/etc were making
it impossible to run the linter on the sub-folders where these were
being used.
3. As part of the big push to consolidate linting and code formatting on
the entire project, this is phase 1 where I purged the mentioned dependencies
from the project and now only the root package.json file declares them
which is currently using the latest and greatest versions.
4. I know that the diff is huge in this pull request but there are no
code changes that would cause bugs or logic modification at all. It's all
just applying automated formatting and linting on sub-directories where
previously this was impossible. E.g., this entire change should not cause
any sort of bugs (but of course we'll see what the CI execution has to
say about that).
5. The follow-up phases will consist of slowly applying more brazen
refactoring in a much more targeted and surgical manner with small
pull requests that are easy and quick to review.
6. The smaller pull requests will target sub-directories that we still
cannot include in the linting (see the .eslintignore file for a list) and
then culminate in us finally enabling the linter for everything.
7. The root folder's ESLint ignore file was refactored in a way that the
files that we plan on fixing later are now ignored on a one by one basis
instead of using patterns. This makes the ignore file a collection of
to-dos where one can delete a single line from the ignore file (pertaining
to a single file that is being ignored) and then proceed to fix the linter
issues and send a small, easy to review pull request that does not overwhelm
the maintainers when they are trying to review a huge diff with a large
batch of linter fixes. Phase two of this project is then to one by one
drain the ignore entries of these mentioned files from the ESLint ignore
file.

So, the bottom line is that this might look like a hugely disruptive
change, but I've done my best to keep it as simple as possible so that
we don't have to worry about reviewing it line by line and instead just
focus on the big picture and the principle idea(s) behind it (code quality).

If it does end up introducing a bug or CI breakage, I'll volunteer to fix
those because I'm very confident that even if this does happen, it will
be very minor and quick fixes necessary only so I don't mind being on the
hook for it.

Signed-off-by: Peter Somogyvari <peter.somogyvari@accenture.com>
  • Loading branch information
petermetz committed Mar 12, 2024
1 parent 9667f4e commit e4a8a66
Show file tree
Hide file tree
Showing 221 changed files with 18,630 additions and 16,876 deletions.
111 changes: 106 additions & 5 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -1,11 +1,112 @@
**/node_modules/**
**/dist/**

examples/cactus-example-carbon-accounting-frontend/www/
examples/cactus-example-supply-chain-frontend/www/

**/src/main/typescript/generated/proto/**
**/src/main/typescript/generated/wasm-pack/**
packages/cactus-verifier/src/main/typescript/

packages/cactus-cmd-socketio-server/**
packages/cactus-plugin-ledger-connector-go-ethereum-socketio/**
packages/cactus-plugin-ledger-connector-*-socketio/**
packages/cactus-cmd-socketio-server/src/main/typescript/business-logic-plugin/BusinessLogicBase.ts
packages/cactus-cmd-socketio-server/src/main/typescript/business-logic-plugin/LedgerOperation.ts
packages/cactus-cmd-socketio-server/src/main/typescript/business-logic-plugin/app.ts
packages/cactus-cmd-socketio-server/src/main/typescript/routing-interface/TransactionManagement.ts
packages/cactus-cmd-socketio-server/src/main/typescript/routing-interface/routes/login.ts
packages/cactus-cmd-socketio-server/src/main/typescript/routing-interface/util/BLPRegistry.ts
packages/cactus-cmd-socketio-server/src/main/typescript/routing-interface/util/ConfigUtil.ts
packages/cactus-cmd-socketio-server/src/main/typescript/routing-interface/util/ContractInfoHolder.ts
packages/cactus-cmd-socketio-server/src/main/typescript/routing-interface/util/LPInfoHolder.ts
packages/cactus-cmd-socketio-server/src/main/typescript/routing-interface/util/RIFUtil.ts
packages/cactus-cmd-socketio-server/src/main/typescript/verifier/DriverCommon.ts
packages/cactus-cmd-socketio-server/src/main/typescript/verifier/Verifier.ts

packages/cactus-cmd-socketio-server/src/main/typescript/verifier/VerifierFactory.ts
packages/cactus-cmd-socketio-server/src/test/typescript/unit/Verifier.test.ts

packages/cactus-plugin-ledger-connector-go-ethereum-socketio/src/main/typescript/common/core/app.ts
packages/cactus-plugin-ledger-connector-go-ethereum-socketio/src/main/typescript/common/core/bin/www.ts
packages/cactus-plugin-ledger-connector-go-ethereum-socketio/src/main/typescript/connector/template/ServerMonitorPlugin_template.ts
packages/cactus-plugin-ledger-connector-go-ethereum-socketio/src/main/typescript/connector/template/ServerPlugin_template.ts
packages/cactus-plugin-ledger-connector-go-ethereum-socketio/src/test/typescript/unit-test/validatorDriver_getNonceHex.ts
packages/cactus-plugin-ledger-connector-go-ethereum-socketio/src/test/typescript/unit-test/validatorDriver_sendRawTransaction.ts
packages/cactus-plugin-ledger-connector-go-ethereum-socketio/src/test/typescript/unit-test/validatorDriver_transferNumericAsset.ts
packages/cactus-plugin-ledger-connector-tcs-huawei-socketio/src/main/typescript/common/core/app.ts
packages/cactus-plugin-ledger-connector-tcs-huawei-socketio/src/main/typescript/connector/ServerMonitorPlugin.ts

weaver/**
weaver/common/policy-dsl/index.js
weaver/common/policy-dsl/parser/PolicyListener.js
weaver/common/policy-dsl/parser/PolicyParser.js
weaver/common/policy-dsl/test/MyErrorListener.js
weaver/common/policy-dsl/test/MyParseTreeVisitor.js
weaver/core/drivers/fabric-driver/server/dbConnector.ts
weaver/core/drivers/fabric-driver/server/events.ts
weaver/core/drivers/fabric-driver/server/fabric-code.ts
weaver/core/drivers/fabric-driver/server/listener.ts
weaver/core/drivers/fabric-driver/server/server.ts
weaver/core/drivers/fabric-driver/server/tests.ts
weaver/core/drivers/fabric-driver/server/utils.ts
weaver/core/drivers/fabric-driver/server/walletSetup.ts
weaver/core/identity-management/iin-agent/src/common/ledgerBase.ts
weaver/core/identity-management/iin-agent/src/common/utils.ts
weaver/core/identity-management/iin-agent/src/fabric-ledger/connector.ts
weaver/core/identity-management/iin-agent/src/fabric-ledger/networkUtils.ts
weaver/core/identity-management/iin-agent/src/fabric-ledger/walletUtils.ts
weaver/core/identity-management/iin-agent/src/protocols/externalOperations.ts
weaver/core/identity-management/iin-agent/src/protocols/localOperations.ts
weaver/core/identity-management/iin-agent/src/server.ts
weaver/core/identity-management/iin-agent/test/membershipTest.js
weaver/core/identity-management/iin-agent/test/utilsTest.js
weaver/samples/besu/besu-cli/src/commands/asset/claim.ts
weaver/samples/besu/besu-cli/src/commands/asset/exchange.ts
weaver/samples/besu/besu-cli/src/commands/asset/issue.ts
weaver/samples/besu/besu-cli/src/commands/asset/lock.ts
weaver/samples/besu/besu-cli/src/commands/asset/unlock.ts
weaver/samples/besu/simpleasset/app/AssetExchangeERC1155_20.js
weaver/samples/besu/simpleasset/app/AssetExchangeERC20.js
weaver/samples/besu/simpleasset/app/AssetExchangeERC721_20.js
weaver/samples/besu/simpleasset/get-network-details.js
weaver/samples/besu/simplestate/get-network-details.js
weaver/samples/fabric/fabric-cli/src/commands/asset/exchange-all.ts
weaver/samples/fabric/fabric-cli/src/commands/asset/exchange/claim.ts
weaver/samples/fabric/fabric-cli/src/commands/asset/exchange/is-locked.ts
weaver/samples/fabric/fabric-cli/src/commands/asset/exchange/lock.ts
weaver/samples/fabric/fabric-cli/src/commands/asset/exchange/unlock.ts
weaver/samples/fabric/fabric-cli/src/commands/asset/transfer/claim.ts
weaver/samples/fabric/fabric-cli/src/commands/asset/transfer/pledge.ts
weaver/samples/fabric/fabric-cli/src/commands/asset/transfer/reclaim.ts
weaver/samples/fabric/fabric-cli/src/commands/chaincode/invoke.ts
weaver/samples/fabric/fabric-cli/src/commands/chaincode/query.ts
weaver/samples/fabric/fabric-cli/src/commands/config-helper.ts
weaver/samples/fabric/fabric-cli/src/commands/configure/asset/add.ts
weaver/samples/fabric/fabric-cli/src/commands/configure/create/access-control.ts
weaver/samples/fabric/fabric-cli/src/commands/configure/create/all.ts
weaver/samples/fabric/fabric-cli/src/commands/configure/create/membership.ts
weaver/samples/fabric/fabric-cli/src/commands/configure/create/verification-policy.ts
weaver/samples/fabric/fabric-cli/src/commands/configure/membership.ts
weaver/samples/fabric/fabric-cli/src/commands/configure/network.ts
weaver/samples/fabric/fabric-cli/src/commands/env-helper.ts
weaver/samples/fabric/fabric-cli/src/commands/event/get-all.ts
weaver/samples/fabric/fabric-cli/src/commands/event/get-subscription-status.ts
weaver/samples/fabric/fabric-cli/src/commands/event/receive.ts
weaver/samples/fabric/fabric-cli/src/commands/event/subscribe.ts
weaver/samples/fabric/fabric-cli/src/commands/event/unsubscribe.ts
weaver/samples/fabric/fabric-cli/src/commands/hash-helper.ts
weaver/samples/fabric/fabric-cli/src/commands/helper-helper.ts
weaver/samples/fabric/fabric-cli/src/commands/helper/getKeyAndCert.ts
weaver/samples/fabric/fabric-cli/src/commands/interop-helper.ts
weaver/samples/fabric/fabric-cli/src/commands/user-helper.ts
weaver/samples/fabric/fabric-cli/src/commands/user/add.ts
weaver/samples/fabric/fabric-cli/src/helpers/fabric-functions.ts
weaver/samples/fabric/fabric-cli/src/helpers/helpers.ts
weaver/samples/fabric/fabric-cli/src/helpers/interop-setup/configure-network.ts
weaver/sdks/besu/node/src/AssetManager.ts
weaver/sdks/fabric/interoperation-node-sdk/src/AssetManager.ts
weaver/sdks/fabric/interoperation-node-sdk/src/EventsManager.ts
weaver/sdks/fabric/interoperation-node-sdk/src/HashFunctions.ts
weaver/sdks/fabric/interoperation-node-sdk/src/InteroperableHelper.ts
weaver/sdks/fabric/interoperation-node-sdk/src/MembershipManager.ts
weaver/sdks/fabric/interoperation-node-sdk/src/Relay.ts
weaver/sdks/fabric/interoperation-node-sdk/src/helpers.ts
weaver/sdks/fabric/interoperation-node-sdk/test/AssetManager.js
weaver/sdks/fabric/interoperation-node-sdk/test/InteroperableHelper.js
weaver/sdks/fabric/interoperation-node-sdk/test/Relay.js
6 changes: 5 additions & 1 deletion .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,8 @@
packages/core
packages/connection-chain
contribs/
**/src/main/typescript/generated/**
**/src/main/typescript/generated/**

# TODO: Send a PR that moves these generated code files under a sub-directory
# that is called "generated" so that the default ignore pattern above matches it
packages/cactus-plugin-ledger-connector-sawtooth/src/main/typescript/sawtooth-api/**
2 changes: 1 addition & 1 deletion .prettierrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ module.exports = {
tabWidth: 2,
trailingComma: "all",
singleQuote: false,
};
};

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
"npm": ">=5"
},
"scripts": {
"lint": "eslint .",
"test": "nyc mocha --recursive",
"mocha": "mocha --recursive",
"start": "fabric-chaincode-node start"
Expand All @@ -24,7 +23,6 @@
"@types/sinon-chai": "^3.2.8",
"chai": "^4.1.2",
"chai-as-promised": "^7.1.1",
"eslint": "^4.19.1",
"mocha": "^8.0.1",
"nyc": "^14.1.1",
"sinon": "^6.0.0",
Expand Down
6 changes: 0 additions & 6 deletions examples/cactus-example-cbdc-bridging-frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,6 @@
"last 1 safari version"
]
},
"eslintConfig": {
"extends": [
"react-app",
"react-app/jest"
]
},
"dependencies": {
"@emotion/react": "^11.11.1",
"@emotion/styled": "^11.11.0",
Expand Down
3 changes: 2 additions & 1 deletion examples/cactus-example-discounted-asset-trade/trades.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ const logger = getLogger(`${moduleName}`);
logger.level = config.logLevel;

const router: Router = Router();
export const transactionManagement: TransactionManagement = new TransactionManagement();
export const transactionManagement: TransactionManagement =
new TransactionManagement();

// Request Execution of Trade
router.post("/", (req: Request, res: Response, next: NextFunction) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import { MeterManagement } from "./MeterManagement";
import { MeterInfo } from "./MeterInfo";
import {
BusinessLogicBase,
LedgerEvent,
json2str,
ConfigUtil,
} from "@hyperledger/cactus-cmd-socketio-server";
Expand Down Expand Up @@ -141,7 +140,7 @@ export class BusinessLogicElectricityTrade extends BusinessLogicBase {
});
}

onEvent(ledgerEvent: LedgerEvent, targetIndex: number): void {
onEvent(): void {
logger.error(
"onEvent() ERROR - No monitors are running, should not be called!",
);
Expand Down
8 changes: 1 addition & 7 deletions examples/cactus-example-electricity-trade/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,7 @@
"devDependencies": {
"@types/escape-html": "1.0.1",
"@types/express": "4.17.19",
"@types/uuid": "9.0.8",
"@typescript-eslint/eslint-plugin": "4.33.0",
"@typescript-eslint/parser": "4.33.0",
"eslint": "7.32.0",
"eslint-config-prettier": "8.10.0",
"eslint-plugin-prettier": "5.0.0",
"prettier": "2.8.8"
"@types/uuid": "9.0.8"
},
"engines": {
"node": ">=18",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ export class BusinessLogicElectricityTrade extends BusinessLogicBase {
}
}

getOperationStatus(tradeID: string): object {
getOperationStatus(): object {
logger.debug(`##in getOperationStatus()`);
return {};
}
Expand All @@ -290,7 +290,6 @@ export class BusinessLogicElectricityTrade extends BusinessLogicBase {
targetIndex: number,
): string | null {
logger.debug(`##in getTxIDFromEvent`);
// logger.debug(`##event: ${json2str(ledgerEvent)}`);

switch (ledgerEvent.verifierId) {
case config.electricityTradeInfo.tcsHuawei.validatorID:
Expand Down
Loading

0 comments on commit e4a8a66

Please sign in to comment.