(init-templates): Add linter/formatter to JavaScript/TypeScript templates
- Dominant language
- TypeScript
- Stars
- 12.9k
- Forks
- 4.6k
- Avg merge
- 2d 3h
- Merged PRs (30d)
- 83
Description
### Describe the feature
Add linter and formatter configurations to the JavaScript and TypeScript templates generated by `cdk init`.
### Use Case
JavaScript/TypeScript toolchain configuration, especially for linters and formatters, is often complex and time-consuming to set up correctly. This complexity can distract developers from focusing on their core CDK development work.
By providing these tools and configurations out of the box in the init templates, we can help developers focus more on their actual infrastructure code rather than spending time on tooling setup.
### Proposed Solution
Add the following to the JavaScript and TypeScript init templates:
1. Add linter/formatter dependencies to package.json:
- Plan A: ESLint + Prettier
- Plan B: Biome (all-in-one solution)
2. Add appropriate configuration files:
- For ESLint: eslint.config.mjs with CDK-specific rules
- For Prettier: .prettierrc with standard configurations
- For Biome: biome.json(or biome.jsonc)
3. Add npm scripts to package.json:
```json
{
"scripts": {
"lint": "eslint . --ext .js,.ts",
"format": "prettier --write .",
// or for Biome:
"lint": "biome lint .",
"format": "biome format ."
}
}
```
### Other Information
The choice between ESLint+Prettier vs Biome could be made based on:
1. Community adoption
2. Maintenance overhead
3. Performance
4. Integration with existing CDK tooling
Biome might be preferable as it's a single tool that handles both linting and formatting, which means less configuration and maintenance.
### Acknowledgements
- [X] I may be able to implement this feature request
- [ ] This feature might incur a breaking change
### CDK version used
2.166.0
### Environment details (OS name and version, etc.)
macOS Sonoma v14.0
Contributor guide
Research direction
Start by locating the JavaScript and TypeScript templates generated by `cdk init` and inspect their `package.json` files. The issue leaves the tool choice and CDK-specific rules undecided, so clarify whether to use ESLint plus Prettier or Biome before implementing configuration files and scripts. Done means both generated templates include the agreed tooling and work with the existing CDK setup.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- eslint, javascript, typescript
- Domain
- developer-experience, tooling
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100