Skip to content

Commit fefb1df

Browse files
chore(build): add TypeScript support to toolchain (#11000)
1 parent 050e996 commit fefb1df

9 files changed

Lines changed: 390 additions & 255 deletions

File tree

.eslintignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
dist/
22
node_modules/
33
test/e2e-selenium/
4+
**/*.d.ts

.eslintrc.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,6 @@ module.exports = {
7373
"react/jsx-no-target-blank": 2,
7474
"react/display-name": 0,
7575
"import/no-extraneous-dependencies": 2,
76-
"react/jsx-filename-extension": 2,
76+
"react/jsx-filename-extension": [2, { extensions: [".jsx", ".tsx"] }],
7777
},
7878
}

.lintstagedrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
{
2-
"*.{js,jsx}": ["eslint --max-warnings 0"],
2+
"*.{js,jsx,ts,tsx}": ["eslint --max-warnings 0"],
33
"*.scss": ["stylelint '**/*.scss'"]
44
}

CLAUDE.md

Lines changed: 42 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -423,9 +423,14 @@ insertPragma: true # Insert @prettier pragma
423423

424424
### File Structure Conventions
425425

426+
**TypeScript (REQUIRED for all new files):**
427+
- All new source files must be written in TypeScript (`.ts` / `.tsx`)
428+
- Use `.tsx` for React components, `.ts` for all other modules
429+
- Existing `.js` / `.jsx` files are not required to be migrated, but new code must not be added in plain JavaScript
430+
426431
**Components:**
427432
- Location: `src/core/components/`
428-
- Extension: `.jsx` (React components)
433+
- Extension: `.tsx` (React components — TypeScript)
429434
- Format: PascalCase for component names
430435

431436
**Styles:**
@@ -437,7 +442,7 @@ insertPragma: true # Insert @prettier pragma
437442
**Tests:**
438443
- Unit: `test/unit/` (mirrors source structure)
439444
- E2E: `test/e2e-cypress/e2e/`
440-
- Naming: `*.test.js`, `*.spec.js`, `*.cy.js` (Cypress)
445+
- Naming: `*.test.ts`, `*.spec.ts`, `*.cy.ts` (Cypress) — use `.tsx` variants when JSX is involved
441446

442447
---
443448

@@ -764,7 +769,7 @@ dist/ # Build output (generated)
764769
### Adding a New Component
765770

766771
1. Create component in `src/core/components/` or appropriate plugin directory
767-
2. Use `.jsx` extension
772+
2. Use `.tsx` extension (TypeScript — required for all new files)
768773
3. Add `@prettier` pragma
769774
4. Follow React best practices (functional components, hooks)
770775
5. Add PropTypes validation
@@ -774,7 +779,7 @@ dist/ # Build output (generated)
774779
### Adding a New Plugin
775780

776781
1. Create directory in `src/core/plugins/[plugin-name]/`
777-
2. Create `index.js` with plugin structure
782+
2. Create `index.ts` with plugin structure (TypeScript — required for all new files)
778783
3. Add actions, reducers, selectors as needed
779784
4. Register plugin in preset (e.g., `src/core/presets/base.js`)
780785
5. Add tests in `test/unit/core/plugins/[plugin-name]/`
@@ -863,40 +868,42 @@ dist/ # Build output (generated)
863868
### DO's ✅
864869

865870
1. **Always read files before modifying them**
866-
2. **Follow the no-semicolon convention**
867-
3. **Use double quotes for strings**
868-
4. **Add `@prettier` pragma to all new files**
869-
5. **Use `.jsx` extension for React components**
870-
6. **Write tests for new features and bug fixes**
871-
7. **Run linters before committing** (automatic via husky)
872-
8. **Use DOMPurify for HTML sanitization**
873-
9. **Follow conventional commit format**
874-
10. **Update documentation for user-facing changes**
875-
11. **Test with multiple OpenAPI spec versions**
876-
12. **Check browser compatibility** (see `.browserslistrc`)
877-
13. **Use the plugin architecture** - don't modify core unnecessarily
878-
14. **Preserve backward compatibility** unless explicitly breaking
879-
15. **Run full test suite before submitting PR**
880-
16. **Keep plugins self-contained** - avoid cross-plugin imports (see [Cross-Plugin Import Guidelines](#cross-plugin-import-guidelines))
871+
2. **Write all new files in TypeScript** - use `.ts` for modules, `.tsx` for React components
872+
3. **Follow the no-semicolon convention**
873+
4. **Use double quotes for strings**
874+
5. **Add `@prettier` pragma to all new files**
875+
6. **Use `.tsx` extension for new React components** (TypeScript JSX)
876+
7. **Write tests for new features and bug fixes**
877+
8. **Run linters before committing** (automatic via husky)
878+
9. **Use DOMPurify for HTML sanitization**
879+
10. **Follow conventional commit format**
880+
11. **Update documentation for user-facing changes**
881+
12. **Test with multiple OpenAPI spec versions**
882+
13. **Check browser compatibility** (see `.browserslistrc`)
883+
14. **Use the plugin architecture** - don't modify core unnecessarily
884+
15. **Preserve backward compatibility** unless explicitly breaking
885+
16. **Run full test suite before submitting PR**
886+
17. **Keep plugins self-contained** - avoid cross-plugin imports (see [Cross-Plugin Import Guidelines](#cross-plugin-import-guidelines))
881887

882888
### DON'Ts ❌
883889

884-
1. **Don't use semicolons** - project convention
885-
2. **Don't use single quotes** - use double quotes
886-
3. **Don't skip the @prettier pragma** - required for formatting
887-
4. **Don't put React in `.js` files** - use `.jsx`
888-
5. **Don't commit files in `dev-helpers/`** (except core files)
889-
6. **Don't commit build artifacts** (`dist/` is gitignored)
890-
7. **Don't skip tests** - they run in CI
891-
8. **Don't bypass ESLint** - pre-commit hook enforces
892-
9. **Don't use `console.log`** - only `console.warn` and `console.error`
893-
10. **Don't render unsanitized HTML** - XSS vulnerability
894-
11. **Don't modify `package-lock.json` manually**
895-
12. **Don't push directly to `main` or `next`**
896-
13. **Don't ignore Cypress test failures**
897-
14. **Don't add dependencies without justification**
898-
15. **Don't break the build** - verify with `npm run build`
899-
16. **Don't import from other plugins** - create self-contained copies instead (e.g., don't import from `oas31` in `oas32`)
890+
1. **Don't write new files in plain JavaScript** - all new files must be TypeScript (`.ts` / `.tsx`)
891+
2. **Don't use semicolons** - project convention
892+
3. **Don't use single quotes** - use double quotes
893+
4. **Don't skip the @prettier pragma** - required for formatting
894+
5. **Don't put React in `.ts` files** - use `.tsx` for JSX
895+
6. **Don't commit files in `dev-helpers/`** (except core files)
896+
7. **Don't commit build artifacts** (`dist/` is gitignored)
897+
8. **Don't skip tests** - they run in CI
898+
9. **Don't bypass ESLint** - pre-commit hook enforces
899+
10. **Don't use `console.log`** - only `console.warn` and `console.error`
900+
11. **Don't render unsanitized HTML** - XSS vulnerability
901+
12. **Don't modify `package-lock.json` manually**
902+
13. **Don't push directly to `main` or `next`**
903+
14. **Don't ignore Cypress test failures**
904+
15. **Don't add dependencies without justification**
905+
16. **Don't break the build** - verify with `npm run build`
906+
17. **Don't import from other plugins** - create self-contained copies instead (e.g., don't import from `oas31` in `oas32`)
900907

901908
### When Working with AI Assistants
902909

babel.config.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ const browser = {
1111
}
1212
],
1313
"@babel/preset-react",
14+
"@babel/preset-typescript",
1415
],
1516
plugins: [
1617
[
@@ -59,6 +60,7 @@ module.exports = {
5960
}
6061
],
6162
"@babel/preset-react",
63+
"@babel/preset-typescript",
6264
],
6365
plugins: [
6466
[
@@ -101,7 +103,8 @@ module.exports = {
101103
useBuiltIns: false,
102104
}
103105
],
104-
"@babel/preset-react"
106+
"@babel/preset-react",
107+
"@babel/preset-typescript",
105108
],
106109
plugins: [
107110
[

0 commit comments

Comments
 (0)