From 6c2d9dd8205e909d092cad3cfdfcbb559db92bd4 Mon Sep 17 00:00:00 2001 From: Jack Bates Date: Fri, 10 Sep 2021 14:02:03 -0700 Subject: [PATCH 1/2] fix: allow comments to contain -- --- packages/eslint-mdx/src/regexp.ts | 2 +- test/__snapshots__/fixtures.test.ts.snap | 2 ++ test/fixtures/comments.mdx | 1 + 3 files changed, 4 insertions(+), 1 deletion(-) create mode 100644 test/fixtures/comments.mdx diff --git a/packages/eslint-mdx/src/regexp.ts b/packages/eslint-mdx/src/regexp.ts index a0e19788..ecf4c543 100644 --- a/packages/eslint-mdx/src/regexp.ts +++ b/packages/eslint-mdx/src/regexp.ts @@ -23,7 +23,7 @@ export const openTag = '<[A-Za-z]*[A-Za-z0-9\\.\\-]*' + attribute + '*\\s*>' export const closeTag = '<\\s*\\/[A-Za-z]*[A-Za-z0-9\\.\\-]*\\s*>' export const selfClosingTag = '<[A-Za-z]*[A-Za-z0-9\\.\\-]*' + attribute + '*\\s*\\/?>' -export const comment = '|' +export const comment = '' export const commentOpen = '()' export const commentContent = `${commentOpen}([\\s\\S]*?)${commentClose}` diff --git a/test/__snapshots__/fixtures.test.ts.snap b/test/__snapshots__/fixtures.test.ts.snap index 70aaea40..cee8988b 100644 --- a/test/__snapshots__/fixtures.test.ts.snap +++ b/test/__snapshots__/fixtures.test.ts.snap @@ -169,6 +169,8 @@ Array [ ] `; +exports[`fixtures should match all snapshots: comments.mdx 1`] = `Array []`; + exports[`fixtures should match all snapshots: details.mdx 1`] = ` Array [ Object { diff --git a/test/fixtures/comments.mdx b/test/fixtures/comments.mdx new file mode 100644 index 00000000..f4473fdd --- /dev/null +++ b/test/fixtures/comments.mdx @@ -0,0 +1 @@ + From bdf53c17d409ba1ad1e5186ec32ccdd7527ae45a Mon Sep 17 00:00:00 2001 From: Jack Bates Date: Tue, 14 Sep 2021 17:02:23 -0700 Subject: [PATCH 2/2] test: add reportUnusedDisableDirectives: 'error' --- test/__snapshots__/fixtures.test.ts.snap | 13 ++++++++++++- test/fixtures.test.ts | 1 + 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/test/__snapshots__/fixtures.test.ts.snap b/test/__snapshots__/fixtures.test.ts.snap index cee8988b..62f66709 100644 --- a/test/__snapshots__/fixtures.test.ts.snap +++ b/test/__snapshots__/fixtures.test.ts.snap @@ -169,7 +169,18 @@ Array [ ] `; -exports[`fixtures should match all snapshots: comments.mdx 1`] = `Array []`; +exports[`fixtures should match all snapshots: comments.mdx 1`] = ` +Array [ + Object { + "column": 2, + "line": 1, + "message": "Unused eslint-disable directive (no problems were reported from 'no-console').", + "nodeType": null, + "ruleId": null, + "severity": 2, + }, +] +`; exports[`fixtures should match all snapshots: details.mdx 1`] = ` Array [ diff --git a/test/fixtures.test.ts b/test/fixtures.test.ts index d8d803aa..1b00edba 100644 --- a/test/fixtures.test.ts +++ b/test/fixtures.test.ts @@ -35,6 +35,7 @@ const getCli = (lintCodeBlocks = false) => ] : [], }, + reportUnusedDisableDirectives: 'error', }) describe('fixtures', () => {