Skip to content

ESLint: Cannot read property 'references' of null Occurred while linting #1690

Closed
vuejs/vue-eslint-parser
#132
@chengweiou

Description

@chengweiou

Checklist

  • [ x] I have tried restarting my IDE and the issue persists.
  • [x ] I have read the FAQ and my problem is not listed.

Tell us about your environment

  • ESLint version: ^8.1.0
  • eslint-plugin-vue version: ^8.0.1
  • Node version: v16.4.0
  • Operating System: mac big sur 11.6

Please show your full configuration:

module.exports = {
  root: true,
  env: {
    browser: true,
    es2021: true,
    node: true,
  },
  extends: [
    "plugin:vue/vue3-recommended",
    "prettier",
  ],
  settings: { // @路径引入的文件也需要校验
    'import/resolver': {
      alias: {
        map: [
          ['@', './src'],
        ],
        extensions: ['.ts', '.js', '.jsx', '.json', '.vue'],
      },
    },
  },
  rules: {
    // 'no-console': process.env.NODE_ENV === 'production' ? 'error' : 'off',
    'no-debugger': process.env.NODE_ENV === 'production' ? 'error' : 'off',
    // allow async-await
    'generator-star-spacing': 'off',
    'space-before-function-paren': ['error', 'never'],
    'comma-dangle': ['error', 'always-multiline'],
    'semi': ['error', 'never'],
    'no-unused-vars': 'warn',
    // allow debugger during development
    'no-tabs': 0,
    'no-trailing-spaces': 'error',
    'no-multiple-empty-lines': ['error', { 'max': 2, 'maxEOF': 0, 'maxBOF': 0 }],
    "indent": ["error", 2, { "SwitchCase": 1 }],
    "vue/first-attribute-linebreak": ["error", {
      "singleline": "ignore",
      "multiline": "ignore",
    }],
  },
  parserOptions: {
    ecmaVersion: '2021',
  },
  // overrides: [
  //   {
  //     files: [
  //       '**/__tests__/*.{j,t}s?(x)',
  //     ],
  //     env: {
  //       mocha: true,
  //     },
  //   },
  // ],
}

What did you do?

<template>
  <div class="f-c" style="height: 100%;">
  </div>
</template>
<script setup>
import { ref, computed } from 'vue' // each time uncomment error will print. anything from 'vue'
import { useStore } from 'vuex' // others like this is ok
</script>

<script>
export default {
  name: 'App',
  components: {
  },
}
</script>

What did you expect to happen?
no error

What actually happened?

Screen Shot 2021-10-29 at 5 29 50 PM

[Error - 5:15:58 PM] ESLint stack trace:
[Error - 5:15:58 PM] TypeError: Cannot read property 'references' of null
Occurred while linting /path-to-proj/src/App.vue:10
Rule: "vue/no-async-in-computed-properties"
at ReferenceTracker._iterateVariableReferences (/path-to-proj/node_modules/eslint-utils/index.js:1650:46)
at _iterateVariableReferences.next ()
at ReferenceTracker._iterateImportReferences (/path-to-proj/node_modules/eslint-utils/index.js:1823:25)
at _iterateImportReferences.next ()
at ReferenceTracker.iterateEsmReferences (/path-to-proj/node_modules/eslint-utils/index.js:1619:25)
at iterateEsmReferences.next ()
at Program (/path-to-proj/node_modules/eslint-plugin-vue/lib/rules/no-async-in-computed-properties.js:245:29)
at ruleErrorHandler (/path-to-proj/node_modules/eslint/lib/linter/linter.js:966:28)
at /path-to-proj/node_modules/eslint/lib/linter/safe-emitter.js:45:58
at Array.forEach ()

Repository to reproduce this issue

the code in browser is working as expect. just only eslint pop a error

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions