Skip to content

Commit af7736c

Browse files
authored
fix: no-reversed-media-syntax add missing offset for code spans (#460)
* fix: no-reversed-media-syntax add missing offset of the paragraph for checking the bounds of code spans * fix: update test to actually test offset fix
1 parent c5398ca commit af7736c

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

src/rules/no-reversed-media-syntax.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,12 @@ export default {
108108
const matchIndex = match.index;
109109
const matchLength = reversedSyntax.length;
110110

111-
if (isInCodeSpan(matchIndex, codeSpans)) {
111+
if (
112+
isInCodeSpan(
113+
matchIndex + node.position.start.offset,
114+
codeSpans,
115+
)
116+
) {
112117
continue;
113118
}
114119

tests/rules/no-reversed-media-syntax.test.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,11 @@ ruleTester.run("no-reversed-media-syntax", rule, {
3939
\`\`\`
4040
`,
4141
"`myobj.getFiles(test)[0]`",
42+
dedent`
43+
Some long text about foo
44+
# Split,
45+
\`myobj.getFiles(test)[0]\`
46+
`,
4247
"(reversed)[link]",
4348
"a ) a ( a )[a]~",
4449
"a<pre>&rpar; a &lpar; a &rpar;[a]~</pre>",

0 commit comments

Comments
 (0)