小编iam*_*lli的帖子

如何修复此错误消息“初始化错误 (Eslint)。意外的标识符”?

我有EslintJSCS设置,可以使用WebStorm中的airbnb js 样式指南重新格式化一些代码库。在过去的两天里,我一直在有效地使用这个设置,但是突然间,WebStorm 开始抛出这个错误......

ESLint 重新格式化问题:index.js:初始化错误 (ESLint)。意外的标识符

在此输入图像描述

我想也许我的.eslintrc中有一些错误,但后来我在这个突然的错误之前使用相同的配置成功重构了大约 150 个文件。在此之前,JSCS编译器偶尔会抛出“不到一分钟超时”异常,但随后我会通过关闭并重新打开文件来修复此问题。不过eslint似乎并没有上当

这是我的.eslintrc配置

{
  "extends": "airbnb",
  "env": {
    "browser": true,
    "node": true
  },
  "globals": {
    "document": false
  },
  "rules": {
    "validateIndentation": 4,
    "func-names": [
      "error",
      "never"
    ],
    "react/jsx-filename-extension": [
      1,
      {
        "extensions": [
          ".js",
          ".jsx"
        ]
      }
    ],
    "jsx-a11y/label-has-for": [
      2,
      {
        "components": [
          "Label"
        ],
        "required": {
          "some": [
            "nesting",
            "id"
          ]
        },
        "allowChildren": false
      } …
Run Code Online (Sandbox Code Playgroud)

webstorm eslint eslint-config-airbnb

9
推荐指数
2
解决办法
1万
查看次数

如何将动态转换器与 firebase 和 TypeScript 结合使用?

我正在尝试动态地将转换器传递给firebases withConverter。如果您查看 上的文档FirestoreDataConverter,如果将转换器直接传递到 ,则提供的示例可以工作withConverter

// I have modified Post Class as seen in the docs, with additional types
class Post {
  constructor(readonly title: string, readonly author: string) {
    this.title = title;
    this.author = author;
  }

  toString(): string {
    return `${this.title}, by ${this.author}`;
  }
}

type PostConverterType = firebase.firestore.FirestoreDataConverter<Post>;

// Example converter from the docs
const postConverter: PostConverterType = {
  toFirestore(post: Post): firebase.firestore.DocumentData {
    return { title: post.title, author: post.author };
  },
  fromFirestore(
    snapshot: …
Run Code Online (Sandbox Code Playgroud)

firebase typescript google-cloud-firestore

8
推荐指数
0
解决办法
1827
查看次数

如何在用 AnimatePresence 包装的 Next.js 页面中导航和滚动到带有 ID 的元素

我正在使用Framer MotionNext.js页面过渡设置动画。但是,使用AnimatePresence会破坏hash链接导航,页面不再转到目标id元素。

页面转换是完美的,直到您想导航到页面上的苛刻 ID :(

// I have a link component setup like this
// index.tsx
<Link href="/about#the-team" scroll={false}>
  <a>The Team</a>
</Link>

// Targeting another page `about.tsx` with the id
// about.tsx

{/* ...many sections before.. */}
<section id="the-team">{content}</section>
Run Code Online (Sandbox Code Playgroud)

我有一个自定义_app.tsx,如下所示。

// _app.tsx
import { AppProps } from 'next/app';
import { useRouter } from 'next/router';
import { AnimatePresence } from 'framer-motion';

const MyApp = ({ Component, pageProps }: AppProps): …
Run Code Online (Sandbox Code Playgroud)

javascript scroll reactjs next.js framer-motion

6
推荐指数
1
解决办法
9873
查看次数