aws / aws/aws-pdk

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

Open
#808 3 comments 1 reaction 0 assignees View on GitHub
backlog bug needs-triage
Dominant language
TypeScript
Stars
451
Forks
84
Avg merge
20h 3m
Merged PRs (30d)
1

Description

### 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:

```json
{
"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:

```sh
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:

```typescript
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

Contributor guide

Open the contributing guide

Research direction

Start with the generated root eslintrc.json and tasks.json for a MonorepoTsProject, then inspect how the eslint task invokes nx run-many for package linting. Reproduce the issue with a whitespace error in .projenrc.ts and run npm run eslint. Done means the default task also checks .projenrc.ts and projenrc/**/*.ts.

Written by the indexing model from the issue text.

Assessment

Tech stack
eslint, typescript
Domain
build-system, tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.