Giter VIP home page Giter VIP logo

Comments (10)

JounQin avatar JounQin commented on July 26, 2024 1

@LeBenLeBen Temporary workaround:

<!-- prettier-ignore -->
- <div kind="docs-packages-vuetify-preset" story="page">
    Vuetify preset
</div>
  : some extra text describing the preset

Sorry, I can't fix it easily due to remark-mdx itself. Let's wait for @wooorm's response.

from eslint-mdx.

JounQin avatar JounQin commented on July 26, 2024

Please provide a minimal runnable reproduction.

from eslint-mdx.

LeBenLeBen avatar LeBenLeBen commented on July 26, 2024

Here you go: https://github.com/LeBenLeBen/eslint-mdx-repro-279

npm install
npm run validate

from eslint-mdx.

JounQin avatar JounQin commented on July 26, 2024

@wooorm I tried to parse the following:

- <div kind="docs-packages-vuetify-preset" story="page">
    Vuetify preset
  </div>
  : some extra text describing the preset

And logged console.log(jsxNodes[0], this.combineLeftJsxNodes(jsxNodes)) at https://github.com/mdx-js/eslint-mdx/blob/master/packages/eslint-mdx/src/traverse.ts#L117

And the log is following:

{
  type: 'jsx',
  data: undefined,
  value: '<div kind="docs-packages-vuetify-preset" story="page">\n' +
    '  Vuetify preset\n' +
    '</div>',
  position: {
    start: { line: 1, column: 0, offset: 2 },
    end: { line: 3, column: 3, offset: 80 }
  }
}

{
  type: 'jsx',
  data: undefined,
  value: '<div kind="docs-packages-vuetify-preset" story="page">\n' +
    '    Vuetify preset\n' +
    '  </',
  position: {
    start: { line: 1, column: 0, offset: 2 },
    end: { line: 3, column: 3, offset: 80 }
  }
}

/Users/JounQin/Workspaces/GitHub/eslint-mdx/test/fixtures/jsx-text.mdx
  3:4  error  Parsing error: /Users/JounQin/Workspaces/GitHub/eslint-mdx/test/fixtures/jsx-text.mdx: Unexpected token (3:4)

  1 | <$><div kind="docs-packages-vuetify-preset" story="page">
  2 |     Vuetify preset
> 3 |   </</$>
    |     ^

βœ– 1 problem (1 error, 0 warnings)

So it seems to be an issue of remark-mdx which produces incorrect offset.

from eslint-mdx.

JounQin avatar JounQin commented on July 26, 2024

@wooorm I have to do something like following, I don't know if it is as expected:

combineLeftJsxNodes(jsxNodes: Node[], parent?: Parent): Node {
  const start = jsxNodes[0].position.start
  const end = { ...last(jsxNodes).position.end }
  // fix #279
  if (parent.type === 'listItem') {
    end.offset += parent.position.indent.reduce(
      (acc, indent, index) => acc + (index ? indent + 1 : 0),
      0,
    )
  }
  return {
    type: 'jsx',
    data: jsxNodes[0].data,
    value: this.code.slice(start.offset, end.offset),
    position: {
      start,
      end,
    },
  }
}

from eslint-mdx.

wooorm avatar wooorm commented on July 26, 2024

Parsing it at least works on main, and maybe on the last v2 beta.

@JounQin posiiton.indent went away in the last remark btw.
Might it be time to investigate the new AST that’s on main already?

from eslint-mdx.

JounQin avatar JounQin commented on July 26, 2024

@wooorm I'm fine to start working on next version, but I'd like to fix this error on current stable version too. I want to confirm if my fix will always work, or, can you patch a fix on remark-mdx@1 for the incorrect position info.

from eslint-mdx.

wooorm avatar wooorm commented on July 26, 2024

I do not know if your fix will always work, maybe?
And I'm personally not interested in patching v1. I rewrote the parsing in april and in november, solving tons of issues. I'm not interested in again fixing things I already fixed

from eslint-mdx.

JounQin avatar JounQin commented on July 26, 2024

@LeBenLeBen Please try v1.9.1

from eslint-mdx.

LeBenLeBen avatar LeBenLeBen commented on July 26, 2024

Perfect, it works now. Thank you for looking into this so quickly πŸ’―

from eslint-mdx.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.