Skip to content

Commit a3c037b

Browse files
committed
Change ''.concat(value) to String(value)
`''.concat(value)` violates current Flow definitons that require args to concat to be strings only, even though the MDN docs and ES spec allow args to be any type. See facebook/flow#8728. To avoid depending on a change to Flow, this commit changes `''.concat(value)` to `String(value)` and removes the lint rule that prohibits use of String(value). This rule was added in facebook#9082. The other rules in that PR (for Boolean and Number constructors) are not changed in this commit, only the rule for String. If it's decided that using `concat` is better, simply omit this commit and use the previous one instead.
1 parent fa75406 commit a3c037b

File tree

55 files changed

+124
-161
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

55 files changed

+124
-161
lines changed

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

Lines 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: {''.concat(this.state.error)}</p>;
44+
return <p>Captured an error: {String(this.state.error)}</p>;
4545
}
4646
}
4747
if (this.state.shouldThrow) {

fixtures/legacy-jsx-runtimes/react-14/cjs/react-jsx-dev-runtime.development.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ function printWarning(level, format, args) {
104104
}
105105

106106
var argsWithFormat = args.map(function (item) {
107-
return ''.concat(item);
107+
return String(item);
108108
}); // Careful: RN currently depends on this prefix
109109

110110
argsWithFormat.unshift('Warning: ' + format); // We intentionally don't use spread (or .apply) directly because it
@@ -483,11 +483,11 @@ function jsxDEV(type, config, maybeKey, source, self) {
483483
// key is explicitly declared to be undefined or not.
484484

485485
if (maybeKey !== undefined) {
486-
key = ''.concat(maybeKey);
486+
key = String(maybeKey);
487487
}
488488

489489
if (hasValidKey(config)) {
490-
key = ''.concat(config.key);
490+
key = String(config.key);
491491
}
492492

493493
if (hasValidRef(config)) {

fixtures/legacy-jsx-runtimes/react-14/cjs/react-jsx-runtime.development.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ function printWarning(level, format, args) {
103103
}
104104

105105
var argsWithFormat = args.map(function (item) {
106-
return ''.concat(item);
106+
return String(item);
107107
}); // Careful: RN currently depends on this prefix
108108

109109
argsWithFormat.unshift('Warning: ' + format); // We intentionally don't use spread (or .apply) directly because it
@@ -487,11 +487,11 @@ function jsxDEV(type, config, maybeKey, source, self) {
487487
// key is explicitly declared to be undefined or not.
488488

489489
if (maybeKey !== undefined) {
490-
key = ''.concat(maybeKey);
490+
key = String(maybeKey);
491491
}
492492

493493
if (hasValidKey(config)) {
494-
key = ''.concat(config.key);
494+
key = String(config.key);
495495
}
496496

497497
if (hasValidRef(config)) {

fixtures/legacy-jsx-runtimes/react-15/cjs/react-jsx-dev-runtime.development.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ function printWarning(level, format, args) {
109109
}
110110

111111
var argsWithFormat = args.map(function (item) {
112-
return ''.concat(item);
112+
return String(item);
113113
}); // Careful: RN currently depends on this prefix
114114

115115
argsWithFormat.unshift('Warning: ' + format); // We intentionally don't use spread (or .apply) directly because it
@@ -488,11 +488,11 @@ function jsxDEV(type, config, maybeKey, source, self) {
488488
// key is explicitly declared to be undefined or not.
489489

490490
if (maybeKey !== undefined) {
491-
key = ''.concat(maybeKey);
491+
key = String(maybeKey);
492492
}
493493

494494
if (hasValidKey(config)) {
495-
key = ''.concat(config.key);
495+
key = String(config.key);
496496
}
497497

498498
if (hasValidRef(config)) {

fixtures/legacy-jsx-runtimes/react-15/cjs/react-jsx-runtime.development.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ function printWarning(level, format, args) {
108108
}
109109

110110
var argsWithFormat = args.map(function (item) {
111-
return ''.concat(item);
111+
return String(item);
112112
}); // Careful: RN currently depends on this prefix
113113

114114
argsWithFormat.unshift('Warning: ' + format); // We intentionally don't use spread (or .apply) directly because it
@@ -492,11 +492,11 @@ function jsxDEV(type, config, maybeKey, source, self) {
492492
// key is explicitly declared to be undefined or not.
493493

494494
if (maybeKey !== undefined) {
495-
key = ''.concat(maybeKey);
495+
key = String(maybeKey);
496496
}
497497

498498
if (hasValidKey(config)) {
499-
key = ''.concat(config.key);
499+
key = String(config.key);
500500
}
501501

502502
if (hasValidRef(config)) {

fixtures/legacy-jsx-runtimes/react-16/cjs/react-jsx-dev-runtime.development.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ function printWarning(level, format, args) {
115115
}
116116

117117
var argsWithFormat = args.map(function (item) {
118-
return ''.concat(item);
118+
return String(item);
119119
}); // Careful: RN currently depends on this prefix
120120

121121
argsWithFormat.unshift('Warning: ' + format); // We intentionally don't use spread (or .apply) directly because it
@@ -509,11 +509,11 @@ function jsxDEV(type, config, maybeKey, source, self) {
509509
// key is explicitly declared to be undefined or not.
510510

511511
if (maybeKey !== undefined) {
512-
key = ''.concat(maybeKey);
512+
key = String(maybeKey);
513513
}
514514

515515
if (hasValidKey(config)) {
516-
key = ''.concat(config.key);
516+
key = String(config.key);
517517
}
518518

519519
if (hasValidRef(config)) {

fixtures/legacy-jsx-runtimes/react-16/cjs/react-jsx-runtime.development.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ function printWarning(level, format, args) {
114114
}
115115

116116
var argsWithFormat = args.map(function (item) {
117-
return ''.concat(item);
117+
return String(item);
118118
}); // Careful: RN currently depends on this prefix
119119

120120
argsWithFormat.unshift('Warning: ' + format); // We intentionally don't use spread (or .apply) directly because it
@@ -513,11 +513,11 @@ function jsxDEV(type, config, maybeKey, source, self) {
513513
// key is explicitly declared to be undefined or not.
514514

515515
if (maybeKey !== undefined) {
516-
key = ''.concat(maybeKey);
516+
key = String(maybeKey);
517517
}
518518

519519
if (hasValidKey(config)) {
520-
key = ''.concat(config.key);
520+
key = String(config.key);
521521
}
522522

523523
if (hasValidRef(config)) {

fixtures/legacy-jsx-runtimes/react-17/cjs/react-jsx-dev-runtime.development.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ function printWarning(level, format, args) {
107107
}
108108

109109
var argsWithFormat = args.map(function (item) {
110-
return ''.concat(item);
110+
return String(item);
111111
}); // Careful: RN currently depends on this prefix
112112

113113
argsWithFormat.unshift('Warning: ' + format); // We intentionally don't use spread (or .apply) directly because it
@@ -815,11 +815,11 @@ function jsxDEV(type, config, maybeKey, source, self) {
815815
// key is explicitly declared to be undefined or not.
816816

817817
if (maybeKey !== undefined) {
818-
key = ''.concat(maybeKey);
818+
key = String(maybeKey);
819819
}
820820

821821
if (hasValidKey(config)) {
822-
key = ''.concat(config.key);
822+
key = String(config.key);
823823
}
824824

825825
if (hasValidRef(config)) {

fixtures/legacy-jsx-runtimes/react-17/cjs/react-jsx-runtime.development.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ function printWarning(level, format, args) {
107107
}
108108

109109
var argsWithFormat = args.map(function (item) {
110-
return ''.concat(item);
110+
return String(item);
111111
}); // Careful: RN currently depends on this prefix
112112

113113
argsWithFormat.unshift('Warning: ' + format); // We intentionally don't use spread (or .apply) directly because it
@@ -815,11 +815,11 @@ function jsxDEV(type, config, maybeKey, source, self) {
815815
// key is explicitly declared to be undefined or not.
816816

817817
if (maybeKey !== undefined) {
818-
key = ''.concat(maybeKey);
818+
key = String(maybeKey);
819819
}
820820

821821
if (hasValidKey(config)) {
822-
key = ''.concat(config.key);
822+
key = String(config.key);
823823
}
824824

825825
if (hasValidRef(config)) {

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ function createPanelIfReactLoaded() {
8282

8383
function initBridgeAndStore() {
8484
const port = chrome.runtime.connect({
85-
name: ''.concat(tabId),
85+
name: String(tabId),
8686
});
8787
// Looks like `port.onDisconnect` does not trigger on in-tab navigation like new URL or back/forward navigation,
8888
// so it makes no sense to handle it here.

0 commit comments

Comments
 (0)