Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

eslint-plugin-firebase-functions

alii925MIT1.0.14TypeScript support: included

null

firebase, eslint, eslintplugin, firebase-functions

readme

eslint-plugin-firebase-functions

An eslint plugin that provides utilty rules for working with firebase functions.

Install

yarn add eslint-plugin-firebase-functions --dev

And add the plugin to your .eslintrc.js and make sure you enable the rules you want to use:

module.exports = {
    plugins: ['firebase-functions'],
    rules: {
        // Example enabling a rule
        'firebase-functions/<rule>': 'error',
    },
};

Rules:

<summary> safe-function-exports — Ensures that firebase functions defined in a file are exported inline as a named export </summary>
import * as functions from 'firebase-functions';

/////////////////////
// Incorrect usage //
/////////////////////

const bad = functions
    .runWith({timeoutSeconds: 2000})
    .https.onRequest((req, res) => {
        //
    });

const bad2 = functions.https.onRequest((req, res) => {
    //
});

// Fails because not inline
export {bad};

///////////////////
// Correct usage //
///////////////////

export const good = functions
    .runWith({timeoutSeconds: 2000})
    .https.onRequest((req, res) => {
        //
    });

export const good2 = functions.https.onRequest((req, res) => {
    //
});