GithubHelp home page GithubHelp logo

isabella232 / actions-on-google-linter-nodejs Goto Github PK

View Code? Open in Web Editor NEW

This project forked from actions-on-google/actions-on-google-linter-nodejs

0.0 0.0 0.0 70 KB

License: Apache License 2.0

JavaScript 100.00%

actions-on-google-linter-nodejs's Introduction

eslint-plugin-actions-on-google

This repository provides implementation of rules to check for common errors in response generation inside of your webhook code on Actions on Google platform using the official Actions on Google Node.js client library.

NPM Version

Installation

You'll first need to install ESLint:

$ npm i eslint --save-dev

Next, install eslint-plugin-actions-on-google:

$ npm install eslint-plugin-actions-on-google --save-dev

Note: If you installed ESLint globally (using the -g flag) then you must also install eslint-plugin-actions-on-google globally.

Usage

Add actions-on-google to the plugins section of your .eslintrc configuration file. You can omit the eslint-plugin- prefix:

{
    "plugins": [
        "actions-on-google"
    ]
}

Then configure the rules you want to use under the rules section. In the snippet below, rule-name is a placeholder value for an actual name of a rule)

{
    "rules": {
        "actions-on-google/rule-name": "error"
    }
}

Supported Rules

  • always-return-promise
    • If intent handler uses a Promise, it must return it.
  • at-most-two-simple-responses
    • The response returned by Actions on Google fulfillment must have <=2 simple responses per turn.
  • first-item-simple-or-helper-response
    • The first item in webhook response must be a simple response, or a helper
  • must-return-response
    • The response returned by Actions on Google fulfillment must return a client library response.

For source code of the rules refer to lib/rules/

References & Issues

Make Contributions

Please read and follow the steps in the CONTRIBUTING.md.

Developer's Guide

The plugin was implemented using the official ESLint guide. Please refer to those docs on how to get started with writing new rules.

The rules were created based on:

  • The official Actions on Google Responses documentation.
  • The most common issues reported by developers

Most of the rules regarding the Actions on Google response generation has to do with:

  • How many of a kind the final response contains. For example, it's only allowed to have at most 2 simple responses, or at most 8 suggestions chips.
  • Was something returned or not. For example, suggestion chips are not allowed in a FinalResponse. Please refer for a full list of rules in the documentation.

As such, we implemented useful library modules to assist with those 2 tasks, located in count-scope-manager and presence-scope-manager. Additionally, we provide library for classifying simple and helper responses. Together those modules can be reused to create more rules.

Note

  • Performing robust checks is difficult on a dynamically typed language, such as JavaScript. As such, linter is not guaranteed to raise 100% of the issues in your code. However, we provide guarantees that those errors reported by the linter are valid.
  • Linter entirely relies on the Action code written using Actions on Google Node.js client library.

License

See LICENSE.

Terms

Your use of this sample is subject to, and by using or downloading the sample files you agree to comply with, the Google APIs Terms of Service.

actions-on-google-linter-nodejs's People

Contributors

atulep avatar fleker avatar sudiptachatterjee avatar taycaldwell avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.