From 75588db9e8768e4f2f209cfd5dc5938b92abc225 Mon Sep 17 00:00:00 2001 From: Nara Kasbergen Kwon <855115+xiehan@users.noreply.github.com> Date: Tue, 21 Jan 2025 14:19:24 +0100 Subject: [PATCH] chore(ci): fix linter misconfiguration to allow Projen upgrade to succeed (#190) As I was debugging the `upgrade-projen` workflow, the upgrade from `0.88.0` => `0.91.6` was failing due to changes in the ESLint configuration. While digging for workarounds, I found the following. --------- Signed-off-by: team-tf-cdk Co-authored-by: team-tf-cdk --- .projen/tasks.json | 2 +- .projenrc.ts | 6 ++++++ examples/hybrid-module/.projen/tasks.json | 2 +- examples/hybrid-module/src/__tests__/index-test.ts | 2 +- examples/hybrid-module/src/index.ts | 2 +- examples/hybrid-module/src/tfModules.ts | 6 +++--- examples/terraform-module/.projen/tasks.json | 2 +- examples/terraform-module/src/__tests__/index-test.ts | 4 ++-- examples/terraform-module/src/index.ts | 2 +- src/hybrid-module.ts | 3 +++ src/terraform-module.ts | 3 +++ 11 files changed, 23 insertions(+), 11 deletions(-) diff --git a/.projen/tasks.json b/.projen/tasks.json index 1d3070c..caa3911 100644 --- a/.projen/tasks.json +++ b/.projen/tasks.json @@ -153,7 +153,7 @@ "description": "Runs eslint against the codebase", "steps": [ { - "exec": "eslint --ext .ts,.tsx --fix --no-error-on-unmatched-pattern $@ src test build-tools projenrc .projenrc.ts", + "exec": "eslint --fix --no-error-on-unmatched-pattern $@ src test projenrc .projenrc.ts build-tools", "receiveArgs": true } ] diff --git a/.projenrc.ts b/.projenrc.ts index 9b5054e..c1c4d3b 100644 --- a/.projenrc.ts +++ b/.projenrc.ts @@ -63,6 +63,12 @@ const project = new JsiiProject({ typescriptVersion, jsiiVersion: typescriptVersion, pullRequestTemplate: false, + // Necessary due to this bug: https://github.com/projen/projen/issues/3950#issuecomment-2483442005 + // If this bug gets fixed, the below `eslintOptions` section should be able to be removed + eslintOptions: { + fileExtensions: [], + dirs: ["src", "test", "projenrc", ".projenrc.ts"], + }, }); project.tsconfig?.exclude?.push("src/exampleCode/**"); project.tsconfig?.exclude?.push("example/**"); diff --git a/examples/hybrid-module/.projen/tasks.json b/examples/hybrid-module/.projen/tasks.json index 559f5c8..1d01b3f 100644 --- a/examples/hybrid-module/.projen/tasks.json +++ b/examples/hybrid-module/.projen/tasks.json @@ -140,7 +140,7 @@ "description": "Runs eslint against the codebase", "steps": [ { - "exec": "eslint --ext .ts,.tsx --fix --no-error-on-unmatched-pattern $@ src test build-tools projenrc .projenrc.ts", + "exec": "eslint --fix --no-error-on-unmatched-pattern $@ src test build-tools projenrc .projenrc.ts", "receiveArgs": true } ] diff --git a/examples/hybrid-module/src/__tests__/index-test.ts b/examples/hybrid-module/src/__tests__/index-test.ts index 96d5cec..cb25ae3 100644 --- a/examples/hybrid-module/src/__tests__/index-test.ts +++ b/examples/hybrid-module/src/__tests__/index-test.ts @@ -13,4 +13,4 @@ describe("MyConstruct", () => { }) ).toMatchSnapshot(); }); -}); +}); \ No newline at end of file diff --git a/examples/hybrid-module/src/index.ts b/examples/hybrid-module/src/index.ts index f43d004..2a6b46e 100644 --- a/examples/hybrid-module/src/index.ts +++ b/examples/hybrid-module/src/index.ts @@ -8,4 +8,4 @@ export class MyConstruct extends Construct { constructor(scope: Construct, id: string, public config: MyConstructOptions) { super(scope, id); } -} +} \ No newline at end of file diff --git a/examples/hybrid-module/src/tfModules.ts b/examples/hybrid-module/src/tfModules.ts index 0addcbd..1e9e75c 100644 --- a/examples/hybrid-module/src/tfModules.ts +++ b/examples/hybrid-module/src/tfModules.ts @@ -1,6 +1,6 @@ -import { TFModuleStack } from "@cdktf/tf-module-stack"; import { App } from "cdktf"; import { Construct } from "constructs"; +import { TFModuleStack } from "@cdktf/tf-module-stack"; import { MyConstruct } from "./index"; class MyAwesomeModule extends TFModuleStack { @@ -14,8 +14,8 @@ class MyAwesomeModule extends TFModuleStack { } const app = new App(); -// This is the name the module can be found under. +// This is the name the module can be found under. // We expect a "my-awesome-module.md" file in this directory. // The README.md file will be generated from this file. new MyAwesomeModule(app, "my-awesome-module"); -app.synth(); +app.synth(); \ No newline at end of file diff --git a/examples/terraform-module/.projen/tasks.json b/examples/terraform-module/.projen/tasks.json index eed68a2..b4286f0 100644 --- a/examples/terraform-module/.projen/tasks.json +++ b/examples/terraform-module/.projen/tasks.json @@ -127,7 +127,7 @@ "description": "Runs eslint against the codebase", "steps": [ { - "exec": "eslint --ext .ts,.tsx --fix --no-error-on-unmatched-pattern $@ src test build-tools projenrc .projenrc.ts", + "exec": "eslint --fix --no-error-on-unmatched-pattern $@ src test build-tools projenrc .projenrc.ts", "receiveArgs": true } ] diff --git a/examples/terraform-module/src/__tests__/index-test.ts b/examples/terraform-module/src/__tests__/index-test.ts index 0580695..1e0c8e8 100644 --- a/examples/terraform-module/src/__tests__/index-test.ts +++ b/examples/terraform-module/src/__tests__/index-test.ts @@ -3,5 +3,5 @@ // To learn more about testing see cdk.tf/testing describe("MyModule", () => { - it.todo("should be tested"); -}); + it.todo("should be tested") +}); \ No newline at end of file diff --git a/examples/terraform-module/src/index.ts b/examples/terraform-module/src/index.ts index c2ceb87..1eccc70 100644 --- a/examples/terraform-module/src/index.ts +++ b/examples/terraform-module/src/index.ts @@ -1,4 +1,4 @@ // Re-Export module bindings export * from "./terraformModules"; -// Add your custom constructs here +// Add your custom constructs here \ No newline at end of file diff --git a/src/hybrid-module.ts b/src/hybrid-module.ts index 52620b3..5eb5bb0 100644 --- a/src/hybrid-module.ts +++ b/src/hybrid-module.ts @@ -175,6 +175,9 @@ export class HybridModule extends JsiiProject { ...options, eslintOptions: Object.assign({}, options.eslintOptions, { lintProjenRc: false, + // Necessary due to this bug: https://github.com/projen/projen/issues/3950#issuecomment-2483442005 + // If this bug gets fixed, the below line should be able to be removed + fileExtensions: [], }), postBuildSteps: [], jsiiVersion: "~5.5.0", diff --git a/src/terraform-module.ts b/src/terraform-module.ts index c449188..2fee63c 100644 --- a/src/terraform-module.ts +++ b/src/terraform-module.ts @@ -59,6 +59,9 @@ export class TerraformModule extends ConstructLibrary { ...options, eslintOptions: Object.assign({}, options.eslintOptions, { lintProjenRc: false, + // Necessary due to this bug: https://github.com/projen/projen/issues/3950#issuecomment-2483442005 + // If this bug gets fixed, the below line should be able to be removed + fileExtensions: [], }), postBuildSteps: [], jsiiVersion: "~5.5.0",