diff --git a/packages/remark-lint-list-item-style/docs/README.md b/packages/remark-lint-list-item-style/docs/README.md index b5a9885..519f20d 100644 --- a/packages/remark-lint-list-item-style/docs/README.md +++ b/packages/remark-lint-list-item-style/docs/README.md @@ -32,10 +32,11 @@ Options type for the remark-lint-list-item-style plugin. | `checkFirstWord?` | typeof [`optionsCheckFirstWord`](README.md#optionscheckfirstword)[`number`] | Checks that the first word of each stringified list item paragraph begins with a non-lowercase character (`"capitalize"`) or a non-uppercase character (`"lowercase"`). List items beginning with a link, image, or inline code block are ignored. **`Default`** "capitalize" | | `checkListSpread?` | typeof [`optionsCheckListSpread`](README.md#optionschecklistspread)[`number`] | Determines how `checkPunctuation` is applied to list items with spread children. Has no effect when `checkPunctuation` is `false`. **`Default`** "each" | | `checkPunctuation?` | ``false`` \| (`string` \| `RegExp`)[] | Checks that the final character of each stringified list item matches at least one of the given values. To match all unicode punctuation characters, you could provide `["\p{P}"]` instead of the default, but this will match characters like `)` and `]`. Alternatively, to prevent punctuation, you could provide `["\P{P}"]`. Lines that consist solely of an image are ignored. **`Default`** ["(\\.\|\\?\|;\|,\|!)"] | +| `ignoredFirstWords?` | (`string` \| `RegExp`)[] | Words that would normally be checked with respect to the `checkFirstWord` option will be ignored if they match at least one of the given values. Use this option to prevent false positives (e.g. "iOS", "eBay"). **`Default`** [] | #### Defined in -[packages/remark-lint-list-item-style/src/index.ts:29](https://github.com/Xunnamius/unified-utils/blob/dcdf185/packages/remark-lint-list-item-style/src/index.ts#L29) +[packages/remark-lint-list-item-style/src/index.ts:29](https://github.com/Xunnamius/unified-utils/blob/436108b/packages/remark-lint-list-item-style/src/index.ts#L29) ## Variables @@ -47,7 +48,7 @@ Valid values for the Options.checkFirstWord property. #### Defined in -[packages/remark-lint-list-item-style/src/index.ts:14](https://github.com/Xunnamius/unified-utils/blob/dcdf185/packages/remark-lint-list-item-style/src/index.ts#L14) +[packages/remark-lint-list-item-style/src/index.ts:14](https://github.com/Xunnamius/unified-utils/blob/436108b/packages/remark-lint-list-item-style/src/index.ts#L14) ___ @@ -59,7 +60,7 @@ Valid values for the Options.checkListSpread property. #### Defined in -[packages/remark-lint-list-item-style/src/index.ts:19](https://github.com/Xunnamius/unified-utils/blob/dcdf185/packages/remark-lint-list-item-style/src/index.ts#L19) +[packages/remark-lint-list-item-style/src/index.ts:19](https://github.com/Xunnamius/unified-utils/blob/436108b/packages/remark-lint-list-item-style/src/index.ts#L19) ## Functions diff --git a/packages/remark-lint-list-item-style/test/fixtures/ok-ignored-first-words.md b/packages/remark-lint-list-item-style/test/fixtures/ok-ignored-first-words.md new file mode 100644 index 0000000..dd41d9c --- /dev/null +++ b/packages/remark-lint-list-item-style/test/fixtures/ok-ignored-first-words.md @@ -0,0 +1,4 @@ +## 1.0 + +- iOS SDK first version +- Android SDK first version diff --git a/packages/remark-lint-list-item-style/test/unit-index.test.ts b/packages/remark-lint-list-item-style/test/unit-index.test.ts index 18ef23c..18a100f 100644 --- a/packages/remark-lint-list-item-style/test/unit-index.test.ts +++ b/packages/remark-lint-list-item-style/test/unit-index.test.ts @@ -120,17 +120,37 @@ describe('::default', () => { expect.hasAssertions(); const results = await runLinter( - remark().use(remarkLintListItemStyle, { ignoredFirstWords: [/^n/, '^bar', 'qux'] }) + remark().use(remarkLintListItemStyle, { + checkFirstWord: 'capitalize', + checkPunctuation: false, + ignoredFirstWords: [/^n/, '^bar', 'qux'] + }) ); expect(results.okFirstWord.messages).toStrictEqual([]); expect(results.notOkFirstWord.messages).toStrictEqual([]); + expect(results.okIgnoredFirstWords.messages).toStrictEqual([ + expect.objectContaining({ + message: 'Inconsistent list item capitalization: "i" should be "I"' + }) + ]); + expect(results.notOkFirstWordSpread.messages).toStrictEqual([ expect.objectContaining({ message: 'Inconsistent list item capitalization: "q" should be "Q"' }) ]); + + const results2 = await runLinter( + remark().use(remarkLintListItemStyle, { + checkFirstWord: 'capitalize', + checkPunctuation: false, + ignoredFirstWords: ['iOS'] + }) + ); + + expect(results2.okIgnoredFirstWords.messages).toStrictEqual([]); }); it("warns when a list item's punctuation violates multi-element checkPunctuation configuration", async () => { @@ -287,6 +307,9 @@ async function runLinter(runner: Processor) { ); const okFirstWord = await runner.process(await getFixtureVFile('ok-first-word')); + const okIgnoredFirstWords = await runner.process( + await getFixtureVFile('ok-ignored-first-words') + ); const okPunctuation = await runner.process(await getFixtureVFile('ok-punctuation')); const okSpreadFirst = await runner.process(await getFixtureVFile('ok-spread-first')); const okSpreadFirstAndFinal = await runner.process( @@ -304,6 +327,7 @@ async function runLinter(runner: Processor) { notOkPunctuation, notOkSpreadEach, okFirstWord, + okIgnoredFirstWords, okPunctuation, okSpreadFirst, okSpreadFirstAndFinal,