Skip to content

Commit

Permalink
refactor: use NODE_ENV variable
Browse files Browse the repository at this point in the history
  • Loading branch information
juanrgm committed Mar 25, 2022
1 parent 0ce3e5b commit 5b6b816
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 8 deletions.
7 changes: 7 additions & 0 deletions .changeset/shiny-nails-kiss.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
"@suid/material": patch
"@suid/site": patch
"@suid/system": patch
---

Use `NODE_ENV` variable
2 changes: 1 addition & 1 deletion packages/material/src/ButtonBase/ButtonBase.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,7 @@ const ButtonBase = $.component(function ButtonBase({
const enableTouchRipple = () =>
mountedState() && !props.disableRipple && !props.disabled;

if ((globalThis as any).ENV !== "production") {
if (process.env.NODE_ENV !== "production") {
createEffect(() => {
if (enableTouchRipple() && !ripple.ref) {
console.error(
Expand Down
2 changes: 1 addition & 1 deletion packages/material/src/Paper/Paper.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ const Paper = $.component(function Paper({
otherProps,
classes,
}) {
if ((globalThis as any).ENV !== "production") {
if (process.env.NODE_ENV !== "production") {
const theme = useTheme();
if (theme.shadows[props.elevation as keyof Shadows] === undefined) {
console.error(
Expand Down
2 changes: 1 addition & 1 deletion packages/material/src/styles/createTransitions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ export default function createTransitions(inputTransitions: {
...other
} = options;

if ((globalThis as any).ENV !== "production") {
if (process.env.NODE_ENV !== "production") {
const isString = (value: unknown) => typeof value === "string";
// IE11 support, replace with Number.isNaN
// eslint-disable-next-line no-restricted-globals
Expand Down
2 changes: 1 addition & 1 deletion packages/material/src/utils/useControlled.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export default function useControlled<T>(props: UseControlledProps<T>) {
isControlled ? props.controlled : valueState()
);

if ((globalThis as any).ENV !== "production") {
if (process.env.NODE_ENV !== "production") {
createEffect(() => {
if (isControlled !== (props.controlled !== undefined)) {
console.error(
Expand Down
2 changes: 1 addition & 1 deletion packages/system/src/colorManipulator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* @returns {number} A number in the range [min, max]
*/
function clamp(value: number, min = 0, max = 1) {
if ((globalThis as any).ENV !== "production") {
if (process.env.NODE_ENV !== "production") {
if (value < min || value > max) {
console.error(
`MUI: The value provided ${value} is out of range [${min}, ${max}].`
Expand Down
6 changes: 3 additions & 3 deletions packages/system/src/spacing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export function createUnaryUnit(
return abs;
}

if ((globalThis as any).ENV !== "production") {
if (process.env.NODE_ENV !== "production") {
if (typeof abs !== "number") {
console.error(
`MUI: Expected ${propName} argument to be a number or a string, got ${abs}.`
Expand All @@ -41,7 +41,7 @@ export function createUnaryUnit(
return abs;
}

if ((globalThis as any).ENV !== "production") {
if (process.env.NODE_ENV !== "production") {
if (!Number.isInteger(abs)) {
console.error(
[
Expand Down Expand Up @@ -70,7 +70,7 @@ export function createUnaryUnit(
return themeSpacing;
}

if ((globalThis as any).ENV !== "production") {
if (process.env.NODE_ENV !== "production") {
console.error(
[
`MUI: The \`theme.${themeKey}\` value (${themeSpacing}) is invalid.`,
Expand Down

0 comments on commit 5b6b816

Please sign in to comment.