Comments (10)
@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.
Please provide a minimal runnable reproduction.
from eslint-mdx.
Here you go: https://github.com/LeBenLeBen/eslint-mdx-repro-279
npm install
npm run validate
from eslint-mdx.
@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.
@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.
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.
@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.
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.
@LeBenLeBen Please try v1.9.1
from eslint-mdx.
Perfect, it works now. Thank you for looking into this so quickly π―
from eslint-mdx.
Related Issues (20)
- Parsing error: Expected value to be truthy HOT 4
- How can you type check React props with this plugin? HOT 4
- Please document how to make the linter fixable HOT 3
- Does not check nested code blocks (only lints top-level code blocks) HOT 6
- Research Spike: ESLint 9 compatibility HOT 13
- Incompatible w/ MDX v3? HOT 2
- There are serious issues when used with the `react/self-closing-comp` / `react/jsx-sort-props` rules. HOT 6
- `prettier/prettier` reports, but cannot be fixed automatically
- feat: use `worker.mts` for pure ESM
- feat: respect `.remarkignore`?
- Add more mdast specified nodes into estree AST
- on npm eslint-plugin-mdx v2.3.2 is tagged as latest while v3.1.3 should be HOT 2
- TypeError: Cannot use 'in' operator to search for 'start' in undefined
- maintenance: enable `strictNullChecks` option
- meta: how can we support `eslint-define-config` better? HOT 6
- mdx/code-blocks doesn't respect eslint-disable from outside of the block HOT 3
- bump up eslint-plugin-markdown to support eslint V9 HOT 2
- react/self-closing-comp rule is applied to HTML tags whose contents are markdown
- `no-unused-expressions` reported on `{' '}` HOT 2
- Report error on component names not imported or provided HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from eslint-mdx.