Skip to content

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

Closed
@iamrgroot

Description

@iamrgroot

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>

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions