Skip to content

Commit 5bae926

Browse files
committed
Don't use the console in prodution
1 parent 6d6c801 commit 5bae926

File tree

7 files changed

+19
-14
lines changed

7 files changed

+19
-14
lines changed

src/components/Svg/TextPath.tsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,10 @@ export default class TextPath extends React.Component<Props> {
1212
render() {
1313
if (!this.props.href || !this.props.href.match(idExpReg)) {
1414
// eslint-disable-next-line no-console
15-
console.warn(
16-
`Invalid \`href\` prop for \`TextPath\` element, expected a href like \`"#id"\`, but got: "${this.props.href}"`,
17-
);
15+
if (process.env.NODE_ENV !== 'production')
16+
console.warn(
17+
`Invalid \`href\` prop for \`TextPath\` element, expected a href like \`"#id"\`, but got: "${this.props.href}"`,
18+
);
1819
}
1920

2021
const { children, ...rest } = this.props;

src/components/Svg/Use.tsx

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,11 @@ export default class Use extends React.Component<Props> {
2222
const matched = href.match(idExpReg);
2323

2424
if (!href || !matched) {
25-
// eslint-disable-next-line no-console
26-
console.warn(
27-
`Invalid \`href\` prop for \`Use\` element, expected a href like \`"#id"\`, but got: "${href}"`,
28-
);
25+
if (process.env.NODE_ENV !== 'production')
26+
// eslint-disable-next-line no-console
27+
console.warn(
28+
`Invalid \`href\` prop for \`Use\` element, expected a href like \`"#id"\`, but got: "${href}"`,
29+
);
2930
}
3031
const { children, ...rest } = this.props;
3132
return <svg_use {...rest}>{children}</svg_use>;

src/jsonUtils/sketchJson/convertJsonToSketch.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ export default function convertJsonToSketch(
2323
);
2424

2525
if (err.value() !== null) {
26-
console.error(err.value());
26+
if (process.env.NODE_ENV !== 'production') console.error(err.value());
2727
throw new Error(err.value());
2828
}
2929

src/jsonUtils/sketchJson/convertSketchToJson.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ export default function convertSketchToJson(
1313
const data = MSJSONDataArchiver.archiveStringWithRootObject_error(imm, err);
1414

1515
if (err.value() !== null) {
16-
console.error(err.value());
16+
if (process.env.NODE_ENV !== 'production') console.error(err.value());
1717
throw new Error(err.value());
1818
}
1919

src/render.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -141,8 +141,9 @@ export default async function render(
141141
const layer = await renderTree(tree, nativeContainer, platformBridge);
142142
return layer;
143143
} catch (err) {
144-
// eslint-disable-next-line no-console
145-
console.error(err);
144+
if (process.env.NODE_ENV !== 'production')
145+
// eslint-disable-next-line no-console
146+
console.error(err);
146147
const tree = buildTree(<RedBox error={err} />, platformBridge);
147148
return renderContents(tree, nativeContainer, platformBridge);
148149
}

src/symbol.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,8 @@ export const injectSymbols = (
6969
document?: SketchDocumentData | SketchDocument | WrappedSketchDocument,
7070
) => {
7171
if (!isRunningInSketch()) {
72-
console.error('Cannot inject symbols while Sketch is not running');
72+
if (process.env.NODE_ENV !== 'production')
73+
console.error('Cannot inject symbols while Sketch is not running');
7374
return;
7475
}
7576

src/utils/processTransform/parseTransformProp.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -168,8 +168,9 @@ function appendTransform(transform: string) {
168168
const [a, c, e, b, d, f] = transformParser.parse(transform);
169169
pooledMatrix.append(a, b, c, d, e, f);
170170
} catch (e) {
171-
// eslint-disable-next-line no-console
172-
console.error(e);
171+
if (process.env.NODE_ENV !== 'production')
172+
// eslint-disable-next-line no-console
173+
console.error(e);
173174
}
174175
}
175176

0 commit comments

Comments
 (0)