Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot destructure property 'parent' of 'node' as it is undefined. #464

Closed
5 tasks done
gitsheny opened this issue Apr 30, 2024 · 5 comments
Closed
5 tasks done

Cannot destructure property 'parent' of 'node' as it is undefined. #464

gitsheny opened this issue Apr 30, 2024 · 5 comments
Labels

Comments

@gitsheny
Copy link

gitsheny commented Apr 30, 2024

Describe the bug

1.创建一个vite-vue模板项目,安装eslint相关

npm create vite@latest my-vue-app -- --template vue
npx @antfu/eslint-config@latest
npm i
  1. 在<script>中写一个未使用的方法
  2. 控制台执行npx eslint报错:
TypeError: Cannot destructure property 'parent' of 'node' as it is undefined.
Occurred while linting D:\JetBrains\Projects\1\my-vue-app\src\App.vue:2
Rule: "unused-imports/no-unused-imports"
    at exports.unusedImportsPredicate (D:\JetBrains\Projects\1\my-vue-app\node_modules\@antfu\eslint-config\node_modules\eslint-plugin-unused-imports\lib\rules\predicates.js:28:13)
    at Object.value [as report] (D:\JetBrains\Projects\1\my-vue-app\node_modules\eslint-rule-composer\lib\rule-composer.js:144:25)
    at Program:exit (D:\JetBrains\Projects\1\my-vue-app\node_modules\@antfu\eslint-config\node_modules\@typescript-eslint\eslint-plugin\dist\rules\no-unused-vars.js:301:33)
    at ruleErrorHandler (D:\JetBrains\Projects\1\my-vue-app\node_modules\eslint\lib\linter\linter.js:1115:48)
    at D:\JetBrains\Projects\1\my-vue-app\node_modules\eslint\lib\linter\safe-emitter.js:45:58
    at Array.forEach (<anonymous>)
    at Object.emit (D:\JetBrains\Projects\1\my-vue-app\node_modules\eslint\lib\linter\safe-emitter.js:45:38)
    at NodeEventGenerator.applySelector (D:\JetBrains\Projects\1\my-vue-app\node_modules\eslint\lib\linter\node-event-generator.js:297:26)
    at NodeEventGenerator.applySelectors (D:\JetBrains\Projects\1\my-vue-app\node_modules\eslint\lib\linter\node-event-generator.js:326:22)
    at NodeEventGenerator.leaveNode (D:\JetBrains\Projects\1\my-vue-app\node_modules\eslint\lib\linter\node-event-generator.js:349:14)

Reproduction

https://stackblitz.com/edit/vitejs-vite-g2jfea?file=src%2FApp.vue&view=editor

System Info

System:
    OS: Windows 10 10.0.19045
    CPU: (8) x64 12th Gen Intel(R) Core(TM) i3-12100
    Memory: 5.31 GB / 15.59 GB
  Binaries:
    Node: 20.12.2 - D:\nvm\nodejs\node.EXE
    npm: 10.5.0 - D:\nvm\nodejs\npm.CMD
  Browsers:
    Edge: Chromium (124.0.2478.51)
    Internet Explorer: 11.0.19041.3636

Used Package Manager

npm

Validations

  • Follow our Code of Conduct
  • Read the Contributing Guide.
  • Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
  • Check that this is a concrete bug. For Q&A, please open a GitHub Discussion instead.
  • The provided reproduction is a minimal reproducible of the bug.
@Bernankez
Copy link
Contributor

Seems a bug with eslint-plugin-unused-imports and typescript-eslint. Tracking sweepline/eslint-plugin-unused-imports#77 typescript-eslint/typescript-eslint#8640

@gitsheny
Copy link
Author

Seems a bug with eslint-plugin-unused-imports and typescript-eslint. Tracking sweepline/eslint-plugin-unused-imports#77 typescript-eslint/typescript-eslint#8640

我的代码里没有用到ts,而且我在配置项中设置了typescript: false也没效果。
咋办😢

@lautr
Copy link

lautr commented Apr 30, 2024

having the same issue, i was able to avoid the problem - or at least turn off the error - with a mix of ignore & rules - needed the ignore for my d.ts file because even with the rule off it keept triggering.

// eslint.config.js
import antfu from '@antfu/eslint-config'

export default antfu({
  ignores: [
    'dist',
    'node_modules',
    '.output',
    '.nuxt',
    'storybook-static',
    './packages/services/types/repository.d.ts',
  ],
  /* @see https://github.com/sweepline/eslint-plugin-unused-imports/issues/77 */
  rules: {
    'unused-imports/no-unused-imports': 'off',
  },
})

@Bernankez
Copy link
Contributor

Seems a bug with eslint-plugin-unused-imports and typescript-eslint. Tracking sweepline/eslint-plugin-unused-imports#77 typescript-eslint/typescript-eslint#8640

我的代码里没有用到ts,而且我在配置项中设置了typescript: false也没效果。 咋办😢

image
可以暂时patch一下@antfu/eslint-config@2.16.0,将package.json文件中的dependencies@typescript-eslint/eslint-plugin@typescript-eslint/parse这两个依赖的版本固定在7.7.x

@antfu
Copy link
Owner

antfu commented Apr 30, 2024

v2.16.1 temporarily locked ts-eslint to ~7.7 until either side resolves the issue.

@antfu antfu added the upstream label Apr 30, 2024
@antfu antfu closed this as completed May 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants