Skip to content

Use Prettier to format samples #1203

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
2 changes: 1 addition & 1 deletion Node-1st-gen/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@

This folder contains examples for 1st gen functions. Note that 2nd gen functions are available and the recommended platform for Cloud Functions for Firebase.

See a description of all samples in this folder in the [root README](../README.md).
See a description of all samples in this folder in the [root README](../README.md).
20 changes: 10 additions & 10 deletions Node-1st-gen/assistant-say-number/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@ This sample shows how to create an action for the Google Home/Assistant using th
e.g. If the user says "Twelve" the action will say "The ordinal of twelve is twelfth".

Further reading:
- Actions SDK: https://developers.google.com/actions/develop/sdk/getting-started#getting-started.
- Firebase SDK: https://firebase.google.com/docs/functions

- Actions SDK: https://developers.google.com/actions/develop/sdk/getting-started#getting-started.
- Firebase SDK: https://firebase.google.com/docs/functions

## Functions Code

Expand All @@ -16,15 +17,14 @@ Handling the Google Actions requests is done using the [Google Actions SDK](http

The dependencies are listed in [functions/package.json](functions/package.json).


## Deploy and test

To test this sample action:

- Create a Firebase Project using the [Firebase Developer Console](https://console.firebase.google.com)
- Configure this sample to use your project using `firebase use --add` and select your project.
- Deploy your project using `firebase deploy`
- In the `action.json` file, update the two `<YOUR_PROJECT_ID>` placeholders with your Firebase project ID. The URL should match the `Function URL (sayNumber):` that was printed out by `firebase deploy`.
- [Download](https://developers.google.com/actions/tools/gactions-cli) the `gaction` CLI
- Make your action available for testing using the `gactions preview action.json`
- Test your Action on the [Google Home Web Simulator](https://g.co/actionswebsim) by saying "Talk to My Action"
- Create a Firebase Project using the [Firebase Developer Console](https://console.firebase.google.com)
- Configure this sample to use your project using `firebase use --add` and select your project.
- Deploy your project using `firebase deploy`
- In the `action.json` file, update the two `<YOUR_PROJECT_ID>` placeholders with your Firebase project ID. The URL should match the `Function URL (sayNumber):` that was printed out by `firebase deploy`.
- [Download](https://developers.google.com/actions/tools/gactions-cli) the `gaction` CLI
- Make your action available for testing using the `gactions preview action.json`
- Test your Action on the [Google Home Web Simulator](https://g.co/actionswebsim) by saying "Talk to My Action"
6 changes: 3 additions & 3 deletions Node-1st-gen/assistant-say-number/firebase.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"functions": {
"codebase": "assistant-say-number"
}
"functions": {
"codebase": "assistant-say-number"
}
}
122 changes: 0 additions & 122 deletions Node-1st-gen/assistant-say-number/functions/.eslintrc.json

This file was deleted.

29 changes: 29 additions & 0 deletions Node-1st-gen/assistant-say-number/functions/eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/**
* Copyright 2025 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

import { defineConfig } from "eslint/config";
import js from "@eslint/js";
import globals from "globals";
import tseslint from "typescript-eslint";

export default defineConfig([
{ files: ["**/*.{js,mjs,cjs,ts}"], plugins: { js }, extends: ["js/recommended"] },
{ files: ["**/*.js"], languageOptions: { sourceType: "commonjs" } },
{ files: ["**/*.{js,mjs,cjs,ts}"], languageOptions: { globals: globals.node } },
{ files: ["**/*.ts"], ...tseslint.configs.base },
// samples often have unused vars just to show some value is available
{ files: ["**/*.{js,mjs,cjs,ts}"], rules: { "no-unused-vars": "off" } },
]);
18 changes: 9 additions & 9 deletions Node-1st-gen/assistant-say-number/functions/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,26 +13,26 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
'use strict';
"use strict";

const functions = require('firebase-functions/v1');
const { actionssdk } = require('actions-on-google');
const functions = require("firebase-functions/v1");
const { actionssdk } = require("actions-on-google");

const app = actionssdk();
app.intent('actions.intent.MAIN', (conv) => {
conv.ask(`<speak>
app.intent("actions.intent.MAIN", (conv) => {
conv.ask(`<speak>
Hi! <break time="1"/>
I can read out an ordinal number like <say-as interpret-as="ordinal">123</say-as>.
Say a number.
</speak>`);
});

app.intent('actions.intent.TEXT', (conv) => {
app.intent("actions.intent.TEXT", (conv) => {
const rawInput = conv.input.raw;
if (rawInput === 'bye') {
conv.ask('Goodbye!');
if (rawInput === "bye") {
conv.ask("Goodbye!");
} else if (isNaN(parseInt(rawInput, 10))) {
conv.ask('I didn\'t quite get that, what was the number?');
conv.ask("I didn't quite get that, what was the number?");
} else {
conv.ask(`<speak>
The ordinal of <say-as interpret-as="cardinal">${rawInput}</say-as> is
Expand Down
12 changes: 9 additions & 3 deletions Node-1st-gen/assistant-say-number/functions/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,17 @@
"firebase-functions": "^6.3.0"
},
"devDependencies": {
"eslint": "^8.57.1",
"eslint-plugin-promise": "^7.2.1"
"@eslint/js": "^9.24.0",
"eslint": "^9.24.0",
"eslint-config-prettier": "^10.1.2",
"eslint-plugin-promise": "^7.2.1",
"globals": "^16.0.0",
"prettier": "^3.5.3",
"typescript-eslint": "^8.30.1"
},
"scripts": {
"lint": "./node_modules/.bin/eslint --max-warnings=0 .",
"lint": "eslint .",
"lint:fix": "prettier . --write",
"serve": "firebase emulators:start --only functions",
"shell": "firebase functions:shell",
"start": "npm run shell",
Expand Down
Loading
Loading