Skip to content

Commit 70fce3c

Browse files
committed
Configure Prettier option singleQuote to the default, false.
1 parent 448bf07 commit 70fce3c

25 files changed

+346
-346
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ jobs:
77
strategy:
88
matrix:
99
os: [ubuntu-latest, macos-latest]
10-
node: ['12', '14', '16', '17']
10+
node: ["12", "14", "16", "17"]
1111
steps:
1212
- uses: actions/checkout@v2
1313
- name: Setup Node.js v${{ matrix.node }}

.prettierrc.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
11
{
2-
"proseWrap": "never",
3-
"singleQuote": true
2+
"proseWrap": "never"
43
}

changelog.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
### Patch
1212

1313
- Also run GitHub Actions CI with Node.js v17, and drop v15.
14+
- Configured Prettier option `singleQuote` to the default, `false`.
1415
- Readme tweaks.
1516

1617
## 5.0.1

cli/coverage-node.mjs

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
#!/usr/bin/env node
22

3-
import { spawn } from 'child_process';
4-
import disposableDirectory from 'disposable-directory';
5-
import kleur from 'kleur';
6-
import CliError from '../private/CliError.mjs';
7-
import childProcessPromise from '../private/childProcessPromise.mjs';
8-
import reportCliError from '../private/reportCliError.mjs';
9-
import analyseCoverage from '../public/analyseCoverage.mjs';
10-
import coverageSupported from '../public/coverageSupported.mjs';
11-
import minNodeVersion from '../public/coverageSupportedMinNodeVersion.mjs';
12-
import reportCoverage from '../public/reportCoverage.mjs';
3+
import { spawn } from "child_process";
4+
import disposableDirectory from "disposable-directory";
5+
import kleur from "kleur";
6+
import CliError from "../private/CliError.mjs";
7+
import childProcessPromise from "../private/childProcessPromise.mjs";
8+
import reportCliError from "../private/reportCliError.mjs";
9+
import analyseCoverage from "../public/analyseCoverage.mjs";
10+
import coverageSupported from "../public/coverageSupported.mjs";
11+
import minNodeVersion from "../public/coverageSupportedMinNodeVersion.mjs";
12+
import reportCoverage from "../public/reportCoverage.mjs";
1313

1414
/**
1515
* Powers the `coverage-node` CLI. Runs Node.js with the given arguments and
@@ -25,14 +25,14 @@ async function coverageNode() {
2525
const [, , ...nodeArgs] = process.argv;
2626

2727
if (!nodeArgs.length)
28-
throw new CliError('Node.js CLI arguments are required.');
28+
throw new CliError("Node.js CLI arguments are required.");
2929

3030
// eslint-disable-next-line curly
3131
if (coverageSupported) {
3232
await disposableDirectory(async (tempDirPath) => {
3333
const { exitCode } = await childProcessPromise(
34-
spawn('node', nodeArgs, {
35-
stdio: 'inherit',
34+
spawn("node", nodeArgs, {
35+
stdio: "inherit",
3636
env: { ...process.env, NODE_V8_COVERAGE: tempDirPath },
3737
})
3838
);
@@ -48,7 +48,7 @@ async function coverageNode() {
4848
// coverage ignore next line
4949
} else {
5050
const { exitCode } = await childProcessPromise(
51-
spawn('node', nodeArgs, { stdio: 'inherit' })
51+
spawn("node", nodeArgs, { stdio: "inherit" })
5252
);
5353

5454
if (exitCode === 0)
@@ -63,7 +63,7 @@ async function coverageNode() {
6363
reportCliError(
6464
`Node.js${
6565
// coverage ignore next line
66-
coverageSupported ? ' with coverage' : ''
66+
coverageSupported ? " with coverage" : ""
6767
}`,
6868
error
6969
);

private/childProcessPromise.mjs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { ChildProcess } from 'child_process';
1+
import { ChildProcess } from "child_process";
22

33
/**
44
* Promisifies a Node.js child process.
@@ -11,12 +11,12 @@ import { ChildProcess } from 'child_process';
1111
export default async function childProcessPromise(childProcess) {
1212
if (!(childProcess instanceof ChildProcess))
1313
throw new TypeError(
14-
'First argument `childProcess` must be a `ChildProcess` instance.'
14+
"First argument `childProcess` must be a `ChildProcess` instance."
1515
);
1616

1717
return new Promise((resolve, reject) => {
18-
childProcess.once('error', reject);
19-
childProcess.once('close', (exitCode, signal) =>
18+
childProcess.once("error", reject);
19+
childProcess.once("close", (exitCode, signal) =>
2020
resolve({ exitCode, signal })
2121
);
2222
});

private/errorConsole.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Console } from 'console';
1+
import { Console } from "console";
22

33
/**
44
* The `console` API, but all output is to `stderr`. This allows `console.group`

private/reportCliError.mjs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
import { inspect } from 'util';
2-
import kleur from 'kleur';
3-
import CliError from './CliError.mjs';
4-
import errorConsole from './errorConsole.mjs';
1+
import { inspect } from "util";
2+
import kleur from "kleur";
3+
import CliError from "./CliError.mjs";
4+
import errorConsole from "./errorConsole.mjs";
55

66
/**
77
* Reports a CLI error via the process `stderr`.
@@ -12,8 +12,8 @@ import errorConsole from './errorConsole.mjs';
1212
* @ignore
1313
*/
1414
export default function reportCliError(cliDescription, error) {
15-
if (typeof cliDescription !== 'string')
16-
throw new TypeError('First argument `cliDescription` must be a string.');
15+
if (typeof cliDescription !== "string")
16+
throw new TypeError("First argument `cliDescription` must be a string.");
1717

1818
errorConsole.group(
1919
// Whitespace blank lines shouldn’t have redundant indentation or color.

private/semver.mjs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
* @ignore
88
*/
99
export default function semver(semver) {
10-
if (typeof semver !== 'string')
11-
throw new TypeError('First argument `semver` must be a string.');
10+
if (typeof semver !== "string")
11+
throw new TypeError("First argument `semver` must be a string.");
1212

1313
const [, major, minor, patch, prerelease, build] = semver.match(
1414
// The is is official recommended RegEx, see:

private/sourceRange.mjs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,31 +6,31 @@
66
* @param {string} source Source code.
77
* @param {number} startOffset Start character offset.
88
* @param {number} endOffset End character offset.
9-
* @param {string|boolean} [ignoreNextLineComment=' coverage ignore next line'] Single line case-insensitive comment content to ignore ranges that start on the the next line, or `false` to disable ignore comments.
9+
* @param {string|boolean} [ignoreNextLineComment=" coverage ignore next line"] Single line case-insensitive comment content to ignore ranges that start on the the next line, or `false` to disable ignore comments.
1010
* @returns {SourceCodeRange} Source code range info.
1111
* @ignore
1212
*/
1313
export default function sourceRange(
1414
source,
1515
startOffset,
1616
endOffset,
17-
ignoreNextLineComment = ' coverage ignore next line'
17+
ignoreNextLineComment = " coverage ignore next line"
1818
) {
19-
if (typeof source !== 'string')
20-
throw new TypeError('First argument `source` must be a string.');
19+
if (typeof source !== "string")
20+
throw new TypeError("First argument `source` must be a string.");
2121

22-
if (typeof startOffset !== 'number')
23-
throw new TypeError('Second argument `startOffset` must be a number.');
22+
if (typeof startOffset !== "number")
23+
throw new TypeError("Second argument `startOffset` must be a number.");
2424

25-
if (typeof endOffset !== 'number')
26-
throw new TypeError('Third argument `endOffset` must be a number.');
25+
if (typeof endOffset !== "number")
26+
throw new TypeError("Third argument `endOffset` must be a number.");
2727

2828
if (
29-
typeof ignoreNextLineComment !== 'string' &&
29+
typeof ignoreNextLineComment !== "string" &&
3030
ignoreNextLineComment !== false
3131
)
3232
throw new TypeError(
33-
'Fourth argument `ignoreNextLineComment` must be a string or `false`.'
33+
"Fourth argument `ignoreNextLineComment` must be a string or `false`."
3434
);
3535

3636
if (ignoreNextLineComment)
@@ -48,7 +48,7 @@ export default function sourceRange(
4848
const nextLineOffset = lineOffset + lineSource.length;
4949

5050
if (
51-
!('line' in range.start) &&
51+
!("line" in range.start) &&
5252
startOffset >= lineOffset &&
5353
startOffset < nextLineOffset
5454
) {

public/analyseCoverage.mjs

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
import fs from 'fs';
2-
import { join } from 'path';
3-
import { fileURLToPath } from 'url';
4-
import v8Coverage from '@bcoe/v8-coverage';
5-
import sourceRange from '../private/sourceRange.mjs';
1+
import fs from "fs";
2+
import { join } from "path";
3+
import { fileURLToPath } from "url";
4+
import v8Coverage from "@bcoe/v8-coverage";
5+
import sourceRange from "../private/sourceRange.mjs";
66

77
/**
88
* Analyzes [Node.js generated V8 JavaScript code coverage data](https://nodejs.org/api/cli.html#cli_node_v8_coverage_dir)
@@ -13,37 +13,37 @@ import sourceRange from '../private/sourceRange.mjs';
1313
* @returns {Promise<CoverageAnalysis>} Resolves the coverage analysis.
1414
* @example <caption>Ways to `import`.</caption>
1515
* ```js
16-
* import { analyseCoverage } from 'coverage-node';
16+
* import { analyseCoverage } from "coverage-node";
1717
* ```
1818
*
1919
* ```js
20-
* import analyseCoverage from 'coverage-node/public/analyseCoverage.mjs';
20+
* import analyseCoverage from "coverage-node/public/analyseCoverage.mjs";
2121
* ```
2222
*/
2323
export default async function analyseCoverage(coverageDirPath) {
24-
if (typeof coverageDirPath !== 'string')
25-
throw new TypeError('First argument `coverageDirPath` must be a string.');
24+
if (typeof coverageDirPath !== "string")
25+
throw new TypeError("First argument `coverageDirPath` must be a string.");
2626

2727
const coverageDirFileNames = await fs.promises.readdir(coverageDirPath);
2828
const filteredProcessCoverages = [];
2929

3030
for (const fileName of coverageDirFileNames)
31-
if (fileName.startsWith('coverage-'))
31+
if (fileName.startsWith("coverage-"))
3232
filteredProcessCoverages.push(
3333
fs.promises
34-
.readFile(join(coverageDirPath, fileName), 'utf8')
34+
.readFile(join(coverageDirPath, fileName), "utf8")
3535
.then((coverageFileJson) => {
3636
const { result } = JSON.parse(coverageFileJson);
3737
return {
3838
// For performance, filtering happens as early as possible.
3939
result: result.filter(
4040
({ url }) =>
4141
// Exclude Node.js internals, keeping only files.
42-
url.startsWith('file://') &&
42+
url.startsWith("file://") &&
4343
// Exclude `node_modules` directory files.
44-
!url.includes('/node_modules/') &&
44+
!url.includes("/node_modules/") &&
4545
// Exclude `test` directory files.
46-
!url.includes('/test/') &&
46+
!url.includes("/test/") &&
4747
// Exclude files with `.test` prefixed before the extension.
4848
!/\.test\.\w+$/u.test(url) &&
4949
// Exclude files named `test` (regardless of extension).
@@ -82,7 +82,7 @@ export default async function analyseCoverage(coverageDirPath) {
8282
for (const range of ranges) if (!range.count) uncoveredRanges.push(range);
8383

8484
if (uncoveredRanges.length) {
85-
const source = await fs.promises.readFile(path, 'utf8');
85+
const source = await fs.promises.readFile(path, "utf8");
8686
const ignored = [];
8787
const uncovered = [];
8888

public/coverageSupported.mjs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import semver from '../private/semver.mjs';
2-
import coverageSupportedMinNodeVersion from './coverageSupportedMinNodeVersion.mjs';
1+
import semver from "../private/semver.mjs";
2+
import coverageSupportedMinNodeVersion from "./coverageSupportedMinNodeVersion.mjs";
33

44
const {
55
major: minMajor,
@@ -16,11 +16,11 @@ const { major, minor, patch } = semver(process.versions.node);
1616
* @type {boolean}
1717
* @example <caption>Ways to `import`.</caption>
1818
* ```js
19-
* import { coverageSupported } from 'coverage-node';
19+
* import { coverageSupported } from "coverage-node";
2020
* ```
2121
*
2222
* ```js
23-
* import coverageSupported from 'coverage-node/public/coverageSupported.mjs';
23+
* import coverageSupported from "coverage-node/public/coverageSupported.mjs";
2424
* ```
2525
*/
2626
export default // coverage ignore next line

public/coverageSupportedMinNodeVersion.mjs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@
66
* @type {SemanticVersion}
77
* @example <caption>Ways to `import`.</caption>
88
* ```js
9-
* import { coverageSupportedMinNodeVersion } from 'coverage-node';
9+
* import { coverageSupportedMinNodeVersion } from "coverage-node";
1010
* ```
1111
*
1212
* ```js
13-
* import coverageSupportedMinNodeVersion from 'coverage-node/public/coverageSupportedMinNodeVersion.mjs';
13+
* import coverageSupportedMinNodeVersion from "coverage-node/public/coverageSupportedMinNodeVersion.mjs";
1414
* ```
1515
*/
1616
export default { major: 13, minor: 3, patch: 0 };

public/index.mjs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
export { default as coverageSupported } from './coverageSupported.mjs';
2-
export { default as coverageSupportedMinNodeVersion } from './coverageSupportedMinNodeVersion.mjs';
3-
export { default as analyseCoverage } from './analyseCoverage.mjs';
4-
export { default as reportCoverage } from './reportCoverage.mjs';
1+
export { default as coverageSupported } from "./coverageSupported.mjs";
2+
export { default as coverageSupportedMinNodeVersion } from "./coverageSupportedMinNodeVersion.mjs";
3+
export { default as analyseCoverage } from "./analyseCoverage.mjs";
4+
export { default as reportCoverage } from "./reportCoverage.mjs";
55

66
/**
77
* [Node.js generated V8 JavaScript code coverage data](https://nodejs.org/api/cli.html#cli_node_v8_coverage_dir)

public/reportCoverage.mjs

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import { relative } from 'path';
2-
import kleur from 'kleur';
3-
import errorConsole from '../private/errorConsole.mjs';
1+
import { relative } from "path";
2+
import kleur from "kleur";
3+
import errorConsole from "../private/errorConsole.mjs";
44

55
/**
66
* Reports a code coverage analysis to the console.
@@ -9,11 +9,11 @@ import errorConsole from '../private/errorConsole.mjs';
99
* @param {CoverageAnalysis} coverageAnalysis Coverage analysis from [`analyseCoverage`]{@link analyseCoverage}.
1010
* @example <caption>Ways to `import`.</caption>
1111
* ```js
12-
* import { reportCoverage } from 'coverage-node';
12+
* import { reportCoverage } from "coverage-node";
1313
* ```
1414
*
1515
* ```js
16-
* import reportCoverage from 'coverage-node/public/reportCoverage.mjs';
16+
* import reportCoverage from "coverage-node/public/reportCoverage.mjs";
1717
* ```
1818
*/
1919
export default function reportCoverage({
@@ -25,11 +25,11 @@ export default function reportCoverage({
2525
if (covered.length) {
2626
console.group(
2727
`\n${kleur.green(
28-
`${covered.length} file${covered.length === 1 ? '' : 's'} covered:`
28+
`${covered.length} file${covered.length === 1 ? "" : "s"} covered:`
2929
)}\n`
3030
);
3131

32-
for (const path of covered) console.info(relative('', path));
32+
for (const path of covered) console.info(relative("", path));
3333

3434
console.groupEnd();
3535
}
@@ -38,15 +38,15 @@ export default function reportCoverage({
3838
console.group(
3939
`\n${kleur.yellow(
4040
`${ignored.length} file${
41-
ignored.length === 1 ? '' : 's'
41+
ignored.length === 1 ? "" : "s"
4242
} ignoring coverage:`
4343
)}\n`
4444
);
4545

4646
for (const { path, ranges } of ignored)
4747
for (const { start, end } of ranges)
4848
console.info(
49-
`${relative('', path)}:${start.line}:${start.column}${end.line}:${
49+
`${relative("", path)}:${start.line}:${start.column}${end.line}:${
5050
end.column
5151
}`
5252
);
@@ -58,15 +58,15 @@ export default function reportCoverage({
5858
errorConsole.group(
5959
`\n${kleur.red(
6060
`${uncovered.length} file${
61-
uncovered.length === 1 ? '' : 's'
61+
uncovered.length === 1 ? "" : "s"
6262
} missing coverage:`
6363
)}\n`
6464
);
6565

6666
for (const { path, ranges } of uncovered)
6767
for (const { start, end } of ranges)
6868
errorConsole.info(
69-
`${relative('', path)}:${start.line}:${start.column}${end.line}:${
69+
`${relative("", path)}:${start.line}:${start.column}${end.line}:${
7070
end.column
7171
}`
7272
);
@@ -77,7 +77,7 @@ export default function reportCoverage({
7777
console.info(
7878
`\n${kleur
7979
.bold()
80-
[uncovered.length ? 'red' : ignored.length ? 'yellow' : 'green'](
80+
[uncovered.length ? "red" : ignored.length ? "yellow" : "green"](
8181
`${covered.length}/${filesCount} files covered.`
8282
)}\n`
8383
);

0 commit comments

Comments
 (0)