Skip to content

Commit 9a08cbd

Browse files
committed
chore: fix eslint problems in starters
1 parent 68ca2ef commit 9a08cbd

File tree

9 files changed

+116
-3
lines changed

9 files changed

+116
-3
lines changed

starters/apps/e2e/src/components/computed/computed.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
/* eslint-disable */
21
import { component$, useComputed$, useSignal, useTask$ } from "@qwik.dev/core";
32

43
export const ComputedRoot = component$(() => {

starters/apps/playground/src/routes/demo/flower/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import {
55
useStylesScoped$,
66
useVisibleTask$,
77
} from "@qwik.dev/core";
8+
// @ts-ignore-next-line not sure why this is not working
89
import styles from "./flower.css?inline";
910

1011
export default component$(() => {
@@ -16,7 +17,6 @@ export default component$(() => {
1617
number: 20,
1718
});
1819

19-
// eslint-disable-next-line qwik/no-use-visible-task
2020
useVisibleTask$(({ cleanup }) => {
2121
const timeout = setTimeout(() => (state.count = 1), 500);
2222
cleanup(() => clearTimeout(timeout));
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
{
2+
"compilerOptions": {
3+
"allowJs": true,
4+
"target": "ES2017",
5+
"module": "ES2022",
6+
"lib": ["es2022", "DOM", "WebWorker", "DOM.Iterable"],
7+
"jsx": "react-jsx",
8+
"jsxImportSource": "@qwik.dev/core",
9+
"strict": true,
10+
"forceConsistentCasingInFileNames": true,
11+
"resolveJsonModule": true,
12+
"moduleResolution": "Bundler",
13+
"esModuleInterop": true,
14+
"skipLibCheck": true,
15+
"incremental": true,
16+
"isolatedModules": true,
17+
"outDir": "tmp",
18+
"noEmit": true,
19+
"paths": {
20+
"~/*": ["./src/*"],
21+
"~components/*": ["./src/components/*"]
22+
}
23+
},
24+
"include": ["src", "./*.d.ts", "./*.config.ts"]
25+
}
Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
/**
2+
* This is the base config for vite.
3+
* When building, the adapter config is used which loads this file and extends it.
4+
*/
5+
import { defineConfig, type UserConfig, type Plugin } from "vite";
6+
import { qwikVite } from "@qwik.dev/core/optimizer";
7+
import { qwikCity } from "@qwik.dev/router/vite";
8+
import crypto from "crypto";
9+
import tsconfigPaths from "vite-tsconfig-paths";
10+
import basicSsl from "@vitejs/plugin-basic-ssl";
11+
/**
12+
* Note that Vite normally starts from `index.html` but the qwikCity plugin makes start at `src/entry.ssr.tsx` instead.
13+
*/
14+
function createBulkPlugin(): Plugin {
15+
return {
16+
name: "add-bulk-and-track",
17+
transform(code, id) {
18+
// Only process JavaScript/TypeScript files
19+
if (!id.match(/(\.[cm]?[jt]sx?$|@qwik)/)) {
20+
return null;
21+
}
22+
23+
// Generate deterministic bulk based on filename
24+
const hash = crypto.createHash("sha256").update(id).digest();
25+
26+
// Create bulk with an exponential-like distribution between 0kb and 50kb
27+
// Most files will be closer to 0kb, with a few reaching 50kb
28+
const maxSize = 500;
29+
const x = hash[0] / 255; // Normalize first byte to 0-1
30+
const exp = Math.pow(x, 6); // Skew distribution
31+
const bulkSize = Math.floor(maxSize * exp);
32+
33+
// Create repeatable random bulk using the hash as seed
34+
const prng = crypto.createHash("sha512").update(id).digest();
35+
const bulk = Array.from({ length: Math.ceil(bulkSize / 64) }, (_, i) => {
36+
// Use the hash as a seed to generate new random blocks
37+
const block = crypto
38+
.createHash("sha512")
39+
.update(prng)
40+
.update(Buffer.from([i]))
41+
.digest("base64");
42+
return block;
43+
}).join("");
44+
45+
// Add tracking code and bulk assignment at the start of each module
46+
const trackingCode = `
47+
console.log(">>> running", ${JSON.stringify(id)});
48+
;(globalThis._loaded||=[]).push(${JSON.stringify(id)});
49+
`;
50+
const bulkCode = `
51+
globalThis._fakeBulk?.(${JSON.stringify(bulk)});
52+
`;
53+
54+
return {
55+
/** Note that this code is injected before the import statements which is technically incorrect but Vite handles it */
56+
code: `${trackingCode}\n${code}\n${bulkCode}`,
57+
map: null,
58+
};
59+
},
60+
};
61+
}
62+
63+
export default defineConfig((): UserConfig => {
64+
return {
65+
plugins: [
66+
qwikCity(),
67+
qwikVite({ debug: true }),
68+
createBulkPlugin(),
69+
tsconfigPaths({ root: "." }),
70+
basicSsl(),
71+
],
72+
build: {
73+
minify: false,
74+
rollupOptions: {
75+
output: {
76+
manualChunks: (id) => {
77+
// Put library code in separate chunks
78+
if (id.includes("vendor-lib")) {
79+
return id;
80+
}
81+
},
82+
},
83+
},
84+
},
85+
};
86+
});

starters/apps/preloader-test/src/components/generated/show-dynamic.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ export default component$(() => {
88
<button
99
onClick$={() => {
1010
showDynamic.value = true;
11+
// eslint-disable-next-line no-console
1112
console.log(
1213
`
1314
************************************************

starters/apps/preloader-test/src/routes/counters/index.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,7 @@ export default component$(() => {
215215
<Counter100 />
216216
<Link
217217
href="/hidden"
218+
// eslint-disable-next-line no-console
218219
onQVisible$={() => console.log("visible below fold")}
219220
>
220221
Home

starters/apps/preloader-test/src/routes/index.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
/* eslint-disable no-console */
21
import {
32
component$,
43
useTask$,

starters/apps/preloader-test/src/routes/layout.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ export default component$(() => {
6969
<LinkCmp href="/about">About</LinkCmp>
7070
<LinkCmp
7171
href="/counters"
72+
// eslint-disable-next-line no-console
7273
onQVisible$={() => console.log("visible")}
7374
>
7475
Counters

starters/apps/qwikrouter-test/src/routes/location-path/[id]/layout.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ export default component$(() => {
1010
// should not happen
1111
throw new Error("id is undefined");
1212
}
13+
// eslint-disable-next-line no-console
1314
console.log("location path id", id);
1415
});
1516
return (

0 commit comments

Comments
 (0)