GoogleCloudPlatform / functions-framework-nodejs

FaaS (Function as a service) framework for writing portable Node.js functions
Apache License 2.0
1.29k stars 158 forks source link

Freshly generated project for CF on TypeScript following official guide contains lots of eslint's violations #472

Closed evil-shrike closed 1 year ago

evil-shrike commented 2 years ago

Hi,

I followed the guide for creating a CF using TypeScript. I suppose it's an official guide how to build CFs using TypeScript. It uses gts for a project. And local .eslintrc.json refers to one in gts:

.eslintrc.json

{
  "extends": "./node_modules/gts/"
}

The problem is that if we run gts lint or open the project in VSCode we'll see tons of errors. And it's just in default freshly generated according an official guide project. Particularly any CF project will have this line:

import type {HttpFunction} from '@google-cloud/functions-framework/build/src/functions';

and eslint complains about it: "@google-cloud/functions-framework" is not published.

If we want to add typing for request/response we'll import import express from 'express'; which installed as a dev-dependency @types/express. Again it will cause a violation from eslint: "no-extraneous-import".

So I don't quite understand how it's suppose to work. We got a lint tool for free (gts/eslint) with some default config but it doesn't work even in empty project.

Can you please consider providing a working bootstrapping setup for TypeScript-based projects for CFs. Thanks.