Skip to content

Commit

Permalink
Replace nyc with c8
Browse files Browse the repository at this point in the history
  • Loading branch information
wooorm committed Aug 10, 2021
1 parent 5912962 commit e633c2f
Show file tree
Hide file tree
Showing 11 changed files with 34 additions and 39 deletions.
5 changes: 2 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
.DS_Store
*.log
coverage/
.nyc_output/
node_modules/
.DS_Store
*.log
package-lock.json
yarn.lock
12 changes: 3 additions & 9 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,10 @@
"Denis Augsburger <denis.augsburger@simpleen.io> (https://simpleen.io)"
],
"devDependencies": {
"c8": "^7.0.0",
"dox": "^0.9.0",
"lerna": "^3.0.0",
"mdast-zone": "^4.0.0",
"nyc": "^15.0.0",
"parse-author": "^2.0.0",
"prettier": "^2.0.0",
"remark": "^13.0.0",
Expand All @@ -58,16 +58,10 @@
"generate:presets": "node script/build-presets",
"generate:rules": "node script/build-rules",
"generate": "npm run generate:presets && npm run generate:rules",
"test-api": "node test",
"test-coverage": "nyc --reporter lcov tape test.js",
"test-api": "node --conditions development test.js",
"test-coverage": "c8 --check-coverage --branches 100 --functions 100 --lines 100 --statements 100 --reporter lcov npm run test-api",
"test": "npm run generate && npm run format && npm run test-coverage"
},
"nyc": {
"check-coverage": true,
"lines": 100,
"functions": 100,
"branches": 100
},
"prettier": {
"tabWidth": 2,
"useTabs": false,
Expand Down
10 changes: 5 additions & 5 deletions packages/remark-lint-checkbox-character-style/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -124,9 +124,9 @@ function checkboxCharacterStyle(tree, file, option) {

type = types[node.checked]

/* istanbul ignore next - a list item cannot be checked and empty, according
* to GFM, but theoretically it makes sense to get the end if that were
* possible. */
// A list item cannot be checked and empty, according to GFM, but
// theoretically it makes sense to get the end if that were possible.
/* c8 ignore next */
point = node.children.length === 0 ? end(node) : start(node.children[0])
// Move back to before `] `.
point.offset -= 2
Expand All @@ -137,8 +137,8 @@ function checkboxCharacterStyle(tree, file, option) {
contents.slice(point.offset - 2, point.offset + 1)
)

/* istanbul ignore if - failsafe to make sure we don‘t crash if there
* actually isn’t a checkbox. */
// Failsafe to make sure we don‘t crash if there actually isn’t a checkbox.
/* c8 ignore next */
if (!value) return

style = preferred[type]
Expand Down
10 changes: 5 additions & 5 deletions packages/remark-lint-checkbox-content-indent/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,18 +62,18 @@ function checkboxContentIndent(tree, file) {
return
}

/* istanbul ignore next - a list item cannot be checked and empty, according
* to GFM, but theoretically it makes sense to get the end if that were
* possible. */
// A list item cannot be checked and empty, according to GFM, but
// theoretically it makes sense to get the end if that were possible.
/* c8 ignore next */
point = node.children.length === 0 ? end(node) : start(node.children[0])

// Assume we start with a checkbox, because well, `checked` is set.
value = /\[([\t xX])]/.exec(
contents.slice(point.offset - 4, point.offset + 1)
)

/* istanbul ignore if - failsafe to make sure we don‘t crash if there
* actually isn’t a checkbox. */
// Failsafe to make sure we don‘t crash if there actually isn’t a checkbox.
/* c8 ignore next */
if (!value) return

// Move past checkbox.
Expand Down
3 changes: 2 additions & 1 deletion packages/remark-lint-link-title-style/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,8 @@ function linkTitleStyle(tree, file, option) {
while (last) {
final = contents.charAt(last)

/* istanbul ignore if - remark before 8.0.0 */
// Legacy for remark before 8.0.0
/* c8 ignore next 2 */
if (/\s/.test(final)) {
last--
} else {
Expand Down
3 changes: 2 additions & 1 deletion packages/remark-lint-list-item-content-indent/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,8 @@ function listItemContentIndent(tree, file) {

reason =
'Don’t use mixed indentation for children, ' +
/* istanbul ignore next - hard to test, I couldn’t find it at least. */
// Hard to test, I couldn’t find it at least.
/* c8 ignore next */
(diff > 0 ? 'add' : 'remove') +
' ' +
abs +
Expand Down
6 changes: 4 additions & 2 deletions packages/remark-lint-maximum-line-length/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,8 @@ function maximumLineLength(tree, file, option) {
var initial
var final

/* istanbul ignore if - Nothing to allow when generated. */
// Nothing to allow when generated.
/* c8 ignore next 3 */
if (generated(node)) {
return
}
Expand All @@ -165,7 +166,8 @@ function maximumLineLength(tree, file, option) {
}

function ignore(node) {
/* istanbul ignore else - Hard to test, as we only run this case on `position: true` */
// Hard to test, as we only run this case on `position: true`.
/* c8 ignore next 3 */
if (!generated(node)) {
allowList(start(node).line - 1, end(node).line)
}
Expand Down
1 change: 0 additions & 1 deletion packages/remark-lint-no-paragraph-content-indent/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,6 @@ function noParagraphContentIndent(tree, file) {
var offset
var lineColumn

/* istanbul ignore else - Custom nodes may be containers. */
if (parent && parent.type === 'root') {
column = 1
} else if (parent && parent.type === 'blockquote') {
Expand Down
6 changes: 1 addition & 5 deletions packages/remark-lint-no-table-indentation/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,6 @@ function noTableIndentation(tree, file) {
var offset
var lineColumn

/* istanbul ignore else - Custom nodes may be containers. */
if (parent && parent.type === 'root') {
column = 1
} else if (parent && parent.type === 'blockquote') {
Expand All @@ -90,6 +89,7 @@ function noTableIndentation(tree, file) {
column = position.start(parent.children[0]).column

// Skip past the first line if we’re the first child of a list item.
/* c8 ignore next 3 */
if (parent.children[0] === node) {
line++
}
Expand All @@ -108,10 +108,6 @@ function noTableIndentation(tree, file) {
offset--
}

/* istanbul ignore else - Exit if we find some other content before this
* line.
* This might be because the paragraph line is lazy, which isn’t this
* rule. */
if (!offset || /[\r\n>]/.test(content.charAt(offset - 1))) {
offset = lineColumn

Expand Down
9 changes: 6 additions & 3 deletions packages/unified-lint-rule/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ function factory(id, rule) {
var ruleId = parts[1]
var fn = wrapped(rule)

/* istanbul ignore if - possibly useful if externalised later. */
// Possibly useful if externalised later.
/* c8 ignore next 4 */
if (!ruleId) {
ruleId = source
source = null
Expand Down Expand Up @@ -38,7 +39,8 @@ function factory(id, rule) {
var message

// Add the error, if not already properly added.
/* istanbul ignore if - only happens for incorrect plugins */
// Only happens for incorrect plugins.
/* c8 ignore next 5 */
if (error && messages.indexOf(error) === -1) {
try {
file.fail(error)
Expand Down Expand Up @@ -66,7 +68,8 @@ function coerce(name, value) {
var result
var level

/* istanbul ignore if - Handled by unified in v6.0.0 */
// Handled by unified in v6.0.0.
/* c8 ignore next 3 */
if (typeof value === 'boolean') {
result = [value]
} else if (value == null) {
Expand Down
8 changes: 4 additions & 4 deletions script/util/rule.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,12 @@ function ruleSync(filePath) {
description = find(tags, 'fileoverview')
name = find(tags, 'module')

/* istanbul ignore if */
/* c8 ignore next 3 */
if (name !== ruleId) {
throw new Error(ruleId + ' has an incorrect `@module`: ' + name)
}

/* istanbul ignore if */
/* c8 ignore next 3 */
if (!description) {
throw new Error(ruleId + ' is missing a `@fileoverview`')
}
Expand All @@ -55,8 +55,8 @@ function ruleSync(filePath) {

try {
info = JSON.parse(lines[0])
/* c8 ignore next 5 */
} catch (error) {
/* istanbul ignore next */
throw new Error(
'Could not parse example in ' + ruleId + ':\n' + error.stack
)
Expand All @@ -83,7 +83,7 @@ function ruleSync(filePath) {
return
}

/* istanbul ignore if */
/* c8 ignore next 9 */
if (info.label !== 'input' && info.label !== 'output') {
throw new Error(
'Expected `input` or `ouput` for `label` in ' +
Expand Down

0 comments on commit e633c2f

Please sign in to comment.