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

Version ^9 throws error using 'no-obj-calls' rule when JSON is used in template #151

Closed
iamrgroot opened this issue May 17, 2022 · 1 comment · Fixed by #152
Closed

Version ^9 throws error using 'no-obj-calls' rule when JSON is used in template #151

iamrgroot opened this issue May 17, 2022 · 1 comment · Fixed by #152

Comments

@iamrgroot
Copy link

See reproduction at: https://github.com/IAmRGroot/reproduction-vue. I'm using Vue 2 with Composition API + Script Setup.

Steps:

  • Add JSON usage to a template:
<template>
    <div>
        {{ JSON.stringify({ test: 'test'}) }}
    </div>
</template>
  • Run eslint with 'no-obj-calls' rule npm run lint

Error:

Oops! Something went wrong! :(

ESLint: 8.15.0

TypeError: Cannot read properties of undefined (reading 'parent')
Occurred while linting /app/src/App.vue:9
Rule: "no-obj-calls"
    at isPassThrough (/app/node_modules/eslint-utils/index.js:1461:25)
    at ReferenceTracker._iteratePropertyReferences (/app/node_modules/eslint-utils/index.js:1676:16)
    at _iteratePropertyReferences.next (<anonymous>)
    at ReferenceTracker._iterateVariableReferences (/app/node_modules/eslint-utils/index.js:1659:29)
    at _iterateVariableReferences.next (<anonymous>)
    at ReferenceTracker.iterateGlobalReferences (/app/node_modules/eslint-utils/index.js:1517:25)
    at iterateGlobalReferences.next (<anonymous>)
    at Program (/app/node_modules/eslint/lib/rules/no-obj-calls.js:74:41)
    at ruleErrorHandler (/app/node_modules/eslint/lib/linter/linter.js:1114:28)
    at /app/node_modules/eslint/lib/linter/safe-emitter.js:45:58

Reverting to vue-eslint-parser@^8 or moving the JSON call to the script prevents the error:

<template>
    <div>
        {{ json }}
    </div>
</template>

<script lang="ts" setup>
import { computed } from '@vue/composition-api';

const json = computed(() => JSON.stringify({ test: 'test'}))
</script>
@ota-meshi
Copy link
Member

Thank you for posting this issue.
I fixed and released it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants