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

<textarea> content after }} causes invalid vue/no-parsing-error #260

Closed
4 tasks done
ws807 opened this issue Apr 3, 2025 · 0 comments · Fixed by #256
Closed
4 tasks done

<textarea> content after }} causes invalid vue/no-parsing-error #260

ws807 opened this issue Apr 3, 2025 · 0 comments · Fixed by #256

Comments

@ws807
Copy link
Contributor

ws807 commented Apr 3, 2025

Before You File a Bug Report Please Confirm You Have Done The Following...

  • I'm using eslint-plugin-vue.
  • I'm sure the problem is a parser problem. (If you are not sure, search for the issue in eslint-plugin-vue repo and open the issue in eslint-plugin-vue repo if there is no solution.
  • I have tried restarting my IDE and the issue persists.
  • I have updated to the latest version of the packages.

What version of ESLint are you using?

9.22.0

What version of eslint-plugin-vue and vue-eslint-parser are you using?

What did you do?

Configuration
import { defineConfig, globalIgnores } from 'eslint/config'
import globals from 'globals'
import js from '@eslint/js'
import pluginVue from 'eslint-plugin-vue'

export default defineConfig([
  {
    name: 'app/files-to-lint',
    files: ['**/*.{js,mjs,jsx,vue}'],
  },

  globalIgnores(['**/dist/**', '**/dist-ssr/**', '**/coverage/**']),

  {
    languageOptions: {
      globals: {
        ...globals.browser,
      },
    },
  },

  js.configs.recommended,
  ...pluginVue.configs['flat/essential'],
])
<template>
  {{ 123 }}
  <textarea> }} <div </textarea>
</template>

What did you expect to happen?

npm run lint should report no error.

What actually happened?

Following errors occurred when running 'npm run lint'

/home/wschoi/mustache-bug-report/src/App.vue
  3:22  error  Parsing error: unexpected-character-in-attribute-name  vue/no-parsing-error
  3:22  error  Attribute name < is not valid                          vue/valid-attribute-name
  3:24  error  Parsing error: unexpected-solidus-in-tag               vue/no-parsing-error

Link to Minimal Reproducible Example

https://github.com/ws807/mustache-bug-report

Additional comments

Because <textarea> is a RCDATA element, <div inside the element should not be parsed as a tag start. <div should be displayed verbatim.

Note that if you do one of the following, no parsing error occurs:

  • Remove {{ 123 }}
  • Remove }} before the <div

This problem occurs because after processing{{ 123 }}, vExpressionScriptState holding DATA is not cleared to null.
When encounting }} before the <div, the state is restored from the incorrect vExpressionScriptState and becomes DATA.
So, it results in parsing <div in the DATA state instead of RCDATA.

#256 solves this problem.

@ws807 ws807 changed the title <textarea> content after }} causes invalid vue/no-parsing-error <textarea> content after }} causes invalid vue/no-parsing-error Apr 3, 2025
@ota-meshi ota-meshi linked a pull request Apr 4, 2025 that will close this issue
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.

1 participant