firebase - Firebase Cloud Functions ESLint 最近是否发生了变化?
问题描述
几个月前我用firebase创建了一个云功能项目,并使用了linting。
我最近创建了一个带有 linting 的新云功能项目,现在 linter 抱怨我从未设置的随机规则。我不记得它在几个月前执行了几乎数量的样式规则。
像:
This line has a length of 95. Maximum allowed is 80
Missing JSDoc comment
Missing Trailing comma
expected indentation of 2 spaces but found 4
Strings must use singlequote
它也不让我使用异步/等待。
我发现我可以在我的 .eslintrc.js 文件中单独设置这些规则,但这很烦人,我不想这样做。默认情况下,为什么不禁用这些规则?我只想要确保我的代码在运行时不会失败的基本规则,而不是像单引号/双引号和最大行长这样的随机样式偏好。
有什么方法可以将基本的 linting 功能与 firebase 功能一起使用?
解决方案
我遇到了和你一样的问题。新的、更严格的 linting 规则似乎来自 Firebase 函数现在默认使用“google” eslint 基本配置插件这一事实。在文档中阅读更多关于配置 ESLint 插件的信息。我的旧 Firebase 函数使用 tslint 没有问题。
当我从 eslint 获取样式错误时,这是我的 .eslintrc.js 文件的样子:
module.exports = {
env: {
es6: true,
node: true,
},
extends: [
'eslint:recommended',
'plugin:import/errors',
'plugin:import/warnings',
'plugin:import/typescript',
'google',
],
parser: '@typescript-eslint/parser',
parserOptions: {
project: ['tsconfig.json', 'tsconfig.dev.json'],
sourceType: 'module',
},
ignorePatterns: [
'/lib/**/*', // Ignore built files.
],
plugins: ['@typescript-eslint', 'import'],
rules: {
quotes: ['error', 'double'],
},
};
我从 extends 属性中删除了“google”,这似乎解决了几乎所有的样式 linting 问题。
现在看起来像这样:
module.exports = {
env: {
es6: true,
node: true,
},
extends: [
'eslint:recommended',
'plugin:import/errors',
'plugin:import/warnings',
'plugin:import/typescript',
],
parser: '@typescript-eslint/parser',
parserOptions: {
project: ['tsconfig.json', 'tsconfig.dev.json'],
sourceType: 'module',
},
ignorePatterns: [
'/lib/**/*', // Ignore built files.
],
plugins: ['@typescript-eslint', 'import'],
rules: {
quotes: ['error', 'double'],
},
};
推荐阅读
- bison - yyllocp->first_line 在可重入 Bison 解析器的第二次迭代中返回未初始化的值
- python - 瀑布图python matplotlib
- javascript - 如何保存我下载的模型?
- java - Xpath编译正则表达式不显示xml注释
- r - 从全局环境中删除所有 R 数据对象
- javascript - TipTap 和 Nuxt - 无法从非 EcmaScript 模块导入命名导出“{module}”
- python - 一种检查字符串是否同时包含字符串和数字的方法
- scheme - 在 DrRacket 中调试#lang sicp
- .net - 如何将凭据映射到 SQL Server 中的 SQLCLR 程序集?
- python - 如何从一个列表中生成所有可能的球员球队?