Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] MonorepoTsProject should lint .projenrc.ts and projenrc/**.ts #808

Open
athewsey opened this issue Jul 3, 2024 · 0 comments
Open
Labels
bug Something isn't working needs-triage

Comments

@athewsey
Copy link

athewsey commented Jul 3, 2024

Describe the bug

When generating a MonorepoTsProject, the generated ESLint configuration seems set up to include the projenrc configuration files... But the structure of the eslint task only runs lint in the monorepo packages so does not capture the monorepo-level projen code.

Expected Behavior

Default ESLint configuration for a MonorepoTsProject should also lint .projenrc.ts and projenrc/**.ts files

Current Behavior

I see the created root eslintrc.json seems to explicitly provision for linting the projenrc config files:

{
  "ignorePatterns": [
    "packages/**/*.*",
    "!.projenrc.ts",
    "!projenrc/**/*.ts"
  ],
  ...
  "overrides": [
    {
      "files": [
        ".projenrc.ts"
      ],
      "rules": {
        "@typescript-eslint/no-require-imports": "off",
        "import/no-extraneous-dependencies": "off"
      }
    }
  ]
}

...But the generated tasks.json task just runs eslint in sub-packages via nx - which won't capture the top-level linting:

npx nx run-many --target=eslint --output-style=stream --nx-bail

Reproduction Steps

  • npx projen new --from @aws/pdk monorepo-ts
  • Edit your .projenrc.ts file with some whitespace error that prettier/eslint should catch
  • Run npm run eslint: The projenrc file will not be re-formatted.

Possible Solution

Maybe MonorepoTsProject should add an additional step to the eslint task to run at the root/monorepo level?

I'm tentatively working around it for now with:

monorepo.eslint?.eslintTask.prependExec(
  "eslint --ext .ts,.tsx --fix --no-error-on-unmatched-pattern $@ .projenrc.ts projenrc",
);

Additional Information/Context

No response

PDK version used

0.23.44

What languages are you seeing this issue on?

Typescript

Environment details (OS name and version, etc.)

macOS, projen v0.82.8

@athewsey athewsey added bug Something isn't working needs-triage labels Jul 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working needs-triage
Projects
None yet
Development

No branches or pull requests

1 participant