小编Mat*_*rpi的帖子

更改 ESLint 中的“shouldFix”参数

我正在使用 ESLint 及其 VS Code 扩展来格式化我的代码。

在某些时候,它会停止在保存时自动格式化代码。我卸载了所有内容并重新安装:VS Code、ESLint 和 VS Code 的 ESLint 扩展。

我想我已经接近让格式化程序正常工作了,但是当我尝试保存带有 linting 错误的文件时,ESLint 会将其记录在 VS Code 中:

2020-10-10T10:41:45.345Z eslint:source-code-fixer shouldFix parameter was false, not attempting fixes
Run Code Online (Sandbox Code Playgroud)

我想如果我找到该shouldFix参数并将其设置为true它会起作用,但是它在哪里?

javascript eslint visual-studio-code

5
推荐指数
2
解决办法
3347
查看次数

在 Gatsby.js 中以编程方式创建多种类型的页面

我正在用 GatsbyJS 建立一个网站。我在两个不同的文件夹中有 Markdown 文件:/content/collections并且/content/posts我希望 Gatsby 使用相应的模板(collection.js 和 post.js)为每个 Markdown 文件创建一个页面。

所以我在我的 gatsby-node.js 文件中写了这个:

const path = require('path');
const { createFilePath } = require('gatsby-source-filesystem');
exports.onCreateNode = ({ node, getNode, actions }) => {
  const { createNodeField } = actions;
  if (node.internal.type === 'MarkdownRemark') {
    const longSlug = createFilePath({ node, getNode, basePath: 'content' });
    const slug = longSlug.split('/');
    createNodeField({
      node,
      name: 'slug',
      value: `/${slug[slug.length - 2]}/`,
    });
  }
};

exports.createPages = async ({ graphql, actions }) => …
Run Code Online (Sandbox Code Playgroud)

javascript reactjs gatsby

5
推荐指数
1
解决办法
1289
查看次数

迁移到 Vite:未捕获类型错误:无法读取未定义的属性“attrs”

create-react-app出于开发环境性能的原因,我正在尝试将大型应用程序从 Vite.js 迁移到 Vite.js。

我遵循了本指南:https ://phelipetls.github.io/posts/migration-from-cra-to-vite/

这是详细的错误:

Uncaught TypeError: Cannot read property 'attrs' of undefined
    at node_modules/styled-bootstrap-grid/dist/components/Container/Container.js (Container.js:68)
    at __require2 (chunk-VZ7BJMYF.js?v=f5540ad4:17)
    at node_modules/styled-bootstrap-grid/dist/components/Container/index.js (index.js:27)
    at __require2 (chunk-VZ7BJMYF.js?v=f5540ad4:17)
    at node_modules/styled-bootstrap-grid/dist/index.js (index.js:53)
    at __require2 (chunk-VZ7BJMYF.js?v=f5540ad4:17)
    at dep:styled-bootstrap-grid:1
node_modules/styled-bootstrap-grid/dist/components/Container/Container.js @ Container.js:68
__require2 @ chunk-VZ7BJMYF.js?v=f5540ad4:17
node_modules/styled-bootstrap-grid/dist/components/Container/index.js @ index.js:27
__require2 @ chunk-VZ7BJMYF.js?v=f5540ad4:17
node_modules/styled-bootstrap-grid/dist/index.js @ index.js:53
__require2 @ chunk-VZ7BJMYF.js?v=f5540ad4:17
(anonymous) @ dep:styled-bootstrap-grid:1
injector.js:239 
Run Code Online (Sandbox Code Playgroud)

我该如何调试这个?有什么建议吗?

提前致谢!

中号

javascript reactjs create-react-app vite

5
推荐指数
1
解决办法
3250
查看次数

Vite.js + React:超出最大调用堆栈大小

我正在将使用 CRA 创建的大型应用程序迁移到 Vite.js

\n

我按照本指南使用现有应用程序配置新的捆绑器,现在运行开发服务器时一切看起来都很好。

\n

但是,当尝试编译生产版本时,我遇到以下错误:

\n
vite v2.6.14 building for production...\n\xe2\x9c\x93 162 modules transformed.\n[vite:react-jsx] unknown: Maximum call stack size exceeded\nfile: /Users/matteocarpi/Documents/Web/philip-morris/aws-amplify-multi-tenant/node_modules/react-i18next/dist/es/Trans.js\nerror during build:\nRangeError: unknown: Maximum call stack size exceeded\n    at getJSXProps (/Users/matteocarpi/Documents/Web/aws-amplify-multi-tenant/node_modules/vite-react-jsx/dist/cjs/babelRestoreJsx.js:79:29)\n    at getJSXNode (/Users/matteocarpi/Documents/Web/aws-amplify-multi-tenant/node_modules/vite-react-jsx/dist/cjs/babelRestoreJsx.js:31:23)\n    at PluginPass.CallExpression (/Users/matteocarpi/Documents/Web/aws-amplify-multi-tenant/node_modules/vite-react-jsx/dist/cjs/babelRestoreJsx.js:165:30)\n    at newFn (/Users/matteocarpi/Documents/Web/aws-amplify-multi-tenant/node_modules/@babel/traverse/lib/visitors.js:177:21)\n    at NodePath._call (/Users/matteocarpi/Documents/Web/aws-amplify-multi-tenant/node_modules/@babel/traverse/lib/path/context.js:53:20)\n    at NodePath.call (/Users/matteocarpi/Documents/Web/aws-amplify-multi-tenant/node_modules/@babel/traverse/lib/path/context.js:40:17)\n    at NodePath.visit (/Users/matteocarpi/Documents/Web/aws-amplify-multi-tenant/node_modules/@babel/traverse/lib/path/context.js:100:31)\n    at TraversalContext.visitQueue (/Users/matteocarpi/Documents/Web/aws-amplify-multi-tenant/node_modules/@babel/traverse/lib/context.js:103:16)\n    at TraversalContext.visitQueue (/Users/matteocarpi/Documents/Web/aws-amplify-multi-tenant/node_modules/@babel/traverse/lib/context.js:109:21)\n    at TraversalContext.visitQueue (/Users/matteocarpi/Documents/Web/aws-amplify-multi-tenant/node_modules/@babel/traverse/lib/context.js:109:21)\n
Run Code Online (Sandbox Code Playgroud)\n

我知道这与 Babel 和 i18next 有关,但我有点困惑具体问题是什么。

\n

有关如何进一步调试的任何提示?

\n

提前致谢,

\n

中号

\n

reactjs babeljs vite

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