Skip to content

Commit 2345263

Browse files
committed
Fix false positives for apostrophes in match-punctuation rule
Fixes #104
1 parent 651da09 commit 2345263

File tree

2 files changed

+29
-1
lines changed

2 files changed

+29
-1
lines changed

config.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,8 @@ const plugins = [
101101
// Disabled as it throws `file.warn is not a function`
102102
// require('remark-lint-no-empty-sections'),
103103

104-
matchPunctuation,
104+
// Configure to exclude single quotes to avoid false positives with apostrophes (e.g., don't, isn't)
105+
[matchPunctuation, ['""', '『』', '()', '《》', '「」', '【】']],
105106
[noRepeatPunctuation, '!!~~,,·??'], // Exclude dots to allow ellipsis (...)
106107

107108
// Custom plugins

test/rules/apostrophe.test.js

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import {describe, it} from 'node:test';
2+
import assert from 'node:assert/strict';
3+
import lint from '../../index.js';
4+
5+
describe('apostrophe handling', () => {
6+
it('should not flag apostrophes as unmatched quotes', async () => {
7+
const markdown = `# Awesome Test [![Awesome](https://awesome.re/badge-flat.svg)](https://awesome.re)
8+
9+
> Test list.
10+
11+
## Contents
12+
13+
- [Section](#section)
14+
15+
## Section
16+
17+
- [Example](https://example.com) - This doesn't trigger false positives.
18+
- [Another](https://example.com) - It isn't, can't, won't cause issues.
19+
`;
20+
21+
const [vFile] = await lint({filename: 'readme.md', contents: markdown});
22+
23+
const apostropheErrors = vFile.messages.filter(message => message.ruleId === 'match-punctuation' && message.message.includes('\''));
24+
25+
assert.equal(apostropheErrors.length, 0);
26+
});
27+
});

0 commit comments

Comments
 (0)