首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >( ESLint /Cypress):解析错误:ESLint被配置为使用`parserOptions.project`在`parserOptions.project`上运行

( ESLint /Cypress):解析错误:ESLint被配置为使用`parserOptions.project`在`parserOptions.project`上运行
EN

Stack Overflow用户
提问于 2022-11-12 13:48:43
回答 1查看 1K关注 0票数 1

我正在使用Remix (remix.run)建立一个新的项目,并试图为组件测试配置Cypress/ESLint。我有一个带有样板代码的TestComponent.cy.ts

代码语言:javascript
运行
复制
describe('TestComponent.cy.ts', () => {
  it('playground', () => {
    // cy.mount()
  })
})

但是,describe函数引发此错误:

代码语言:javascript
运行
复制
    Parsing error: ESLint was configured to run on `<tsconfigRootDir>/component/TestComponent.cy.ts` using `parserOptions.project`: <tsconfigRootDir>/../../../../../../users/tduke/desktop/dev/blog/cypress/tsconfig.json
    However, that TSConfig does not include this file. Either:
    - Change ESLint's list of included files to not include this file
    - Change that TSConfig to include this file
    - Create a new TSConfig that includes this file and include it in your parserOptions.project

我试图重新配置我的.tsconfig.json.eslintrc.js,但没有结果。目前,这些文件是这样的:

tsconfig.json:

代码语言:javascript
运行
复制
{
  "exclude": ["./cypress", "./cypress.config.ts"],
  "include": ["remix.env.d.ts", "**/*.ts", "**/*.tsx", "./cypress/component/*.cy.ts", "./cypress/**/*.cy.ts", 
  ],
  "compilerOptions": {
    "lib": ["DOM", "DOM.Iterable", "ES2019"],
    "types": ["vitest/globals"],
    "isolatedModules": true,
    "esModuleInterop": true,
    "jsx": "react-jsx",
    "module": "CommonJS",
    "moduleResolution": "node",
    "resolveJsonModule": true,
    "target": "ES2019",
    "strict": true,
    "allowJs": true,
    "forceConsistentCasingInFileNames": true,
    "baseUrl": ".",
    "paths": {
      "~/*": ["./app/*"]
    },
    "skipLibCheck": true,

    // Remix takes care of building everything in `remix build`.
    "noEmit": true
  }
}

.eslintrc.js:

代码语言:javascript
运行
复制
/** @type {import('@types/eslint').Linter.BaseConfig} */
module.exports = {
  extends: [
    "@remix-run/eslint-config",
    "@remix-run/eslint-config/node",
    "@remix-run/eslint-config/jest-testing-library",
    "prettier",
  ],
  env: {
    "cypress/globals": true,
  },
  parserOptions: {
    project: './tsconfig.json'
  },
  plugins: ["cypress"],
  // We're using vitest which has a very similar API to jest
  // (so the linting plugins work nicely), but we have to
  // set the jest version explicitly.
  settings: {
    jest: {
      version: 28,
    },
  },
};
EN

回答 1

Stack Overflow用户

发布于 2022-11-13 13:48:48

我也遇到了同样的问题,我通过删除project属性在parserOptions下解决了这个问题。

代码语言:javascript
运行
复制
parserOptions: {
  ecmaFeatures: {
    jsx: true,
  },
  ecmaVersion: 12,
  sourceType: 'module',
  // project: 'tsconfig.json',
  tsconfigRootDir: __dirname,
},

票数 3
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/74413483

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档