GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Improve DEV errors if string coercion throws (Temporal.*, Symbol, etc… · react/react@c88fb49

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • .eslintrc.js
  • dangerfile.js
  • fixtures/dom/src/components/fixtures/error-handling
    • index.js
  • packages
    • react-debug-tools/src/__tests__
      • ReactHooksInspectionIntegration-test.js
    • react-devtools-extensions/src
      • main.js
    • react-devtools-shared/src
      • backend
        • legacy
          • renderer.js
        • renderer.js
        • utils.js
      • devtools/views
        • ErrorBoundary
          • ErrorBoundary.js
        • utils.js
      • hook.js
      • hooks
        • SourceMapMetadataConsumer.js
      • utils.js
    • react-dom/src
      • __tests__
        • ReactDOMAttribute-test.js
        • ReactDOMComponent-test.js
        • ReactDOMInput-test.js
        • ReactDOMSelect-test.js
        • ReactDOMServerIntegrationHooks-test.js
        • ReactDOMServerIntegrationUntrustedURL-test.internal.js
        • ReactDOMTextComponent-test.js
        • ReactDOMTextarea-test.js
        • ReactIdentity-test.js
        • ReactMultiChildText-test.js
      • client
        • DOMPropertyOperations.js
        • ReactDOMComponent.js
        • ReactDOMInput.js
        • ToStringValue.js
        • inputValueTracking.js
      • server
        • DOMMarkupOperations.js
        • ReactDOMServerFormatConfig.js
        • ReactPartialRenderer.js
        • escapeTextForBrowser.js
      • shared
        • dangerousStyleValue.js
      • test-utils
        • ReactTestUtils.js
    • react-noop-renderer/src
      • createReactNoop.js
    • react-reconciler/src
      • ReactChildFiber.new.js
      • ReactChildFiber.old.js
      • ReactPortal.js
      • __tests__
        • ReactCache-test.js
        • ReactHooksWithNoopRenderer-test.js
        • ReactIncremental-test.js
        • ReactMemo-test.js
        • ReactPersistent-test.js
    • react-server/src
      • ReactFlightServer.js
    • react-test-renderer/src
      • ReactTestRenderer.js
    • react/src
      • ReactChildren.js
      • ReactElement.js
      • jsx
        • ReactJSXElement.js
    • shared
      • CheckStringCoercion.js
      • consoleWithStackDev.js
  • scripts
    • eslint-rules
      • __tests__
        • no-primitive-constructors-test.internal.js
        • safe-string-coercion-test.internal.js
      • index.js
      • no-primitive-constructors.js
      • safe-string-coercion.js
    • flow
      • runFlow.js
    • merge-fork
      • merge-fork.js
    • rollup
      • build-all-release-channels.js

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Dismiss banner
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎.eslintrc.js‎

Copy file name to clipboardExpand all lines: .eslintrc.js
+12-1Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,10 @@ module.exports = {
108108
// CUSTOM RULES
109109
// the second argument of warning/invariant should be a literal string
110110
'react-internal/no-primitive-constructors': ERROR,
111+
'react-internal/safe-string-coercion': [
112+
ERROR,
113+
{isProductionUserAppCode: true},
114+
],
111115
'react-internal/no-to-warn-dev-within-to-throw': ERROR,
112116
'react-internal/invariant-args': ERROR,
113117
'react-internal/warning-args': ERROR,
@@ -168,10 +172,17 @@ module.exports = {
168172
'packages/*/npm/**/*.js',
169173
'packages/dom-event-testing-library/**/*.js',
170174
'packages/react-devtools*/**/*.js',
175+
'dangerfile.js',
176+
'fixtures',
177+
'packages/react-dom/src/test-utils/*.js',
171178
],
172179
rules: {
173180
'react-internal/no-production-logging': OFF,
174181
'react-internal/warning-args': OFF,
182+
'react-internal/safe-string-coercion': [
183+
ERROR,
184+
{isProductionUserAppCode: false},
185+
],
175186

176187
// Disable accessibility checks
177188
'jsx-a11y/aria-role': OFF,
@@ -185,7 +196,7 @@ module.exports = {
185196
{
186197
files: [
187198
'scripts/eslint-rules/*.js',
188-
'packages/eslint-plugin-react-hooks/src/*.js'
199+
'packages/eslint-plugin-react-hooks/src/*.js',
189200
],
190201
plugins: ['eslint-plugin'],
191202
rules: {
Collapse file

‎dangerfile.js‎

Copy file name to clipboardExpand all lines: dangerfile.js
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,8 +102,8 @@ function row(result) {
102102
let headSha;
103103
let baseSha;
104104
try {
105-
headSha = (readFileSync(HEAD_DIR + '/COMMIT_SHA') + '').trim();
106-
baseSha = (readFileSync(BASE_DIR + '/COMMIT_SHA') + '').trim();
105+
headSha = String(readFileSync(HEAD_DIR + '/COMMIT_SHA')).trim();
106+
baseSha = String(readFileSync(BASE_DIR + '/COMMIT_SHA')).trim();
107107
} catch {
108108
warn(
109109
"Failed to read build artifacts. It's possible a build configuration " +
Collapse file

‎fixtures/dom/src/components/fixtures/error-handling/index.js‎

Copy file name to clipboardExpand all lines: fixtures/dom/src/components/fixtures/error-handling/index.js
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ class ErrorBoundary extends React.Component {
4141
if (this.state.error) {
4242
return <p>Captured an error: {this.state.error.message}</p>;
4343
} else {
44-
return <p>Captured an error: {'' + this.state.error}</p>;
44+
return <p>Captured an error: {String(this.state.error)}</p>;
4545
}
4646
}
4747
if (this.state.shouldThrow) {
Collapse file

‎packages/react-debug-tools/src/__tests__/ReactHooksInspectionIntegration-test.js‎

Copy file name to clipboardExpand all lines: packages/react-debug-tools/src/__tests__/ReactHooksInspectionIntegration-test.js
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -615,7 +615,7 @@ describe('ReactHooksInspectionIntegration', () => {
615615
expect(tree[0].id).toEqual(0);
616616
expect(tree[0].isStateEditable).toEqual(false);
617617
expect(tree[0].name).toEqual('OpaqueIdentifier');
618-
expect((tree[0].value + '').startsWith('c_')).toBe(true);
618+
expect(String(tree[0].value).startsWith('c_')).toBe(true);
619619

620620
expect(tree[1]).toEqual({
621621
id: 1,
@@ -646,7 +646,7 @@ describe('ReactHooksInspectionIntegration', () => {
646646
expect(tree[0].id).toEqual(0);
647647
expect(tree[0].isStateEditable).toEqual(false);
648648
expect(tree[0].name).toEqual('OpaqueIdentifier');
649-
expect((tree[0].value + '').startsWith('c_')).toBe(true);
649+
expect(String(tree[0].value).startsWith('c_')).toBe(true);
650650

651651
expect(tree[1]).toEqual({
652652
id: 1,
Collapse file

‎packages/react-devtools-extensions/src/main.js‎

Copy file name to clipboardExpand all lines: packages/react-devtools-extensions/src/main.js
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ function createPanelIfReactLoaded() {
9494

9595
function initBridgeAndStore() {
9696
const port = chrome.runtime.connect({
97-
name: '' + tabId,
97+
name: String(tabId),
9898
});
9999
// Looks like `port.onDisconnect` does not trigger on in-tab navigation like new URL or back/forward navigation,
100100
// so it makes no sense to handle it here.
Collapse file

‎packages/react-devtools-shared/src/backend/legacy/renderer.js‎

Copy file name to clipboardExpand all lines: packages/react-devtools-shared/src/backend/legacy/renderer.js
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ function getData(internalInstance: InternalInstance) {
6363
// != used deliberately here to catch undefined and null
6464
if (internalInstance._currentElement != null) {
6565
if (internalInstance._currentElement.key) {
66-
key = '' + internalInstance._currentElement.key;
66+
key = String(internalInstance._currentElement.key);
6767
}
6868

6969
const elementType = internalInstance._currentElement.type;
Collapse file

‎packages/react-devtools-shared/src/backend/renderer.js‎

Copy file name to clipboardExpand all lines: packages/react-devtools-shared/src/backend/renderer.js
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1848,7 +1848,7 @@ export function attach(
18481848

18491849
// This check is a guard to handle a React element that has been modified
18501850
// in such a way as to bypass the default stringification of the "key" property.
1851-
const keyString = key === null ? null : '' + key;
1851+
const keyString = key === null ? null : String(key);
18521852
const keyStringID = getStringID(keyString);
18531853

18541854
pushOperation(TREE_OPERATION_ADD);
Collapse file

‎packages/react-devtools-shared/src/backend/utils.js‎

Copy file name to clipboardExpand all lines: packages/react-devtools-shared/src/backend/utils.js
+3-10Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -166,11 +166,7 @@ export function format(
166166
): string {
167167
const args = inputArgs.slice();
168168

169-
// Symbols cannot be concatenated with Strings.
170-
let formatted: string =
171-
typeof maybeMessage === 'symbol'
172-
? maybeMessage.toString()
173-
: '' + maybeMessage;
169+
let formatted: string = String(maybeMessage);
174170

175171
// If the first argument is a string, check for substitutions.
176172
if (typeof maybeMessage === 'string') {
@@ -203,17 +199,14 @@ export function format(
203199
// Arguments that remain after formatting.
204200
if (args.length) {
205201
for (let i = 0; i < args.length; i++) {
206-
const arg = args[i];
207-
208-
// Symbols cannot be concatenated with Strings.
209-
formatted += ' ' + (typeof arg === 'symbol' ? arg.toString() : arg);
202+
formatted += ' ' + String(args[i]);
210203
}
211204
}
212205

213206
// Update escaped %% values.
214207
formatted = formatted.replace(/%{2,2}/g, '%');
215208

216-
return '' + formatted;
209+
return String(formatted);
217210
}
218211

219212
export function isSynchronousXHRSupported(): boolean {
Collapse file

‎packages/react-devtools-shared/src/devtools/views/ErrorBoundary/ErrorBoundary.js‎

Copy file name to clipboardExpand all lines: packages/react-devtools-shared/src/devtools/views/ErrorBoundary/ErrorBoundary.js
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ export default class ErrorBoundary extends Component<Props, State> {
4646
error !== null &&
4747
error.hasOwnProperty('message')
4848
? error.message
49-
: '' + error;
49+
: String(error);
5050

5151
const callStack =
5252
typeof error === 'object' &&
Collapse file

‎packages/react-devtools-shared/src/devtools/views/utils.js‎

Copy file name to clipboardExpand all lines: packages/react-devtools-shared/src/devtools/views/utils.js
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ export function alphaSortEntries(
1919
): number {
2020
const a = entryA[0];
2121
const b = entryB[0];
22-
if ('' + +a === a) {
23-
if ('' + +b !== b) {
22+
if (String(+a) === a) {
23+
if (String(+b) !== b) {
2424
return -1;
2525
}
2626
return +a < +b ? -1 : 1;

0 commit comments

Comments
0 (0)
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.