-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Moved process markdownlint results to a dedicated file 🚓
- Loading branch information
Showing
7 changed files
with
202 additions
and
233 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"extends": "./node_modules/lint-pilot/markdownlint.json" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
139 changes: 139 additions & 0 deletions
139
src/linters/markdownlint/__tests__/processResults.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,139 @@ | ||
import { expectedResultThemes, markdownlintError } from '@Jest/testData' | ||
|
||
import { type LintResults } from '../markdownlintAsync' | ||
import processResults from '../processResults' | ||
|
||
describe('processResults', () => { | ||
|
||
it('returns results and a summary when there are no lint results', () => { | ||
const report = processResults({}) | ||
|
||
expect(report).toStrictEqual({ | ||
results: {}, | ||
summary: { | ||
deprecatedRules: [], | ||
errorCount: 0, | ||
fileCount: 0, | ||
fixableErrorCount: 0, | ||
fixableWarningCount: 0, | ||
linter: 'MarkdownLint', | ||
warningCount: 0, | ||
}, | ||
}) | ||
}) | ||
|
||
it('returns results and a summary when there are no errors', () => { | ||
const lintResults: LintResults = { | ||
'README.md': [], | ||
} | ||
|
||
const report = processResults(lintResults) | ||
|
||
expect(report).toStrictEqual({ | ||
results: {}, | ||
summary: { | ||
deprecatedRules: [], | ||
errorCount: 0, | ||
fileCount: 1, | ||
fixableErrorCount: 0, | ||
fixableWarningCount: 0, | ||
linter: 'MarkdownLint', | ||
warningCount: 0, | ||
}, | ||
}) | ||
}) | ||
|
||
it('returns results sorted by lineNumber and a summary when there are errors', () => { | ||
const lintResults: LintResults = { | ||
// No errors | ||
'CHANGELOG.md': [], | ||
'CONTRIBUTING.md': [markdownlintError], | ||
// 5 errors | ||
'README.md': [{ | ||
...markdownlintError, | ||
lineNumber: 7, | ||
errorRange: [], | ||
ruleDescription: 'no-error-range', | ||
}, { | ||
...markdownlintError, | ||
errorDetail: '', | ||
fixInfo: undefined, | ||
lineNumber: 9, | ||
ruleDescription: 'no-error-detail', | ||
}, { | ||
...markdownlintError, | ||
fixInfo: undefined, | ||
lineNumber: 13, | ||
ruleNames: ['MD000', 'test-rule-b'], | ||
ruleDescription: 'sorted-by-name', | ||
}, { | ||
...markdownlintError, | ||
fixInfo: undefined, | ||
lineNumber: 13, | ||
ruleNames: ['MD000', 'test-rule-a'], | ||
ruleDescription: 'sorted-by-name', | ||
}, { | ||
...markdownlintError, | ||
fixInfo: undefined, | ||
errorDetail: '', | ||
lineNumber: 3, | ||
ruleDescription: 'sort-by-line-number', | ||
}], | ||
} | ||
|
||
const report = processResults(lintResults) | ||
|
||
expect(report).toStrictEqual({ | ||
results: { | ||
'CONTRIBUTING.md': [{ | ||
...expectedResultThemes, | ||
message: 'test-rule-description: test-error-detail', | ||
position: '1:1', | ||
rule: 'test-rule-name', | ||
severity: 'X', | ||
}], | ||
'README.md': [{ | ||
...expectedResultThemes, | ||
message: 'sort-by-line-number', | ||
position: '3:1', | ||
rule: 'test-rule-name', | ||
severity: 'X', | ||
}, { | ||
...expectedResultThemes, | ||
message: 'no-error-range: test-error-detail', | ||
position: '7', | ||
rule: 'test-rule-name', | ||
severity: 'X', | ||
}, { | ||
...expectedResultThemes, | ||
message: 'no-error-detail', | ||
position: '9:1', | ||
rule: 'test-rule-name', | ||
severity: 'X', | ||
}, { | ||
...expectedResultThemes, | ||
message: 'sorted-by-name: test-error-detail', | ||
position: '13:1', | ||
rule: 'test-rule-a', | ||
severity: 'X', | ||
}, { | ||
...expectedResultThemes, | ||
message: 'sorted-by-name: test-error-detail', | ||
position: '13:1', | ||
rule: 'test-rule-b', | ||
severity: 'X', | ||
}], | ||
}, | ||
summary: { | ||
deprecatedRules: [], | ||
errorCount: 6, | ||
fileCount: 3, | ||
fixableErrorCount: 2, | ||
fixableWarningCount: 0, | ||
linter: 'MarkdownLint', | ||
warningCount: 0, | ||
}, | ||
}) | ||
}) | ||
|
||
}) |
Oops, something went wrong.