Skip to content

Commit fab9c00

Browse files
authored
chore: upgrade biome (#16246)
1 parent 337d3aa commit fab9c00

20 files changed

Lines changed: 588 additions & 633 deletions

biome.jsonc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"$schema": "https://biomejs.dev/schemas/2.4.2/schema.json",
2+
"$schema": "https://biomejs.dev/schemas/2.4.10/schema.json",
33
"files": {
44
"includes": [
55
"**",

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@
6262
},
6363
"devDependencies": {
6464
"@astrojs/check": "^0.9.5",
65-
"@biomejs/biome": "2.4.2",
65+
"@biomejs/biome": "2.4.10",
6666
"@changesets/changelog-github": "^0.5.2",
6767
"@changesets/cli": "^2.29.8",
6868
"@flue/cli": "^0.0.47",

packages/astro/test/astro-component-bundling.test.js

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -45,20 +45,18 @@ describe('Component bundling', () => {
4545
await fixture.build();
4646
});
4747

48-
it(
49-
'should treeshake FooComponent',
50-
{ skip: 'Not sure how this can possibly work, we bundle the module as an entrypoint.' },
51-
async () => {
52-
const astroChunkDir = await fixture.readdir('/_astro');
53-
const manyComponentsChunkName = astroChunkDir.find((chunk) =>
54-
chunk.startsWith('ManyComponents'),
55-
);
56-
const manyComponentsChunkContent = await fixture.readFile(
57-
`/_astro/${manyComponentsChunkName}`,
58-
);
59-
assert.equal(manyComponentsChunkContent.includes('FooComponent'), false);
60-
},
61-
);
48+
it('should treeshake FooComponent', {
49+
skip: 'Not sure how this can possibly work, we bundle the module as an entrypoint.',
50+
}, async () => {
51+
const astroChunkDir = await fixture.readdir('/_astro');
52+
const manyComponentsChunkName = astroChunkDir.find((chunk) =>
53+
chunk.startsWith('ManyComponents'),
54+
);
55+
const manyComponentsChunkContent = await fixture.readFile(
56+
`/_astro/${manyComponentsChunkName}`,
57+
);
58+
assert.equal(manyComponentsChunkContent.includes('FooComponent'), false);
59+
});
6260

6361
it('should not include Astro components in client bundles', async () => {
6462
const html = await fixture.readFile('/astro-in-client/index.html');

packages/astro/test/cli.test.js

Lines changed: 66 additions & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -14,54 +14,50 @@ describe('astro cli', () => {
1414
});
1515

1616
// Flaky test, in CI it exceeds the timeout most of the times
17-
it.skip(
18-
'astro check --watch reports errors on modified files',
19-
{
20-
timeout: 35000,
21-
},
22-
async () => {
23-
let messageResolve;
24-
const messagePromise = new Promise((resolve) => {
25-
messageResolve = resolve;
26-
});
27-
const oneErrorContent = 'foobar';
17+
it.skip('astro check --watch reports errors on modified files', {
18+
timeout: 35000,
19+
}, async () => {
20+
let messageResolve;
21+
const messagePromise = new Promise((resolve) => {
22+
messageResolve = resolve;
23+
});
24+
const oneErrorContent = 'foobar';
2825

29-
/** @type {import('./test-utils').Fixture} */
30-
const fixture = await loadFixture({
31-
root: './fixtures/astro-check-watch/',
32-
});
33-
const logs = [];
26+
/** @type {import('./test-utils').Fixture} */
27+
const fixture = await loadFixture({
28+
root: './fixtures/astro-check-watch/',
29+
});
30+
const logs = [];
3431

35-
const checkServer = await fixture.check({
36-
flags: { watch: true },
37-
logging: {
38-
level: 'info',
39-
dest: new Writable({
40-
objectMode: true,
41-
write(event, _, callback) {
42-
logs.push({ ...event, message: stripVTControlCharacters(event.message) });
43-
if (event.message.includes('1 error')) {
44-
messageResolve(logs);
45-
}
46-
callback();
47-
},
48-
}),
49-
},
50-
});
51-
await checkServer.watch();
52-
const pagePath = join(fileURLToPath(fixture.config.root), 'src/pages/index.astro');
53-
const pageContent = readFileSync(pagePath, 'utf-8');
54-
await fs.writeFile(pagePath, oneErrorContent);
55-
const messages = await messagePromise;
56-
await fs.writeFile(pagePath, pageContent);
57-
await checkServer.stop();
58-
const diagnostics = messages.filter(
59-
(m) => m.type === 'diagnostics' && m.message.includes('Result'),
60-
);
61-
assert.equal(diagnostics[0].message.includes('0 errors'), true);
62-
assert.equal(diagnostics[1].message.includes('1 error'), true);
63-
},
64-
);
32+
const checkServer = await fixture.check({
33+
flags: { watch: true },
34+
logging: {
35+
level: 'info',
36+
dest: new Writable({
37+
objectMode: true,
38+
write(event, _, callback) {
39+
logs.push({ ...event, message: stripVTControlCharacters(event.message) });
40+
if (event.message.includes('1 error')) {
41+
messageResolve(logs);
42+
}
43+
callback();
44+
},
45+
}),
46+
},
47+
});
48+
await checkServer.watch();
49+
const pagePath = join(fileURLToPath(fixture.config.root), 'src/pages/index.astro');
50+
const pageContent = readFileSync(pagePath, 'utf-8');
51+
await fs.writeFile(pagePath, oneErrorContent);
52+
const messages = await messagePromise;
53+
await fs.writeFile(pagePath, pageContent);
54+
await checkServer.stop();
55+
const diagnostics = messages.filter(
56+
(m) => m.type === 'diagnostics' && m.message.includes('Result'),
57+
);
58+
assert.equal(diagnostics[0].message.includes('0 errors'), true);
59+
assert.equal(diagnostics[1].message.includes('1 error'), true);
60+
});
6561

6662
it('astro --version', async () => {
6763
const pkgURL = new URL('../package.json', import.meta.url);
@@ -72,39 +68,31 @@ describe('astro cli', () => {
7268
assert.equal(result.stdout.includes(pkgVersion), true);
7369
});
7470

75-
it(
76-
'astro check no errors',
77-
{
78-
timeout: 35000,
79-
},
80-
async () => {
81-
const projectRootURL = new URL('./fixtures/astro-check-no-errors/', import.meta.url);
82-
const result = await cli(
83-
'check',
84-
'--root',
85-
fileURLToPath(projectRootURL),
86-
'--noSync',
87-
).getResult();
71+
it('astro check no errors', {
72+
timeout: 35000,
73+
}, async () => {
74+
const projectRootURL = new URL('./fixtures/astro-check-no-errors/', import.meta.url);
75+
const result = await cli(
76+
'check',
77+
'--root',
78+
fileURLToPath(projectRootURL),
79+
'--noSync',
80+
).getResult();
8881

89-
assert.equal(result.stdout.includes('0 errors'), true);
90-
},
91-
);
82+
assert.equal(result.stdout.includes('0 errors'), true);
83+
});
9284

93-
it(
94-
'astro check has errors',
95-
{
96-
timeout: 35000,
97-
},
98-
async () => {
99-
const projectRootURL = new URL('./fixtures/astro-check-errors/', import.meta.url);
100-
const result = await cli(
101-
'check',
102-
'--root',
103-
fileURLToPath(projectRootURL),
104-
'--noSync',
105-
).getResult();
85+
it('astro check has errors', {
86+
timeout: 35000,
87+
}, async () => {
88+
const projectRootURL = new URL('./fixtures/astro-check-errors/', import.meta.url);
89+
const result = await cli(
90+
'check',
91+
'--root',
92+
fileURLToPath(projectRootURL),
93+
'--noSync',
94+
).getResult();
10695

107-
assert.equal(result.stdout.includes('1 error'), true);
108-
},
109-
);
96+
assert.equal(result.stdout.includes('1 error'), true);
97+
});
11098
});

packages/astro/test/custom-404-implicit-rerouting.test.js

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -58,14 +58,12 @@ for (const caseNumber of [1, 2, 3, 4, 5]) {
5858
});
5959

6060
// IMPORTANT: never skip
61-
it(
62-
'prod server stays responsive for case number ' + caseNumber,
63-
{ timeout: 3000 },
64-
async () => {
65-
const response = await app.render(new Request('https://example.com/alvsibdlvjks'));
66-
assert.equal(response.status, 404);
67-
},
68-
);
61+
it('prod server stays responsive for case number ' + caseNumber, {
62+
timeout: 3000,
63+
}, async () => {
64+
const response = await app.render(new Request('https://example.com/alvsibdlvjks'));
65+
assert.equal(response.status, 404);
66+
});
6967
});
7068
});
7169
}

packages/astro/test/hmr-markdown.test.js

Lines changed: 27 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -23,32 +23,31 @@ describe('HMR: Markdown updates', () => {
2323
await devServer.stop();
2424
});
2525

26-
it(
27-
'should update HTML when markdown changes',
28-
{ skip: isWindows, todo: 'HMR tests hang on Windows' },
29-
async () => {
30-
let response = await fixture.fetch('/');
31-
assert.equal(response.status, 200);
32-
let html = await response.text();
33-
assert.ok(html.includes('Original content'));
34-
35-
response = await fixture.fetch('/blog/post');
36-
assert.equal(response.status, 200);
37-
html = await response.text();
38-
assert.ok(html.includes('Original content'));
39-
40-
await fixture.editFile(markdownPath, UPDATED_CONTENT);
41-
await fixture.onNextDataStoreChange();
42-
43-
response = await fixture.fetch('/');
44-
assert.equal(response.status, 200);
45-
html = await response.text();
46-
assert.ok(html.includes('Updated content'));
47-
48-
response = await fixture.fetch('/blog/post');
49-
assert.equal(response.status, 200);
50-
html = await response.text();
51-
assert.ok(html.includes('Updated content'));
52-
},
53-
);
26+
it('should update HTML when markdown changes', {
27+
skip: isWindows,
28+
todo: 'HMR tests hang on Windows',
29+
}, async () => {
30+
let response = await fixture.fetch('/');
31+
assert.equal(response.status, 200);
32+
let html = await response.text();
33+
assert.ok(html.includes('Original content'));
34+
35+
response = await fixture.fetch('/blog/post');
36+
assert.equal(response.status, 200);
37+
html = await response.text();
38+
assert.ok(html.includes('Original content'));
39+
40+
await fixture.editFile(markdownPath, UPDATED_CONTENT);
41+
await fixture.onNextDataStoreChange();
42+
43+
response = await fixture.fetch('/');
44+
assert.equal(response.status, 200);
45+
html = await response.text();
46+
assert.ok(html.includes('Updated content'));
47+
48+
response = await fixture.fetch('/blog/post');
49+
assert.equal(response.status, 200);
50+
html = await response.text();
51+
assert.ok(html.includes('Updated content'));
52+
});
5453
});

packages/astro/test/hmr-new-page.test.js

Lines changed: 41 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -50,52 +50,50 @@ describe('HMR: New page detection', () => {
5050
assert.equal(response.status, 404);
5151
});
5252

53-
it(
54-
'should detect a new page without server restart',
55-
{ skip: isWindows, todo: 'I hangs on windows' },
56-
async () => {
57-
// 1. Verify the page doesn't exist yet
58-
let response = await fixture.fetch('/new-page');
59-
assert.equal(response.status, 404, 'Page should not exist initially');
60-
61-
// 2. Create the new page file
62-
await fs.promises.writeFile(newPagePath, NEW_PAGE_CONTENT, 'utf-8');
53+
it('should detect a new page without server restart', {
54+
skip: isWindows,
55+
todo: 'I hangs on windows',
56+
}, async () => {
57+
// 1. Verify the page doesn't exist yet
58+
let response = await fixture.fetch('/new-page');
59+
assert.equal(response.status, 404, 'Page should not exist initially');
60+
61+
// 2. Create the new page file
62+
await fs.promises.writeFile(newPagePath, NEW_PAGE_CONTENT, 'utf-8');
63+
64+
// 3. Wait for HMR to process the change
65+
await new Promise((resolve) => setTimeout(resolve, 2000));
66+
67+
// 4. Verify the new page is now accessible
68+
response = await fixture.fetch('/new-page');
69+
assert.equal(response.status, 200, 'Page should be accessible after creation');
70+
71+
const html = await response.text();
72+
assert.ok(html.includes('New Page Created via HMR'), 'Page content should match');
73+
});
6374

64-
// 3. Wait for HMR to process the change
75+
it('should detect page removal without server restart', {
76+
skip: isWindows,
77+
todo: 'I hangs on windows',
78+
}, async () => {
79+
// Ensure the page exists first (from previous test or create it)
80+
if (!fs.existsSync(newPagePath)) {
81+
await fs.promises.writeFile(newPagePath, NEW_PAGE_CONTENT, 'utf-8');
6582
await new Promise((resolve) => setTimeout(resolve, 2000));
83+
}
6684

67-
// 4. Verify the new page is now accessible
68-
response = await fixture.fetch('/new-page');
69-
assert.equal(response.status, 200, 'Page should be accessible after creation');
70-
71-
const html = await response.text();
72-
assert.ok(html.includes('New Page Created via HMR'), 'Page content should match');
73-
},
74-
);
75-
76-
it(
77-
'should detect page removal without server restart',
78-
{ skip: isWindows, todo: 'I hangs on windows' },
79-
async () => {
80-
// Ensure the page exists first (from previous test or create it)
81-
if (!fs.existsSync(newPagePath)) {
82-
await fs.promises.writeFile(newPagePath, NEW_PAGE_CONTENT, 'utf-8');
83-
await new Promise((resolve) => setTimeout(resolve, 2000));
84-
}
85-
86-
// 1. Verify the page is accessible
87-
let response = await fixture.fetch('/new-page');
88-
assert.equal(response.status, 200, 'Page should exist before deletion');
89-
90-
// 2. Delete the page file
91-
await fs.promises.unlink(newPagePath);
85+
// 1. Verify the page is accessible
86+
let response = await fixture.fetch('/new-page');
87+
assert.equal(response.status, 200, 'Page should exist before deletion');
9288

93-
// 3. Wait for HMR to process the change
94-
await new Promise((resolve) => setTimeout(resolve, 2000));
89+
// 2. Delete the page file
90+
await fs.promises.unlink(newPagePath);
9591

96-
// 4. Verify the page now returns 404
97-
response = await fixture.fetch('/new-page');
98-
assert.equal(response.status, 404, 'Page should return 404 after deletion');
99-
},
100-
);
92+
// 3. Wait for HMR to process the change
93+
await new Promise((resolve) => setTimeout(resolve, 2000));
94+
95+
// 4. Verify the page now returns 404
96+
response = await fixture.fetch('/new-page');
97+
assert.equal(response.status, 404, 'Page should return 404 after deletion');
98+
});
10199
});

0 commit comments

Comments
 (0)