From f25f7bf67d9d05c269335d47435b62fbb23c3cad Mon Sep 17 00:00:00 2001 From: Sara Gerion <47529391+saragerion@users.noreply.github.com> Date: Thu, 29 Sep 2022 17:00:45 +0200 Subject: [PATCH] Fix: standardized and consistent linting strategy across Lerna targets (#1105) * fix: lerna format standardized for all lerna packages + examples * chore: remove --fix to lint command, rename lerna format to lint-fix * chore: run lerna lint fix on commit & push --- .husky/pre-commit | 2 +- .husky/pre-push | 2 +- examples/cdk/package.json | 2 ++ examples/sam/package.json | 2 ++ layer-publisher/package.json | 2 ++ package.json | 4 ++-- packages/commons/package.json | 4 ++-- packages/idempotency/package.json | 4 ++-- packages/logger/package.json | 4 ++-- packages/metrics/package.json | 4 ++-- packages/metrics/tests/unit/middleware/middy.test.ts | 6 +++--- packages/tracer/package.json | 4 ++-- 12 files changed, 23 insertions(+), 17 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 diff --git a/examples/cdk/package.json b/examples/cdk/package.json index 32139c6b3e..cce5d95777 100644 --- a/examples/cdk/package.json +++ b/examples/cdk/package.json @@ -14,6 +14,8 @@ "build": "tsc --skipLibCheck", "watch": "tsc -w", "test": "npm run test:unit", + "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 b365e2bdc0..693389d09d 100644 --- a/examples/sam/package.json +++ b/examples/sam/package.json @@ -10,6 +10,8 @@ "scripts": { "build": "sam build --beta-features", "test": "npm run test:unit", + "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 8de22d05a1..69ef7317ab 100644 --- a/layer-publisher/package.json +++ b/layer-publisher/package.json @@ -10,6 +10,8 @@ "test": "npm run test:unit", "cdk": "cdk", "package": "echo 'Not applicable'", + "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 19329e669a..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 -- eslint --fix \"./{src,tests}/**/*.ts ./src/*.ts\"", + "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/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' }], }, ], 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",