Skip to content

Commit

Permalink
fix: incompatible with react/jsx-sort-props rule (#490)
Browse files Browse the repository at this point in the history
close #488, related #425
  • Loading branch information
JounQin authored Dec 12, 2023
1 parent 311bdfa commit a3a86d8
Show file tree
Hide file tree
Showing 7 changed files with 2,626 additions and 570 deletions.
5 changes: 5 additions & 0 deletions .changeset/ninety-bugs-dance.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"eslint-mdx": patch
---

fix: incorrect `JSXAttribute` node position info - close #488, related #425
1 change: 1 addition & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ module.exports = {
files: '*.{md,mdx}',
rules: {
'react/jsx-curly-brace-presence': 'error',
'react/jsx-sort-props': 'error',
'react/self-closing-comp': 'error',
'react/no-unescaped-entities': 'warn',
},
Expand Down
9 changes: 7 additions & 2 deletions packages/eslint-mdx/src/worker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -633,7 +633,7 @@ runAsWorker(
}

return {
...attrNamePos,
...normalizeNode(attrStart, lastAttrOffset + 1),
type: 'JSXAttribute',
name: {
...attrNamePos,
Expand Down Expand Up @@ -713,11 +713,16 @@ runAsWorker(

const expression = handleNode(node)

// keep for debugging
// if (+1 === 1) {
// throw new SyntaxError(JSON.stringify({ node, expression }, null, 2))
// }

if (expression) {
body.push({
...normalizePosition(node.position),
type: 'ExpressionStatement',
expression: handleNode(node) as Expression,
expression: expression as Expression,
})
}

Expand Down
Loading

0 comments on commit a3a86d8

Please sign in to comment.