Skip to content

Commit 750b8df

Browse files
chore: update dependency glob to v10 (#17917)
* chore: update dependency glob to v10 * update tools/check-rule-examples.js for glob 10 * fix for removed `nonull` flag * fix test on Windows --------- Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Co-authored-by: Francesco Trotta <[email protected]>
1 parent c2bf27d commit 750b8df

File tree

3 files changed

+28
-27
lines changed

3 files changed

+28
-27
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@
127127
"esprima": "^4.0.1",
128128
"fast-glob": "^3.2.11",
129129
"fs-teardown": "^0.1.3",
130-
"glob": "^7.1.6",
130+
"glob": "^10.0.0",
131131
"got": "^11.8.3",
132132
"gray-matter": "^4.0.3",
133133
"js-yaml": "^4.1.0",

tests/tools/check-rule-examples.js

Lines changed: 19 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -51,20 +51,29 @@ describe("check-rule-examples", () => {
5151

5252
await assert.rejects(
5353
promise,
54-
{
55-
code: 1,
56-
stdout: "",
57-
stderr:
54+
({ code, stdout, stderr }) => {
55+
assert.strictEqual(code, 1);
56+
assert.strictEqual(stdout, "");
57+
58+
// Remove OS-dependent path except base name.
59+
const normalizedStderr =
60+
// eslint-disable-next-line no-control-regex -- escaping control character
61+
stderr.replace(/(?<=\x1B\[4m).*(?=bad-examples\.md)/u, "");
62+
63+
const expectedStderr =
5864
"\x1B[0m\x1B[0m\n" +
59-
"\x1B[0m\x1B[4mtests/fixtures/bad-examples.md\x1B[24m\x1B[0m\n" +
65+
"\x1B[0m\x1B[4mbad-examples.md\x1B[24m\x1B[0m\n" +
6066
"\x1B[0m \x1B[2m11:4\x1B[22m \x1B[31merror\x1B[39m Missing language tag: use one of 'javascript', 'js' or 'jsx'\x1B[0m\n" +
6167
"\x1B[0m \x1B[2m12:1\x1B[22m \x1B[31merror\x1B[39m Syntax error: 'import' and 'export' may appear only with 'sourceType: module'\x1B[0m\n" +
6268
"\x1B[0m \x1B[2m20:5\x1B[22m \x1B[31merror\x1B[39m Nonstandard language tag 'ts': use one of 'javascript', 'js' or 'jsx'\x1B[0m\n" +
6369
"\x1B[0m \x1B[2m23:7\x1B[22m \x1B[31merror\x1B[39m Syntax error: Identifier 'foo' has already been declared\x1B[0m\n" +
6470
"\x1B[0m \x1B[2m31:1\x1B[22m \x1B[31merror\x1B[39m Example code should contain a configuration comment like /* eslint no-restricted-syntax: \"error\" */\x1B[0m\n" +
6571
"\x1B[0m\x1B[0m\n" +
6672
"\x1B[0m\x1B[31m\x1B[1m✖ 5 problems (5 errors, 0 warnings)\x1B[22m\x1B[39m\x1B[0m\n" +
67-
"\x1B[0m\x1B[31m\x1B[1m\x1B[22m\x1B[39m\x1B[0m\n"
73+
"\x1B[0m\x1B[31m\x1B[1m\x1B[22m\x1B[39m\x1B[0m\n";
74+
75+
assert.strictEqual(normalizedStderr, expectedStderr);
76+
return true;
6877
}
6978
);
7079
});
@@ -74,22 +83,10 @@ describe("check-rule-examples", () => {
7483

7584
await assert.rejects(
7685
promise,
77-
({ code, stdout, stderr }) => {
78-
assert.strictEqual(code, 1);
79-
assert.strictEqual(stdout, "");
80-
const expectedStderr =
81-
"\x1B[0m\x1B[0m\n" +
82-
"\x1B[0m\x1B[4mtests/fixtures/non-existing-examples.md\x1B[24m\x1B[0m\n" +
83-
"\x1B[0m \x1B[2m0:0\x1B[22m \x1B[31merror\x1B[39m Error checking file: ENOENT: no such file or directory, open <FILE>\x1B[0m\n" +
84-
"\x1B[0m\x1B[0m\n" +
85-
"\x1B[0m\x1B[31m\x1B[1m✖ 1 problem (1 error, 0 warnings)\x1B[22m\x1B[39m\x1B[0m\n" +
86-
"\x1B[0m\x1B[31m\x1B[1m\x1B[22m\x1B[39m\x1B[0m\n";
87-
88-
// Replace filename as it's OS-dependent.
89-
const normalizedStderr = stderr.replace(/'.+'/u, "<FILE>");
90-
91-
assert.strictEqual(normalizedStderr, expectedStderr);
92-
return true;
86+
{
87+
code: 1,
88+
stdout: "",
89+
stderr: "No files found that match the specified patterns.\n"
9390
}
9491
);
9592
});

tools/check-rule-examples.js

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,10 @@
66

77
const { parse } = require("espree");
88
const { readFile } = require("fs").promises;
9-
const glob = require("glob");
9+
const { glob } = require("glob");
1010
const matter = require("gray-matter");
1111
const markdownIt = require("markdown-it");
1212
const markdownItContainer = require("markdown-it-container");
13-
const { promisify } = require("util");
1413
const markdownItRuleExample = require("../docs/tools/markdown-it-rule-example");
1514
const ConfigCommentParser = require("../lib/linter/config-comment-parser");
1615
const rules = require("../lib/rules");
@@ -166,10 +165,15 @@ async function checkFile(filename) {
166165
const patterns = process.argv.slice(2);
167166

168167
(async function() {
169-
const globAsync = promisify(glob);
170168

171169
// determine which files to check
172-
const filenames = (await Promise.all(patterns.map(pattern => globAsync(pattern, { nonull: true })))).flat();
170+
const filenames = await glob(patterns);
171+
172+
if (patterns.length && !filenames.length) {
173+
console.error("No files found that match the specified patterns.");
174+
process.exitCode = 1;
175+
return;
176+
}
173177
const results = await Promise.all(filenames.map(checkFile));
174178

175179
if (results.every(result => result.errorCount === 0)) {

0 commit comments

Comments
 (0)