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

Axi*_*xil 13 lint node.js npm firebase google-cloud-functions

我有一个 firebase 函数代码,有很多 Lint 问题。我怎样才能用--fix修复这些问题。它显示在错误消息的末尾。

\n
\n

火力基地部署

\n
\n
/Users/xxx/firebase/functions/index.js\n  16:1   error  Unexpected tab character                             no-tabs\n  16:1   error  Expected indentation of 6 spaces but found 1 tab     indent\n  .....\n  69:1   error  Unexpected tab character                             no-tabs\n  69:1   error  Expected indentation of 6 spaces but found 1 tab     indent\n  69:5   error  Trailing spaces not allowed                          no-trailing-spaces\n  69:5   error  Block must not be padded by blank lines              padded-blocks\n  71:1   error  Trailing spaces not allowed                          no-trailing-spaces\n\n\xe2\x9c\x96 157 problems (157 errors, 0 warnings)\n  45 errors and 0 warnings potentially fixable with the `--fix` option.\n
Run Code Online (Sandbox Code Playgroud)\n

小智 26

该错误消息可能来自 eslint。您可以直接运行 eslint:

$ (cd functions && npx eslint . --fix)
# or
$ (cd functions && node_modules/eslint/bin/eslint.js . --fix)
Run Code Online (Sandbox Code Playgroud)