Skip to content

fix(functions): update typescript templates to support ts 6 and fix linting - #10939

Merged
ajperel merged 1 commit into
mainfrom
ajp/fix-init-templates
Aug 17, 2026
Merged

ajperel merged 1 commit into
mainfrom
ajp/fix-init-templates

Conversation

@ajperel

@ajperel ajperel commented Aug 14, 2026

Copy link
Copy Markdown
Contributor

Description

Updates the TypeScript Cloud Functions template to support TypeScript 6 and resolves out-of-the-box linting errors/warnings in newly initialized projects.

Specifically:

  • Upgrades @typescript-eslint/eslint-plugin and @typescript-eslint/parser to ^8.0.0 and eslint to ^8.57.0 in package templates to support TypeScript 6.
  • Adds allowJs: true to tsconfig.dev.json to resolve the TS18003: No inputs were found error when linting config files (like .eslintrc.js).
  • Comments out unused imports (onRequest, logger) in index.ts by default to avoid unused variable warnings.
  • Fixes spacing in setGlobalOptions in index.ts to match standard ESLint spacing rules.

Scenarios Tested

  • Initialized a new project using the updated templates and verified that npm run lint passes successfully without any warnings or errors.
  • Verified that firebase deploy functions runs successfully without warnings or errors.

Sample Commands

  • firebase init

TAG=agy
CONV=e55af4de-d0de-4b48-841c-43e04476766c

@ajperel
ajperel requested review from inlined and joehan August 14, 2026 21:24

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request updates the default TypeScript functions template by commenting out unused imports, upgrading ESLint and TypeScript ESLint devDependencies, and enabling allowJs in tsconfig.dev.json. The reviewer suggested adding "noEmit": true to tsconfig.dev.json to prevent accidental compilation output during linting or IDE analysis.

Comment on lines +2 to +4
"compilerOptions": {
"allowJs": true
},

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Since tsconfig.dev.json is used specifically for linting configuration files and does not extend the main tsconfig.json, running tsc against this configuration (or IDE tooling doing so automatically) could accidentally emit compiled JavaScript files into the project root. Adding "noEmit": true prevents any accidental compilation output.

  "compilerOptions": {
    "allowJs": true,
    "noEmit": true
  },

@@ -1,4 +1,7 @@
{
"compilerOptions": {
"allowJs": true

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the only bit from Jetski that I'm a little skeptical of but it says it's necessary to not get an error when in turn using .eslintrc.js below.

@joehan

joehan commented Aug 14, 2026

Copy link
Copy Markdown
Member

/joe-review

@joehan joehan left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Disclaimer: This draft review was generated by an experimental AI review agent. Please verify all findings before acting on them.\n\n## Code Review Summary: firebase/firebase-tools\n\n### 🟢 Strengths & LGTM Aspects\n- Support for TypeScript 6: Upgrades ESLint parser and plugin packages to ^8.0.0 in the templates to resolve compatibility issues with TypeScript 6 devDependencies.\n- Zero-error Initialization UX: Resolves out-of-the-box linting warnings by commenting out unused imports (onRequest, logger) in the default index.ts template, and fixes a style violation by removing spaces inside setGlobalOptions arguments.\n- Elegant Lint Config Solution: Resolves the TS18003: No inputs were found error by introducing \"allowJs\": true inside the development-only tsconfig.dev.json which is target-tailored for linting .eslintrc.js without compromising the production TypeScript build constraints.\n\n### 🔴 Overview of Findings\n- Missing noEmit constraint: In tsconfig.dev.json, enabling \"allowJs\": true without \"noEmit\": true might cause build systems or IDEs to accidentally emit compilation artifacts for .eslintrc.js. We recommend adding \"noEmit\": true inside the compiler options.\n

Comment thread templates/init/functions/typescript/index.ts
// In the v1 API, each function can only serve one request per container, so
// this will be the maximum concurrent request count.
setGlobalOptions({ maxInstances: 10 });
setGlobalOptions({maxInstances: 10});

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 [Style & Linting] Spacing\n\nFormatting setGlobalOptions parameters without inner spacing correctly aligns the code with standard Google ESLint configuration (object-curly-spacing: never) that is extended by the template's config.

@@ -1,4 +1,7 @@
{
"compilerOptions": {
"allowJs": true

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔴 [TypeScript Config] Add noEmit: true\n\nRationale: Since allowJs: true is now enabled in tsconfig.dev.json, there is a risk that running the TypeScript compiler against this config will emit build artifacts. Adding \"noEmit\": true prevents this.\n\nSuggested Fix:\njson\n \"compilerOptions\": {\n \"allowJs\": true,\n \"noEmit\": true\n },\n

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@joehan joehan left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM after tweaks

…inting

### Description
Updates the TypeScript Cloud Functions template to support TypeScript 6 and resolves out-of-the-box linting errors/warnings in newly initialized projects.

Specifically:
- Upgrades `@typescript-eslint/eslint-plugin` and `@typescript-eslint/parser` to `^8.0.0` and `eslint` to `^8.57.0` in package templates to support TypeScript 6.
- Adds `allowJs: true` to `tsconfig.dev.json` to resolve the `TS18003: No inputs were found` error when linting config files (like `.eslintrc.js`).
- Comments out unused imports (`onRequest`, `logger`) in `index.ts` by default to avoid unused variable warnings.
- Fixes spacing in `setGlobalOptions` in `index.ts` to match standard ESLint spacing rules.

### Scenarios Tested
- Initialized a new project using the updated templates and verified that `npm run lint` passes successfully without any warnings or errors.
- Verified that `firebase deploy functions` runs successfully without warnings or errors.

### Sample Commands
- `firebase init`

TAG=agy
CONV=e55af4de-d0de-4b48-841c-43e04476766c
@ajperel
ajperel force-pushed the ajp/fix-init-templates branch from c652375 to 0e72a97 Compare August 14, 2026 21:57
@ajperel
ajperel merged commit 7cb4b37 into main Aug 17, 2026
79 of 80 checks passed
@ajperel
ajperel deleted the ajp/fix-init-templates branch August 17, 2026 17:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants