From d6fece1eb49a85c699e202abb53aff48788688e0 Mon Sep 17 00:00:00 2001 From: konstantinabl Date: Thu, 31 Oct 2024 10:26:33 +0200 Subject: [PATCH] chore: Adds eslint rules in eslintrc (#3173) * Adds linting rules and lint script to all the packages; foundation for running pre commit hook Signed-off-by: Konstantina Blazhukova * Removes license header rule and uninstalls unecessary plugin Signed-off-by: Konstantina Blazhukova --------- Signed-off-by: Konstantina Blazhukova --- .eslintrc.js | 18 ++++++++-- .eslintrc.yml | 20 ----------- package-lock.json | 50 +++++++++++++++------------- package.json | 4 +-- packages/config-service/package.json | 2 +- packages/relay/package.json | 2 +- packages/server/package.json | 1 + packages/ws-server/package.json | 1 + 8 files changed, 47 insertions(+), 51 deletions(-) delete mode 100644 .eslintrc.yml diff --git a/.eslintrc.js b/.eslintrc.js index e5a0bce709..76a1a635cc 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -17,6 +17,7 @@ * limitations under the License. * */ +const path = require('path'); module.exports = { "env": { @@ -49,9 +50,20 @@ module.exports = { "@typescript-eslint/ban-ts-comment": "off", "@typescript-eslint/no-empty-interface": "off", "@typescript-eslint/no-explicit-any": "off", - "@typescript-eslint/no-var-requires": "off", "@typescript-eslint/semi": "off", + "@typescript-eslint/no-var-requires": "warn", + "@typescript-eslint/ban-types": "warn", + "no-trailing-spaces": "error", + "no-prototype-builtins": "warn", + "prefer-const": "error", + "no-unsafe-optional-chaining": "warn", "comma-dangle": [2, "only-multiline"], - "semi": [2, "always"] - } + "semi": [2, "always"], + "sort-imports": ["error", { + "ignoreCase": true, + "ignoreDeclarationSort": true, + "ignoreMemberSort": false, + "memberSyntaxSortOrder": ["none", "all", "multiple", "single"], + }], + }, }; diff --git a/.eslintrc.yml b/.eslintrc.yml deleted file mode 100644 index 1e479d6a79..0000000000 --- a/.eslintrc.yml +++ /dev/null @@ -1,20 +0,0 @@ -root: true -parser: '@typescript-eslint/parser' -plugins: - - '@typescript-eslint' -extends: - - plugin:@typescript-eslint/recommended - - prettier -env: - node: true - es6: true -parserOptions: - ecmaVersion: latest - sourceType: module -rules: - '@typescript-eslint/no-empty-interface': 'off' - '@typescript-eslint/no-explicit-any': 'off' - "@typescript-eslint/ban-ts-comment": "off" - '@typescript-eslint/no-var-requires': 'off' - '@typescript-eslint/semi': 'off' -ignorePatterns: [ "**/dist/*" ] diff --git a/package-lock.json b/package-lock.json index 3ada5b4852..6a30f8db16 100644 --- a/package-lock.json +++ b/package-lock.json @@ -10305,6 +10305,7 @@ "resolved": "https://registry.npmjs.org/bufferutil/-/bufferutil-4.0.5.tgz", "integrity": "sha512-HTm14iMQKK2FjFLRTM5lAVcyaUzOnqbPtesFIvREgXpJHdQm8bWS+GkQgIkfaBYRHuCnea7w8UVNfwiAQhlr9A==", "dev": true, + "hasInstallScript": true, "optional": true, "dependencies": { "node-gyp-build": "^4.3.0" @@ -10667,6 +10668,7 @@ "resolved": "https://registry.npmjs.org/utf-8-validate/-/utf-8-validate-5.0.7.tgz", "integrity": "sha512-vLt1O5Pp+flcArHGIyKEQq883nBt8nN8tVBcoL0qUXj2XT1n7p70yGIq2VK98I5FdZ1YHc0wk/koOnHjnXWk1Q==", "dev": true, + "hasInstallScript": true, "optional": true, "dependencies": { "node-gyp-build": "^4.3.0" @@ -21995,7 +21997,7 @@ "debug": "^4.1.0", "gensync": "^1.0.0-beta.2", "json5": "^2.2.2", - "semver": "^7.5.3" + "semver": "^6.3.1" } }, "@babel/generator": { @@ -22020,7 +22022,7 @@ "@babel/helper-validator-option": "^7.22.5", "browserslist": "^4.21.9", "lru-cache": "^5.1.1", - "semver": "^7.5.3" + "semver": "^6.3.1" }, "dependencies": { "lru-cache": { @@ -22379,7 +22381,7 @@ "requires": { "hosted-git-info": "^2.1.4", "resolve": "^1.10.0", - "semver": "^7.5.3", + "semver": "2 || 3 || 4 || 5", "validate-npm-package-license": "^3.0.1" } }, @@ -22465,7 +22467,7 @@ "fs-extra": "^0.30.0", "memorystream": "^0.3.1", "require-from-string": "^1.1.0", - "semver": "^7.5.3", + "semver": "^5.3.0", "yargs": "^4.7.1" } }, @@ -24368,7 +24370,7 @@ "integrity": "sha512-da51j1RCHm+uXpQNM0KJ7qbhUJLTp6Avw8GdL+PQCbZ4lBwKAo8jjJ5rRjf1odsN1+zKl+JF7SMmKZB8PY229Q==", "requires": { "long": "^4.0.0", - "protobufjs": "^7.2.4" + "protobufjs": "^7.2.5" } }, "@hashgraph/sdk": { @@ -24844,7 +24846,7 @@ "read-cmd-shim": "4.0.0", "resolve-from": "5.0.0", "rimraf": "^4.4.1", - "semver": "^7.5.3", + "semver": "^7.3.4", "set-blocking": "^2.0.0", "signal-exit": "3.0.7", "slash": "^3.0.0", @@ -25121,7 +25123,7 @@ "promise-all-reject-late": "^1.0.0", "promise-call-limit": "^3.0.1", "read-package-json-fast": "^3.0.2", - "semver": "^7.5.3", + "semver": "^7.3.7", "ssri": "^10.0.6", "treeverse": "^3.0.0", "walk-up-path": "^3.0.1" @@ -25163,7 +25165,7 @@ "resolved": "https://registry.npmjs.org/@npmcli/fs/-/fs-3.1.1.tgz", "integrity": "sha512-q9CRWjpHCMIh5sVyefoD1cA7PkvILqCZsnSOEUUivORLjxCO/Irmue2DprETiNgEqktDBZaM1Bi+jrarx1XdCg==", "requires": { - "semver": "^7.5.3" + "semver": "^7.3.5" } }, "@npmcli/git": { @@ -25178,7 +25180,7 @@ "proc-log": "^4.0.0", "promise-inflight": "^1.0.1", "promise-retry": "^2.0.1", - "semver": "^7.5.3", + "semver": "^7.3.5", "which": "^4.0.0" }, "dependencies": { @@ -25286,7 +25288,7 @@ "json-parse-even-better-errors": "^3.0.0", "pacote": "^18.0.0", "proc-log": "^4.1.0", - "semver": "^7.5.3" + "semver": "^7.3.5" } }, "@npmcli/name-from-folder": { @@ -27472,7 +27474,7 @@ "integrity": "sha512-qwVpFEHNfhYJIzNRBvd2C1kyo6jz3ZSMPyyuR47OPdiKWlbYnZNyDWuyR175qDnAJLiCo5fBBqPb3RiXgWlkOQ==", "dev": true, "requires": { - "semver": "^7.5.3" + "semver": "^7.0.0" } }, "byte-size": { @@ -28125,7 +28127,7 @@ "requires": { "hosted-git-info": "^4.0.1", "is-core-module": "^2.5.0", - "semver": "^7.5.3", + "semver": "^7.3.4", "validate-npm-package-license": "^3.0.1" } } @@ -28146,7 +28148,7 @@ "handlebars": "^4.7.7", "json-stringify-safe": "^5.0.1", "meow": "^8.1.2", - "semver": "^7.5.3", + "semver": "^7.0.0", "split": "^1.0.1" } }, @@ -30502,7 +30504,7 @@ "integrity": "sha512-hIvOeZwRbQ+7YEUmCkHqo8FOLQZCEn18yevLHADlFPZY02KJGsu5FZt9YW/lybfK2uhWFI7Qg/07LekJiTv7iA==", "requires": { "meow": "^8.1.2", - "semver": "^7.5.3" + "semver": "^7.0.0" } }, "git-up": { @@ -31000,7 +31002,7 @@ "npm-package-arg": "^11.0.0", "promzard": "^1.0.0", "read": "^3.0.1", - "semver": "^7.5.3", + "semver": "^7.3.5", "validate-npm-package-license": "^3.0.4", "validate-npm-package-name": "^5.0.0" } @@ -31478,7 +31480,7 @@ "@babel/core": "^7.7.5", "@istanbuljs/schema": "^0.1.2", "istanbul-lib-coverage": "^3.0.0", - "semver": "^7.5.3" + "semver": "^6.3.0" } }, "istanbul-lib-processinfo": { @@ -32927,7 +32929,7 @@ "integrity": "sha512-g3FeP20LNwhALb/6Cz6Dd4F2ngze0jz7tbzrD2wAV+o9FeNHe4rL+yK2md0J/fiSf1sa1ADhXqi5+oVwOM/eGw==", "dev": true, "requires": { - "semver": "^7.5.3" + "semver": "^6.0.0" } }, "make-error": { @@ -33196,7 +33198,7 @@ "requires": { "hosted-git-info": "^4.0.1", "is-core-module": "^2.5.0", - "semver": "^7.5.3", + "semver": "^7.3.4", "validate-npm-package-license": "^3.0.1" } }, @@ -33239,7 +33241,7 @@ "requires": { "hosted-git-info": "^2.1.4", "resolve": "^1.10.0", - "semver": "^7.5.3", + "semver": "2 || 3 || 4 || 5", "validate-npm-package-license": "^3.0.1" } }, @@ -33834,7 +33836,7 @@ "make-fetch-happen": "^13.0.0", "nopt": "^7.0.0", "proc-log": "^4.1.0", - "semver": "^7.5.3", + "semver": "^7.3.5", "tar": "^6.2.1", "which": "^4.0.0" }, @@ -34015,7 +34017,7 @@ "resolved": "https://registry.npmjs.org/npm-install-checks/-/npm-install-checks-6.3.0.tgz", "integrity": "sha512-W29RiK/xtpCGqn6f3ixfRYGk+zRyr+Ew9F2E20BfXxT5/euLdA/Nm7fO7OeTGuAmTs30cpgInyJ0cYe708YTZw==", "requires": { - "semver": "^7.5.3" + "semver": "^7.1.1" } }, "npm-normalize-package-bin": { @@ -34065,7 +34067,7 @@ "npm-install-checks": "^6.0.0", "npm-normalize-package-bin": "^3.0.0", "npm-package-arg": "^11.0.0", - "semver": "^7.5.3" + "semver": "^7.3.5" } }, "npm-registry-fetch": { @@ -35446,7 +35448,7 @@ "requires": { "hosted-git-info": "^2.1.4", "resolve": "^1.10.0", - "semver": "^7.5.3", + "semver": "2 || 3 || 4 || 5", "validate-npm-package-license": "^3.0.1" } }, @@ -37823,7 +37825,7 @@ "integrity": "sha512-LS9X+dc8KLxXCb8dni79fLIIUA5VyZoyjSMCwTluaXA0o27cCK0bhXkpgw+sTXVpPy/lSO57ilRixqk0vDmtRA==", "requires": { "pify": "^4.0.1", - "semver": "^7.5.3" + "semver": "^5.6.0" } }, "pify": { diff --git a/package.json b/package.json index f6d1eff7f8..ffa966520a 100644 --- a/package.json +++ b/package.json @@ -7,8 +7,8 @@ "@types/co-body": "6.1.0", "@types/find-config": "^1.0.4", "@types/koa-cors": "^0.0.6", - "@types/sinon": "^10.0.20", "@types/lodash": "^4.17.7", + "@types/sinon": "^10.0.20", "@typescript-eslint/eslint-plugin": "^6.5.0", "@typescript-eslint/parser": "^6.5.0", "ajv": "^8.16.0", @@ -93,8 +93,8 @@ "lerna": "^8.1.8", "pino": "^7.11.0", "pino-pretty": "^7.6.1", - "prom-client": "^14.0.1", "pnpm": "^8.7.1", + "prom-client": "^14.0.1", "redis": "^4.7.0" }, "overrides": { diff --git a/packages/config-service/package.json b/packages/config-service/package.json index aac6365742..9255f0240d 100644 --- a/packages/config-service/package.json +++ b/packages/config-service/package.json @@ -9,7 +9,7 @@ "build": "pnpm run clean && pnpm run compile", "clean": "rm -rf ./dist && rm -rf tsconfig.tsbuildinfo", "compile": "tsc -b tsconfig.json", - "lint": "npx eslint --ext .js,.ts .", + "lint": "npx eslint --ext .js,.ts . --ignore-path ../../.eslintignore", "format": "npx prettier --ignore-path ../../.gitignore --write \"**/*.+(js|ts|json)\"", "test": "nyc ts-mocha --recursive './tests/**/*.spec.ts' './tests/**/**/*.spec.ts' --exit", "print-env": "node src/commands/printEnvs.ts" diff --git a/packages/relay/package.json b/packages/relay/package.json index 45430fecf1..04cc78a43b 100644 --- a/packages/relay/package.json +++ b/packages/relay/package.json @@ -23,7 +23,7 @@ "build": "pnpm run clean && pnpm run compile", "clean": "rm -rf ./dist && rm -rf tsconfig.tsbuildinfo", "compile": "tsc -b tsconfig.json", - "lint": "npx eslint --ext .js,.ts .", + "lint": "npx eslint --ext .js,.ts . --ignore-path ../../.eslintignore", "format": "npx prettier --ignore-path ../../.gitignore --write \"**/*.+(js|ts|json)\"", "test": "nyc ts-mocha --recursive './tests/**/*.spec.ts' './tests/**/**/*.spec.ts' --exit", "test-eth": "nyc ts-mocha --recursive './tests/lib/eth/**/*.spec.ts' --exit", diff --git a/packages/server/package.json b/packages/server/package.json index 7250739754..ba0a54e2a6 100644 --- a/packages/server/package.json +++ b/packages/server/package.json @@ -47,6 +47,7 @@ "clean": "rm -rf ./dist && rm -rf tsconfig.tsbuildinfo", "compile": "tsc -b tsconfig.json", "acceptancetest": "nyc ts-mocha tests/acceptance/index.spec.ts", + "lint": "npx eslint --ext .js,.ts . --ignore-path ../../.eslintignore", "start": "node dist/index.js", "test": "nyc ts-mocha --recursive './tests/integration/*.spec.ts' './tests/integration/**/*.spec.ts' --exit" }, diff --git a/packages/ws-server/package.json b/packages/ws-server/package.json index 7f94ae46c9..2267c2aa6d 100644 --- a/packages/ws-server/package.json +++ b/packages/ws-server/package.json @@ -46,6 +46,7 @@ "compile": "tsc -b tsconfig.json", "acceptancetest": "nyc ts-mocha tests/acceptance/index.spec.ts", "start": "node dist/index.js", + "lint": "npx eslint --ext .js,.ts . --ignore-path ../../.eslintignore", "test": "nyc ts-mocha --recursive './tests/unit/**/*.spec.ts' --exit" }, "nyc": {