Skip to content

Commit c72e8c7

Browse files
rubennortemeta-codesync[bot]
authored andcommitted
Make Blob/File/URL modules Flow strict-local (#57728)
Summary: Pull Request resolved: #57728 Upgrade the Blob-related modules (`File`, `FileReader`, `URL`, `URLSearchParams`) from `flow` to `flow strict-local`. These expose spec-mandated getters/setters, so they opt out of the `unsafe-getters-setters` lint with a scoped `// flowlint unsafe-getters-setters:off` directive. `URL` also received small behavior-preserving refactors (local variables instead of parameter reassignment, explicit null/empty checks). Changelog: [Internal] Reviewed By: javache Differential Revision: D113763778 fbshipit-source-id: 1e0ceb02270d458fae6b89886ae41d9893ae7329
1 parent 1a7c318 commit c72e8c7

5 files changed

Lines changed: 20 additions & 10 deletions

File tree

packages/react-native/Libraries/Blob/File.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,12 @@
44
* This source code is licensed under the MIT license found in the
55
* LICENSE file in the root directory of this source tree.
66
*
7-
* @flow
7+
* @flow strict-local
88
* @format
99
*/
1010

11+
// flowlint unsafe-getters-setters:off
12+
1113
'use strict';
1214

1315
import type {BlobOptions} from './BlobTypes';

packages/react-native/Libraries/Blob/FileReader.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,12 @@
44
* This source code is licensed under the MIT license found in the
55
* LICENSE file in the root directory of this source tree.
66
*
7-
* @flow
7+
* @flow strict-local
88
* @format
99
*/
1010

11+
// flowlint unsafe-getters-setters:off
12+
1113
import type {EventCallback} from '../../src/private/webapis/dom/events/EventTarget';
1214
import type Blob from './Blob';
1315

packages/react-native/Libraries/Blob/URL.js

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,12 @@
44
* This source code is licensed under the MIT license found in the
55
* LICENSE file in the root directory of this source tree.
66
*
7-
* @flow
7+
* @flow strict-local
88
* @format
99
*/
1010

11+
// flowlint unsafe-getters-setters:off
12+
1113
import type Blob from './Blob';
1214

1315
import NativeBlobModule from './NativeBlobModule';
@@ -79,6 +81,7 @@ export class URL {
7981
// $FlowFixMe[missing-local-annot]
8082
constructor(url: string, base?: string | URL) {
8183
let baseUrl = null;
84+
// $FlowFixMe[sketchy-null-string]
8285
if (!base || validateBaseUrl(url)) {
8386
this._url = url;
8487
if (this._url.includes('#')) {
@@ -112,13 +115,14 @@ export class URL {
112115
if (baseUrl.endsWith('/')) {
113116
baseUrl = baseUrl.slice(0, baseUrl.length - 1);
114117
}
115-
if (!url.startsWith('/')) {
116-
url = `/${url}`;
118+
let path = url;
119+
if (!path.startsWith('/')) {
120+
path = `/${path}`;
117121
}
118-
if (baseUrl.endsWith(url)) {
119-
url = '';
122+
if (baseUrl.endsWith(path)) {
123+
path = '';
120124
}
121-
this._url = `${baseUrl}${url}`;
125+
this._url = `${baseUrl}${path}`;
122126
}
123127
}
124128

packages/react-native/Libraries/Blob/URLSearchParams.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,12 @@
44
* This source code is licensed under the MIT license found in the
55
* LICENSE file in the root directory of this source tree.
66
*
7-
* @flow
7+
* @flow strict-local
88
* @format
99
*/
1010

11+
// flowlint unsafe-getters-setters:off
12+
1113
// Small subset from whatwg-url: https://github.com/jsdom/whatwg-url/tree/master/src
1214
// The reference code bloat comes from Unicode issues with URLs, so those won't work here.
1315
export class URLSearchParams {

packages/react-native/Libraries/Blob/URLSearchParams.js.flow

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* This source code is licensed under the MIT license found in the
55
* LICENSE file in the root directory of this source tree.
66
*
7-
* @flow
7+
* @flow strict-local
88
* @format
99
*/
1010

0 commit comments

Comments
 (0)