Show (unchanged) keyword for accessibility in CLI --write (#15467)

This commit is contained in:
ADTC authored and GitHub committed 2023-10-09 08:40:28 +09:00
1 parent 64746cdd32
commit 7e67e43061
5 files changed
+50 -31

No files matched your search

+19
View File
@@ -0,0 +1,19 @@
#### Show `(unchanged)` keyword for accessibility in CLI `--write` (#15467 by @ADTC)
Previously, the only distinction between a changed file and an unchanged file was the grey color of the file name. In the example below, we can't distinguish between `a.js` and `b.js` as the color is missing. This issue is fixed by adding the `(unchanged)` keyword which makes the distinction accessible without color.
<!-- prettier-ignore -->
```sh
# Input
prettier --write .
# Prettier stable
a.js 0ms
b.js 0ms
c.js 0ms (cached)
# Prettier main
a.js 0ms
b.js 0ms (unchanged)
c.js 0ms (unchanged) (cached)
```
+1 -1
View File
@@ -437,7 +437,7 @@ async function formatFiles(context) {
} else if (!context.argv.check && !context.argv.listDifferent) {
const message = `${chalk.grey(fileNameToDisplay)} ${
Date.now() - start
}ms`;
}ms (unchanged)`;
if (isCacheExists) {
context.logger.log(`${message} (cached)`);
} else {
@@ -83,7 +83,7 @@ invalid-2.unknown
[[called readline.clearLine(process.stdout)]]
valid-1.js
[[called readline.clearLine(process.stdout)]]
valid-1.js 0ms"
valid-1.js 0ms (unchanged)"
`;
exports[`Line breaking after filepath with errors (write) 1`] = `[]`;
@@ -2,7 +2,7 @@
exports[`do not write file with --write + formatted file (stderr) 1`] = `""`;
exports[`do not write file with --write + formatted file (stdout) 1`] = `"formatted.js 0ms"`;
exports[`do not write file with --write + formatted file (stdout) 1`] = `"formatted.js 0ms (unchanged)"`;
exports[`do not write file with --write + invalid file (stderr) 1`] = `
"[error] invalid.js: SyntaxError: Unexpected token (1:17)
+28 -28
View File
@@ -133,7 +133,7 @@ describe("--cache option", () => {
expect(firstStdout.split("\n")).toEqual(
expect.arrayContaining([
expect.stringMatching(/^a\.js .+ms$/),
expect.stringMatching(/^b\.js .+ms$/),
expect.stringMatching(/^b\.js .+ms \(unchanged\)$/),
]),
);
@@ -146,8 +146,8 @@ describe("--cache option", () => {
]);
expect(secondStdout.split("\n")).toEqual(
expect.arrayContaining([
expect.stringMatching(/^a\.js .+ms \(cached\)$/),
expect.stringMatching(/^b\.js .+ms \(cached\)$/),
expect.stringMatching(/^a\.js .+ms \(unchanged\) \(cached\)$/),
expect.stringMatching(/^b\.js .+ms \(unchanged\) \(cached\)$/),
]),
);
});
@@ -167,7 +167,7 @@ describe("--cache option", () => {
expect(firstStdout.split("\n")).toEqual(
expect.arrayContaining([
expect.stringMatching(/^a\.js .+ms$/),
expect.stringMatching(/^b\.js .+ms$/),
expect.stringMatching(/^b\.js .+ms \(unchanged\)$/),
]),
);
@@ -182,7 +182,7 @@ describe("--cache option", () => {
// the cache of `b.js` is only available.
expect.arrayContaining([
expect.stringMatching(/^a\.js .+ms$/),
expect.stringMatching(/^b\.js .+ms \(cached\)$/),
expect.stringMatching(/^b\.js .+ms \(unchanged\) \(cached\)$/),
]),
);
});
@@ -202,7 +202,7 @@ describe("--cache option", () => {
expect(firstStdout.split("\n")).toEqual(
expect.arrayContaining([
expect.stringMatching(/^a\.js .+ms$/),
expect.stringMatching(/^b\.js .+ms$/),
expect.stringMatching(/^b\.js .+ms \(unchanged\)$/),
]),
);
@@ -218,7 +218,7 @@ describe("--cache option", () => {
// the cache of `b.js` is only available.
expect.arrayContaining([
expect.stringMatching(/^a\.js .+ms$/),
expect.stringMatching(/^b\.js .+ms \(cached\)$/),
expect.stringMatching(/^b\.js .+ms \(unchanged\) \(cached\)$/),
]),
);
});
@@ -234,7 +234,7 @@ describe("--cache option", () => {
expect(firstStdout.split("\n")).toEqual(
expect.arrayContaining([
expect.stringMatching(/^a\.js .+ms$/),
expect.stringMatching(/^b\.js .+ms$/),
expect.stringMatching(/^b\.js .+ms \(unchanged\)$/),
]),
);
@@ -250,7 +250,7 @@ describe("--cache option", () => {
expect(secondStdout.split("\n")).toEqual(
expect.arrayContaining([
expect.stringMatching(/^a\.js .+ms$/),
expect.stringMatching(/^b\.js .+ms$/),
expect.stringMatching(/^b\.js .+ms \(unchanged\)$/),
]),
);
});
@@ -273,7 +273,7 @@ describe("--cache option", () => {
expect(secondStdout.split("\n")).toEqual(
expect.arrayContaining([
expect.stringMatching(/^a\.js .+ms$/),
expect.stringMatching(/^b\.js .+ms \(cached\)$/),
expect.stringMatching(/^b\.js .+ms \(unchanged\) \(cached\)$/),
]),
);
});
@@ -309,7 +309,7 @@ describe("--cache option", () => {
expect(thirdStdout.split("\n")).toEqual(
expect.arrayContaining([
expect.stringMatching(/^a\.js .+ms$/),
expect.stringMatching(/^b\.js .+ms \(cached\)$/),
expect.stringMatching(/^b\.js .+ms \(unchanged\) \(cached\)$/),
]),
);
});
@@ -336,7 +336,7 @@ describe("--cache option", () => {
expect(firstStdout.split("\n")).toEqual(
expect.arrayContaining([
expect.stringMatching(/^a\.js .+ms$/),
expect.stringMatching(/^b\.js .+ms$/),
expect.stringMatching(/^b\.js .+ms \(unchanged\)$/),
]),
);
@@ -394,7 +394,7 @@ describe("--cache option", () => {
expect(firstStdout.split("\n")).toEqual(
expect.arrayContaining([
expect.stringMatching(/^a\.js .+ms$/),
expect.stringMatching(/^b\.js .+ms$/),
expect.stringMatching(/^b\.js .+ms \(unchanged\)$/),
]),
);
@@ -404,8 +404,8 @@ describe("--cache option", () => {
);
expect(secondStdout.split("\n")).toEqual(
expect.arrayContaining([
expect.stringMatching(/^a\.js .+ms \(cached\)$/),
expect.stringMatching(/^b\.js .+ms \(cached\)$/),
expect.stringMatching(/^a\.js .+ms \(unchanged\) \(cached\)$/),
expect.stringMatching(/^b\.js .+ms \(unchanged\) \(cached\)$/),
]),
);
});
@@ -425,7 +425,7 @@ describe("--cache option", () => {
expect(firstStdout.split("\n")).toEqual(
expect.arrayContaining([
expect.stringMatching(/^a\.js .+ms$/),
expect.stringMatching(/^b\.js .+ms$/),
expect.stringMatching(/^b\.js .+ms \(unchanged\)$/),
]),
);
@@ -440,7 +440,7 @@ describe("--cache option", () => {
// the cache of `b.js` is only available.
expect.arrayContaining([
expect.stringMatching(/^a\.js .+ms$/),
expect.stringMatching(/^b\.js .+ms \(cached\)$/),
expect.stringMatching(/^b\.js .+ms \(unchanged\) \(cached\)$/),
]),
);
});
@@ -460,7 +460,7 @@ describe("--cache option", () => {
expect(firstStdout.split("\n")).toEqual(
expect.arrayContaining([
expect.stringMatching(/^a\.js .+ms$/),
expect.stringMatching(/^b\.js .+ms$/),
expect.stringMatching(/^b\.js .+ms \(unchanged\)$/),
]),
);
@@ -474,8 +474,8 @@ describe("--cache option", () => {
);
expect(secondStdout.split("\n")).toEqual(
expect.arrayContaining([
expect.stringMatching(/^a\.js .+ms \(cached\)$/),
expect.stringMatching(/^b\.js .+ms \(cached\)$/),
expect.stringMatching(/^a\.js .+ms \(unchanged\) \(cached\)$/),
expect.stringMatching(/^b\.js .+ms \(unchanged\) \(cached\)$/),
]),
);
});
@@ -491,7 +491,7 @@ describe("--cache option", () => {
expect(firstStdout.split("\n")).toEqual(
expect.arrayContaining([
expect.stringMatching(/^a\.js .+ms$/),
expect.stringMatching(/^b\.js .+ms$/),
expect.stringMatching(/^b\.js .+ms \(unchanged\)$/),
]),
);
@@ -507,7 +507,7 @@ describe("--cache option", () => {
expect(secondStdout.split("\n")).toEqual(
expect.arrayContaining([
expect.stringMatching(/^a\.js .+ms$/),
expect.stringMatching(/^b\.js .+ms$/),
expect.stringMatching(/^b\.js .+ms \(unchanged\)$/),
]),
);
});
@@ -530,7 +530,7 @@ describe("--cache option", () => {
expect(secondStdout.split("\n")).toEqual(
expect.arrayContaining([
expect.stringMatching(/^a\.js .+ms$/),
expect.stringMatching(/^b\.js .+ms \(cached\)$/),
expect.stringMatching(/^b\.js .+ms \(unchanged\) \(cached\)$/),
]),
);
});
@@ -566,7 +566,7 @@ describe("--cache option", () => {
expect(thirdStdout.split("\n")).toEqual(
expect.arrayContaining([
expect.stringMatching(/^a\.js .+ms$/),
expect.stringMatching(/^b\.js .+ms \(cached\)$/),
expect.stringMatching(/^b\.js .+ms \(unchanged\) \(cached\)$/),
]),
);
});
@@ -593,7 +593,7 @@ describe("--cache option", () => {
expect(firstStdout.split("\n")).toEqual(
expect.arrayContaining([
expect.stringMatching(/^a\.js .+ms$/),
expect.stringMatching(/^b\.js .+ms$/),
expect.stringMatching(/^b\.js .+ms \(unchanged\)$/),
]),
);
@@ -677,7 +677,7 @@ describe("--cache option", () => {
expect(firstStdout.split("\n")).toEqual(
expect.arrayContaining([
expect.stringMatching(/^a\.js .+ms$/),
expect.stringMatching(/^b\.js .+ms$/),
expect.stringMatching(/^b\.js .+ms \(unchanged\)$/),
]),
);
@@ -687,8 +687,8 @@ describe("--cache option", () => {
);
expect(secondStdout.split("\n")).toEqual(
expect.arrayContaining([
expect.stringMatching(/^a\.js .+ms \(cached\)$/),
expect.stringMatching(/^b\.js .+ms \(cached\)$/),
expect.stringMatching(/^a\.js .+ms \(unchanged\) \(cached\)$/),
expect.stringMatching(/^b\.js .+ms \(unchanged\) \(cached\)$/),
]),
);
});