Skip to content

Commit 3b3f901

Browse files
committed
refactor: update dev mode console warn
1 parent c0364b1 commit 3b3f901

File tree

2 files changed

+5
-13
lines changed

2 files changed

+5
-13
lines changed

packages/solid-uplot/src/SolidUplot.tsx

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,7 @@ import type { SolidUplotPluginBus, UplotPluginFactory, VoidStruct } from "./crea
1818
import { createCursorMovePlugin, type OnCursorMoveParams } from "./eventPlugins";
1919
import { getSeriesData, type SeriesDatum } from "./utils/getSeriesData";
2020

21-
const __DEV__ = (() => {
22-
try {
23-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
24-
const g = globalThis as any;
25-
return g.process?.env?.NODE_ENV !== "production";
26-
} catch {
27-
return false;
28-
}
29-
})();
21+
const __DEV__ = import.meta.env.DEV;
3022

3123
/** Placement options for children components relative to the chart */
3224
type ChildrenPlacement = "top" | "bottom";
@@ -277,12 +269,12 @@ export const SolidUplot = <T extends VoidStruct = VoidStruct>(
277269
for (const entry of entries) {
278270
const { width, height } = entry.contentRect;
279271

280-
if (!hasWarnedZeroHeight && height === 0 && __DEV__) {
272+
if (height === 0 && !hasWarnedZeroHeight && __DEV__) {
281273
hasWarnedZeroHeight = true;
282274
console.warn(
283275
"[SolidUplot] autoResize observed 0px height. " +
284-
"Ensure the parent container has an explicit height " +
285-
"or is within a flex/grid layout that provides height.",
276+
"Ensure the parent container has an explicit height " +
277+
"or is within a flex/grid layout that provides height.",
286278
);
287279
}
288280

packages/solid-uplot/tsconfig.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"extends": "@dschz/tsconfig/solid.json",
33
"compilerOptions": {
4-
"types": ["@testing-library/jest-dom"]
4+
"types": ["@testing-library/jest-dom", "vite/client"]
55
},
66
"include": ["src/**/*.ts", "src/**/*.tsx", "*.ts", "*.tsx"],
77
"exclude": ["dist", "node_modules"]

0 commit comments

Comments
 (0)