Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/alii/eslint-plugin-firebase-functions

eslint-plugin-firebase-functions
https://github.com/alii/eslint-plugin-firebase-functions

eslint firebase plugin

Last synced: 24 days ago
JSON representation

eslint-plugin-firebase-functions

Awesome Lists containing this project

README

        

# eslint-plugin-firebase-functions

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

### Install

```sh
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:

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

### Rules:

safe-function-exports
Ensures that firebase functions defined in a file are exported inline as a named export

```ts
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) => {
//
});
```