如何在 Firebase 函数中使用 --fix 修复 Lint 问题

How to fix Lint problems with --fix in Firebase Functions

我的 firebase 函数代码存在很多 Lint 问题。如何使用 --fix 修复这些问题。它显示在错误消息的末尾。

firebase deploy

/Users/xxx/firebase/functions/index.js
  16:1   error  Unexpected tab character                             no-tabs
  16:1   error  Expected indentation of 6 spaces but found 1 tab     indent
  .....
  69:1   error  Unexpected tab character                             no-tabs
  69:1   error  Expected indentation of 6 spaces but found 1 tab     indent
  69:5   error  Trailing spaces not allowed                          no-trailing-spaces
  69:5   error  Block must not be padded by blank lines              padded-blocks
  71:1   error  Trailing spaces not allowed                          no-trailing-spaces

✖ 157 problems (157 errors, 0 warnings)
  45 errors and 0 warnings potentially fixable with the `--fix` option.

错误信息可能来自eslint。你可以直接 运行 eslint:

$ (cd functions && npx eslint . --fix)
# or
$ (cd functions && node_modules/eslint/bin/eslint.js . --fix)