javascript - 如何从 package.json 脚本中正确调用 eslint?
问题描述
我正在尝试将功能部署到 firebase,但 ESLint 似乎存在问题。我试图通过按Shift
++Option
对其进行格式化F
,但这似乎也不起作用。
当我尝试初始化 eslint 时,它要求我创建一个已经存在的新 package.json 文件。
这是package.json
文件
{
"name": "functions",
"description": "Cloud Functions for Firebase",
"scripts": {
"lint": "eslint.js",
"serve": "firebase emulators:start --only functions",
"shell": "firebase functions:shell",
"start": "npm run shell",
"deploy": "firebase deploy --only functions",
"logs": "firebase functions:log"
},
"engines": {
"node": "14"
},
"main": "index.js",
"dependencies": {
"firebase-admin": "^9.8.0",
"firebase-functions": "^3.14.1"
},
"devDependencies": {
"eslint": "^7.6.0",
"eslint-config-google": "^0.14.0",
"firebase-functions-test": "^0.2.0"
},
"private": true
}
如果我使用"eslint ."
而不是"eslint.js"
in package.json
,我会收到以下标识错误
8:1 error Expected indentation of 6 spaces but found 8 indent
9:8 error Newline required at end of file but not found eol-last
解决方案
你是在自问自答。要运行 eslint,你只需要eslint
在脚本中,而不是eslint.js
.
当 eslint 运行时,它会为您提供 linter 输出,因此请修复这些问题。
8:1 error Expected indentation of 6 spaces but found 8 indent
9:8 error Newline required at end of file but not found eol-last
这是 eslint 输出,表明您有违反 lint 规则的代码。您的选择是:
- 修复缩进和缺少换行符。
- 调整您的 eslint 脚本以忽略具有这些错误的文件
- 调整您的 lint 规则以删除这两个规则
- 停止使用 eslint。
推荐阅读
- c++ - 如何修复代码块中的 nan?
- javascript - Javascript 异步操作慢
- android - Android osm 地图中出现未知标记
- python - Plotly 中大型数据集的 3D 散点图
- django - 如何在 Django 中存储变量?
- java - 无法通过加载 jpg 文件分配内存 - Android Studio Erro
- if-statement - Roblox if 语句未运行
- swift - 无法理解 watchkit 扩展崩溃
- c - strtok 和 fgets 的奇数数组行为
- postgresql - 如何使用 git bash 将数据库推送到 heroku?