Skip to content

Commit de345cf

Browse files
committed
docs: allow ignoreReadme: true on individual tests to suppress from README (e.g., if just for coverage)
1 parent 565fdbd commit de345cf

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

src/bin/generateReadme.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ import Gitdown from 'gitdown';
77
import glob from 'glob';
88
import _ from 'lodash';
99

10+
const removeReadmeIgnores = ({ignoreReadme}) => {
11+
return !ignoreReadme;
12+
};
13+
1014
const trimCode = (code) => {
1115
let lines = code.replace(/^\n/u, '').trimEnd().split('\n');
1216

@@ -59,8 +63,8 @@ const getAssertions = () => {
5963
const codes = require(filePath);
6064

6165
return {
62-
invalid: _.map(codes.invalid, formatCodeSnippet),
63-
valid: _.map(codes.valid, formatCodeSnippet),
66+
invalid: codes.invalid.filter(removeReadmeIgnores).map(formatCodeSnippet),
67+
valid: codes.valid.filter(removeReadmeIgnores).map(formatCodeSnippet),
6468
};
6569
});
6670

test/rules/index.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,12 +74,14 @@ const ruleTester = new RuleTester();
7474
}
7575

7676
assertions.invalid = assertions.invalid.map((assertion) => {
77+
Reflect.deleteProperty(assertion, 'ignoreReadme');
7778
assertion.parserOptions = _.defaultsDeep(assertion.parserOptions, parserOptions);
7879

7980
return assertion;
8081
});
8182

8283
assertions.valid = assertions.valid.map((assertion) => {
84+
Reflect.deleteProperty(assertion, 'ignoreReadme');
8385
if (assertion.errors) {
8486
throw new Error(`Valid assertions for rule ${ruleName} should not have an \`errors\` array.`);
8587
}

0 commit comments

Comments
 (0)