Skip to content

Commit 65028b9

Browse files
authored
fix: allow comments to contain -- (#348)
1 parent 2a5792f commit 65028b9

File tree

4 files changed

+16
-1
lines changed

4 files changed

+16
-1
lines changed

packages/eslint-mdx/src/regexp.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ export const openTag = '<[A-Za-z]*[A-Za-z0-9\\.\\-]*' + attribute + '*\\s*>'
2323
export const closeTag = '<\\s*\\/[A-Za-z]*[A-Za-z0-9\\.\\-]*\\s*>'
2424
export const selfClosingTag =
2525
'<[A-Za-z]*[A-Za-z0-9\\.\\-]*' + attribute + '*\\s*\\/?>'
26-
export const comment = '<!---->|<!--(?:-?[^>-])(?:-?[^-])*-->'
26+
export const comment = '<!--(?:[^-]|-(?:[^-]|-+[^->]))*-*-->'
2727
export const commentOpen = '(<!---*)'
2828
export const commentClose = '(-*-->)'
2929
export const commentContent = `${commentOpen}([\\s\\S]*?)${commentClose}`

test/__snapshots__/fixtures.test.ts.snap

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,19 @@ Array [
169169
]
170170
`;
171171

172+
exports[`fixtures should match all snapshots: comments.mdx 1`] = `
173+
Array [
174+
Object {
175+
"column": 2,
176+
"line": 1,
177+
"message": "Unused eslint-disable directive (no problems were reported from 'no-console').",
178+
"nodeType": null,
179+
"ruleId": null,
180+
"severity": 2,
181+
},
182+
]
183+
`;
184+
172185
exports[`fixtures should match all snapshots: details.mdx 1`] = `
173186
Array [
174187
Object {

test/fixtures.test.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ const getCli = (lintCodeBlocks = false) =>
3535
]
3636
: [],
3737
},
38+
reportUnusedDisableDirectives: 'error',
3839
})
3940

4041
describe('fixtures', () => {

test/fixtures/comments.mdx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
<!-- eslint-disable-next-line no-console -- Here's a description about why this configuration is necessary. -->

0 commit comments

Comments
 (0)