Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Account for ! and ? and add tests #114

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@
"release-it": "^17.0.0",
"sentences-per-line": "^0.2.1",
"should-semantic-release": "^0.2.1",
"tsup": "^8.0.0",
"tsup": "^8.0.1",
"typescript": "^5.2.2",
"vitest": "^1.0.0",
"yaml-eslint-parser": "^1.2.2"
Expand Down
2 changes: 1 addition & 1 deletion pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

72 changes: 72 additions & 0 deletions src/sentences-per-line.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,78 @@ Abc. Def.
"Abc. Def.",
6,
],
[
`
\`\`\`plaintext
Abc! Def!
\`\`\`
`,
undefined,
],
[
`
\`\`\`plaintext
Abc? Def?
\`\`\`
`,
undefined,
],
[
`
\`\`\`plaintext
Abc? Def!
\`\`\`
`,
undefined,
],
[
`
\`\`\`plaintext
Abc! Def?
\`\`\`
`,
undefined,
],
[
`
\`\`\`plaintext
Abc! Def.
\`\`\`
`,
undefined,
],
[
`
\`\`\`plaintext
Abc? Def.
\`\`\`
`,
undefined,
],
[
`
\`\`\`plaintext
Abc. Def!
\`\`\`
`,
undefined,
],
[
`
\`\`\`plaintext
Abc. Def?
\`\`\`
`,
undefined,
],
[
`
\`\`\`plaintext
Abc. Def.
\`\`\`
`,
undefined,
],
])("%s", (input, errorContext, lineNumber = 1) => {
const actual = markdownlint.sync({
config: {
Expand Down
10 changes: 6 additions & 4 deletions src/sentences-per-line.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,10 +86,12 @@
}

if (
line[i] === "." &&
line[i + 1] === " " &&
isCapitalizedAlphabetCharacter(line[i + 2]) &&
!isAfterIgnoredWord(line, i)
line[i] === "." ||
line[i] === "!" ||
(line[i] === "?" &&
line[i + 1] === " " &&
isCapitalizedAlphabetCharacter(line[i + 2]) &&
!isAfterIgnoredWord(line, i))

Check warning on line 94 in src/sentences-per-line.ts

View check run for this annotation

Codecov / codecov/patch

src/sentences-per-line.ts#L94

Added line #L94 was not covered by tests
) {
helpers.addError(
onError,
Expand Down
Loading