From ac4e5a73fd90031c4797d9219c6d363bbd5de770 Mon Sep 17 00:00:00 2001 From: Sara Gerion Date: Thu, 29 Sep 2022 16:11:20 +0200 Subject: [PATCH 1/3] fix: lerna format standardized for all lerna packages + examples --- examples/cdk/package.json | 1 + examples/sam/package.json | 1 + layer-publisher/package.json | 1 + package.json | 2 +- packages/metrics/tests/unit/middleware/middy.test.ts | 6 +++--- 5 files changed, 7 insertions(+), 4 deletions(-) diff --git a/examples/cdk/package.json b/examples/cdk/package.json index 32139c6b3e..8ddc4749ab 100644 --- a/examples/cdk/package.json +++ b/examples/cdk/package.json @@ -14,6 +14,7 @@ "build": "tsc --skipLibCheck", "watch": "tsc -w", "test": "npm run test:unit", + "format": "eslint --fix --ext .ts --fix --no-error-on-unmatched-pattern src tests", "package": "echo 'Not applicable'", "package-bundle": "echo 'Not applicable'", "test:unit": "npm run build && jest", diff --git a/examples/sam/package.json b/examples/sam/package.json index b365e2bdc0..b96c3fb218 100644 --- a/examples/sam/package.json +++ b/examples/sam/package.json @@ -10,6 +10,7 @@ "scripts": { "build": "sam build --beta-features", "test": "npm run test:unit", + "format": "eslint --fix --ext .ts --fix --no-error-on-unmatched-pattern src tests", "package": "echo 'Not applicable'", "package-bundle": "echo 'Not applicable'", "test:unit": "npm run build && jest", diff --git a/layer-publisher/package.json b/layer-publisher/package.json index 8de22d05a1..98bec41b18 100644 --- a/layer-publisher/package.json +++ b/layer-publisher/package.json @@ -10,6 +10,7 @@ "test": "npm run test:unit", "cdk": "cdk", "package": "echo 'Not applicable'", + "format": "eslint --fix --ext .ts --fix --no-error-on-unmatched-pattern src tests", "test:unit": "if-node-version '>12' jest --testPathPattern=unit -u", "test:e2e": "if-node-version '>12' jest --testPathPattern=e2e" }, diff --git a/package.json b/package.json index 19329e669a..53e59ed93d 100644 --- a/package.json +++ b/package.json @@ -23,7 +23,7 @@ "lerna-package-bundle": "lerna exec -- npm run package-bundle", "lerna-build": "lerna exec -- tsc", "lerna-lint": "lerna exec -- eslint \"./{src,tests}/**/*.ts ./src/*.ts\"", - "lerna-format": "lerna exec -- eslint --fix \"./{src,tests}/**/*.ts ./src/*.ts\"", + "lerna-format": "lerna exec -- npm run format", "lerna-prepare": "lerna exec -- npm run build", "lerna-prepublishOnly": "lerna exec -- npm test && lerna exec -- npm run lint", "lerna-preversion": "lerna exec -- npm run lint", diff --git a/packages/metrics/tests/unit/middleware/middy.test.ts b/packages/metrics/tests/unit/middleware/middy.test.ts index f322ce8bbd..a31cb20d5e 100644 --- a/packages/metrics/tests/unit/middleware/middy.test.ts +++ b/packages/metrics/tests/unit/middleware/middy.test.ts @@ -216,7 +216,7 @@ describe('Middy middleware', () => { ], }, service: 'orders', - successfulBooking: [2, 1], + successfulBooking: [ 2, 1 ], }) ); }); @@ -247,7 +247,7 @@ describe('Middy middleware', () => { CloudWatchMetrics: [ { Namespace: 'serverlessAirline', - Dimensions: [['environment', 'aws_region', 'service', 'function_name']], + Dimensions: [[ 'environment', 'aws_region', 'service', 'function_name' ]], Metrics: [{ Name: 'ColdStart', Unit: 'Count' }], }, ], @@ -267,7 +267,7 @@ describe('Middy middleware', () => { CloudWatchMetrics: [ { Namespace: 'serverlessAirline', - Dimensions: [['environment', 'aws_region', 'service']], + Dimensions: [[ 'environment', 'aws_region', 'service' ]], Metrics: [{ Name: 'successfulBooking', Unit: 'Count' }], }, ], From f0f7ec5585e125369ae85c9b620cf5c3d5f959bb Mon Sep 17 00:00:00 2001 From: Sara Gerion Date: Thu, 29 Sep 2022 16:26:33 +0200 Subject: [PATCH 2/3] chore: remove --fix to lint command, rename lerna format to lint-fix --- examples/cdk/package.json | 3 ++- examples/sam/package.json | 3 ++- layer-publisher/package.json | 3 ++- package.json | 4 ++-- packages/commons/package.json | 4 ++-- packages/idempotency/package.json | 4 ++-- packages/logger/package.json | 4 ++-- packages/metrics/package.json | 4 ++-- packages/tracer/package.json | 4 ++-- 9 files changed, 18 insertions(+), 15 deletions(-) diff --git a/examples/cdk/package.json b/examples/cdk/package.json index 8ddc4749ab..cce5d95777 100644 --- a/examples/cdk/package.json +++ b/examples/cdk/package.json @@ -14,7 +14,8 @@ "build": "tsc --skipLibCheck", "watch": "tsc -w", "test": "npm run test:unit", - "format": "eslint --fix --ext .ts --fix --no-error-on-unmatched-pattern src tests", + "lint": "eslint --ext .ts --no-error-on-unmatched-pattern src tests", + "lint-fix": "eslint --fix --ext .ts --fix --no-error-on-unmatched-pattern src tests", "package": "echo 'Not applicable'", "package-bundle": "echo 'Not applicable'", "test:unit": "npm run build && jest", diff --git a/examples/sam/package.json b/examples/sam/package.json index b96c3fb218..693389d09d 100644 --- a/examples/sam/package.json +++ b/examples/sam/package.json @@ -10,7 +10,8 @@ "scripts": { "build": "sam build --beta-features", "test": "npm run test:unit", - "format": "eslint --fix --ext .ts --fix --no-error-on-unmatched-pattern src tests", + "lint": "eslint --ext .ts --no-error-on-unmatched-pattern src tests", + "lint-fix": "eslint --fix --ext .ts --fix --no-error-on-unmatched-pattern src tests", "package": "echo 'Not applicable'", "package-bundle": "echo 'Not applicable'", "test:unit": "npm run build && jest", diff --git a/layer-publisher/package.json b/layer-publisher/package.json index 98bec41b18..69ef7317ab 100644 --- a/layer-publisher/package.json +++ b/layer-publisher/package.json @@ -10,7 +10,8 @@ "test": "npm run test:unit", "cdk": "cdk", "package": "echo 'Not applicable'", - "format": "eslint --fix --ext .ts --fix --no-error-on-unmatched-pattern src tests", + "lint": "eslint --ext .ts --no-error-on-unmatched-pattern src tests", + "lint-fix": "eslint --fix --ext .ts --fix --no-error-on-unmatched-pattern src tests", "test:unit": "if-node-version '>12' jest --testPathPattern=unit -u", "test:e2e": "if-node-version '>12' jest --testPathPattern=e2e" }, diff --git a/package.json b/package.json index 53e59ed93d..e0a5025392 100644 --- a/package.json +++ b/package.json @@ -22,8 +22,8 @@ "lerna-package": "lerna exec -- npm run package", "lerna-package-bundle": "lerna exec -- npm run package-bundle", "lerna-build": "lerna exec -- tsc", - "lerna-lint": "lerna exec -- eslint \"./{src,tests}/**/*.ts ./src/*.ts\"", - "lerna-format": "lerna exec -- npm run format", + "lerna-lint": "lerna exec -- npm run lint", + "lerna-lint-fix": "lerna exec -- npm run lint-fix", "lerna-prepare": "lerna exec -- npm run build", "lerna-prepublishOnly": "lerna exec -- npm test && lerna exec -- npm run lint", "lerna-preversion": "lerna exec -- npm run lint", diff --git a/packages/commons/package.json b/packages/commons/package.json index 534083afa9..a24ab07859 100644 --- a/packages/commons/package.json +++ b/packages/commons/package.json @@ -16,8 +16,8 @@ "test:e2e": "echo 'Not Applicable'", "watch": "jest --watch", "build": "tsc", - "lint": "eslint --ext .ts --fix --no-error-on-unmatched-pattern src tests", - "format": "eslint --fix --ext .ts --fix --no-error-on-unmatched-pattern src tests", + "lint": "eslint --ext .ts --no-error-on-unmatched-pattern src tests", + "lint-fix": "eslint --fix --ext .ts --no-error-on-unmatched-pattern src tests", "package": "mkdir -p dist/ && npm pack && mv *.tgz dist/", "package-bundle": "../../package-bundler.sh commons-bundle ./dist", "prepare": "npm run build", diff --git a/packages/idempotency/package.json b/packages/idempotency/package.json index 9d4ec3cc30..60fca20565 100644 --- a/packages/idempotency/package.json +++ b/packages/idempotency/package.json @@ -19,8 +19,8 @@ "test:e2e": "jest --group=e2e", "watch": "jest --watch --group=unit", "build": "tsc", - "lint": "eslint --ext .ts --fix --no-error-on-unmatched-pattern src tests", - "format": "eslint --fix --ext .ts --fix --no-error-on-unmatched-pattern src tests", + "lint": "eslint --ext .ts --no-error-on-unmatched-pattern src tests", + "lint-fix": "eslint --fix --ext .ts --no-error-on-unmatched-pattern src tests", "package": "mkdir -p dist/ && npm pack && mv *.tgz dist/", "package-bundle": "../../package-bundler.sh logger-bundle ./dist", "prepare": "npm run build", diff --git a/packages/logger/package.json b/packages/logger/package.json index 386ac9fd12..f646569cd9 100644 --- a/packages/logger/package.json +++ b/packages/logger/package.json @@ -19,8 +19,8 @@ "test:e2e": "jest --group=e2e", "watch": "jest --watch --group=unit", "build": "tsc", - "lint": "eslint --ext .ts --fix --no-error-on-unmatched-pattern src tests", - "format": "eslint --fix --ext .ts --fix --no-error-on-unmatched-pattern src tests", + "lint": "eslint --ext .ts --no-error-on-unmatched-pattern src tests", + "lint-fix": "eslint --fix --ext .ts --no-error-on-unmatched-pattern src tests", "package": "mkdir -p dist/ && npm pack && mv *.tgz dist/", "package-bundle": "../../package-bundler.sh logger-bundle ./dist", "prepare": "npm run build", diff --git a/packages/metrics/package.json b/packages/metrics/package.json index c999ddfc51..ec26a65c45 100644 --- a/packages/metrics/package.json +++ b/packages/metrics/package.json @@ -19,8 +19,8 @@ "test:e2e": "jest --group=e2e", "watch": "jest --group=unit --watch ", "build": "tsc", - "lint": "eslint --ext .ts --fix --no-error-on-unmatched-pattern src tests", - "format": "eslint --fix --ext .ts --fix --no-error-on-unmatched-pattern src tests", + "lint": "eslint --ext .ts --no-error-on-unmatched-pattern src tests", + "lint-fix": "eslint --fix --ext .ts --no-error-on-unmatched-pattern src tests", "package": "mkdir -p dist/ && npm pack && mv *.tgz dist/", "package-bundle": "../../package-bundler.sh metrics-bundle ./dist", "prepare": "npm run build", diff --git a/packages/tracer/package.json b/packages/tracer/package.json index e006663457..93708217e0 100644 --- a/packages/tracer/package.json +++ b/packages/tracer/package.json @@ -19,8 +19,8 @@ "test:e2e": "jest --group=e2e", "watch": "jest --watch", "build": "tsc", - "lint": "eslint --ext .ts --fix --no-error-on-unmatched-pattern src tests", - "format": "eslint --fix --ext .ts --fix --no-error-on-unmatched-pattern src tests", + "lint": "eslint --ext .ts --no-error-on-unmatched-pattern src tests", + "lint-fix": "eslint --fix --ext .ts --no-error-on-unmatched-pattern src tests", "prepare": "npm run build", "prepublishOnly": "npm test && npm run lint", "preversion": "npm run lint", From 237201becaf34d9bf1aade8f91382080bfe7f68b Mon Sep 17 00:00:00 2001 From: Sara Gerion Date: Thu, 29 Sep 2022 16:43:28 +0200 Subject: [PATCH 3/3] chore: run lerna lint fix on commit & push --- .husky/pre-commit | 2 +- .husky/pre-push | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.husky/pre-commit b/.husky/pre-commit index 8527102f54..64ad72dea3 100755 --- a/.husky/pre-commit +++ b/.husky/pre-commit @@ -1,4 +1,4 @@ #!/bin/sh . "$(dirname "$0")/_/husky.sh" -npm run lerna-lint +npm run lerna-lint-fix diff --git a/.husky/pre-push b/.husky/pre-push index 771caa1dda..78f6873145 100755 --- a/.husky/pre-push +++ b/.husky/pre-push @@ -1,5 +1,5 @@ #!/bin/sh . "$(dirname "$0")/_/husky.sh" -npm run lerna-lint +npm run lerna-lint-fix npm run test