Skip to content

Commit

Permalink
refactor: Remove Flow Type (#2145)
Browse files Browse the repository at this point in the history
  • Loading branch information
dplewis authored May 20, 2024
1 parent acd59aa commit 31796f3
Show file tree
Hide file tree
Showing 33 changed files with 1,258 additions and 954 deletions.
12 changes: 0 additions & 12 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
"extends": [
"eslint:recommended",
"plugin:jsdoc/recommended",
"plugin:flowtype/recommended",
"plugin:@typescript-eslint/recommended"
],
"env": {
Expand All @@ -15,7 +14,6 @@
"wx": true
},
"plugins": [
"flowtype",
"jsdoc",
"@typescript-eslint"
],
Expand Down Expand Up @@ -46,7 +44,6 @@
"@typescript-eslint/no-explicit-any": "off",
"@typescript-eslint/no-var-requires": "off",
"@typescript-eslint/no-non-null-assertion": "off",
"flowtype/no-types-missing-file-annotation": 0,
"jsdoc/require-jsdoc": 0,
"jsdoc/require-returns-description": 0,
"jsdoc/require-param-description": 0,
Expand All @@ -59,15 +56,6 @@
"allowExtraTrailingParamDocs": true
}
],
"jsdoc/check-tag-names": [
"error",
{
"definedTags": [
"flow",
"flow-weak"
]
}
],
"jsdoc/no-undefined-types": [
"error",
{
Expand Down
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ Parse Community has a [responsible Vulnerability Disclosure Program](https://git
## Coding Style

* Most importantly, match the existing code style as much as possible.
* We use [Flow](http://flowtype.org/) and ES6 for this codebase. Use modern syntax whenever possible.
* We use ES6 for this codebase. Use modern syntax whenever possible.
* Keep lines within 80 characters.
* Always end lines with semicolons.

Expand Down
1 change: 0 additions & 1 deletion babel-jest.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,4 @@ module.exports = babelJest.createTransformer({
useBuiltIns: 'entry',
corejs: 3,
}]],
plugins: ['@babel/plugin-transform-flow-comments'],
});
8 changes: 4 additions & 4 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,12 @@ const PRESETS = {
'react-native': ["@babel/preset-typescript", 'module:metro-react-native-babel-preset'],
};
const PLUGINS = {
'browser': [transformRuntime, '@babel/plugin-transform-flow-comments', '@babel/plugin-proposal-class-properties', 'inline-package-json',
'browser': [transformRuntime, '@babel/plugin-proposal-class-properties', 'inline-package-json',
['transform-inline-environment-variables', {'exclude': ['SERVER_RENDERING']}]],
'weapp': [transformRuntime, '@babel/plugin-transform-flow-comments', '@babel/plugin-proposal-class-properties', 'inline-package-json',
'weapp': [transformRuntime, '@babel/plugin-proposal-class-properties', 'inline-package-json',
['transform-inline-environment-variables', {'exclude': ['SERVER_RENDERING']}]],
'node': ['@babel/plugin-transform-flow-comments', 'inline-package-json', 'transform-inline-environment-variables'],
'react-native': ['@babel/plugin-transform-flow-comments', 'inline-package-json', 'transform-inline-environment-variables']
'node': ['inline-package-json', 'transform-inline-environment-variables'],
'react-native': ['inline-package-json', 'transform-inline-environment-variables']
};

const DEV_HEADER = (
Expand Down
1 change: 0 additions & 1 deletion jsdoc-conf.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
"babel": {
"babelrc": false,
"extensions": ["js", "ts", "jsx", "tsx"],
"plugins": ["@babel/plugin-transform-flow-comments"],
"presets": ["@babel/preset-typescript"]
},
"source": {
Expand Down
73 changes: 1 addition & 72 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 0 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,6 @@
"devDependencies": {
"@babel/core": "7.22.0",
"@babel/plugin-proposal-class-properties": "7.18.6",
"@babel/plugin-transform-flow-comments": "7.22.5",
"@babel/plugin-transform-flow-strip-types": "7.21.0",
"@babel/plugin-transform-runtime": "7.21.4",
"@babel/preset-env": "7.21.5",
"@babel/preset-react": "7.22.5",
Expand All @@ -64,7 +62,6 @@
"core-js": "3.30.2",
"cross-env": "7.0.2",
"eslint": "8.56.0",
"eslint-plugin-flowtype": "8.0.3",
"eslint-plugin-jsdoc": "48.2.5",
"express": "4.18.2",
"gulp": "4.0.2",
Expand Down
10 changes: 0 additions & 10 deletions src/.flowconfig

This file was deleted.

32 changes: 13 additions & 19 deletions src/EventuallyQueue.js → src/EventuallyQueue.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,3 @@
/**
* https://github.com/francimedia/parse-js-local-storage
*
* @flow
*/

import CoreManager from './CoreManager';
import ParseError from './ParseError';
import ParseObject from './ParseObject';
Expand All @@ -27,9 +21,9 @@ type QueueObject = {
type Queue = Array<QueueObject>;

const QUEUE_KEY = 'Parse/Eventually/Queue';
let queueCache = [];
let queueCache: QueueObject[] = [];
let dirtyCache = true;
let polling = undefined;
let polling: ReturnType<typeof setInterval> | undefined = undefined;

/**
* Provides utility functions to queue objects that will be
Expand All @@ -50,7 +44,7 @@ const EventuallyQueue = {
* @static
* @see Parse.Object#saveEventually
*/
save(object: ParseObject, serverOptions: SaveOptions = {}): Promise {
save(object: ParseObject, serverOptions: SaveOptions = {}): Promise<void> {
return this.enqueue('save', object, serverOptions);
},

Expand All @@ -65,7 +59,7 @@ const EventuallyQueue = {
* @static
* @see Parse.Object#destroyEventually
*/
destroy(object: ParseObject, serverOptions: RequestOptions = {}): Promise {
destroy(object: ParseObject, serverOptions: RequestOptions = {}): Promise<void> {
return this.enqueue('destroy', object, serverOptions);
},

Expand Down Expand Up @@ -99,7 +93,7 @@ const EventuallyQueue = {
action: string,
object: ParseObject,
serverOptions: SaveOptions | RequestOptions
): Promise {
): Promise<void> {
const queueData = await this.getQueue();
const queueId = this.generateQueueId(action, object);

Expand Down Expand Up @@ -127,7 +121,7 @@ const EventuallyQueue = {
return this.setQueue(queueData);
},

store(data) {
store(data: QueueObject[]) {
return Storage.setItemAsync(QUEUE_KEY, JSON.stringify(data));
},

Expand All @@ -140,10 +134,10 @@ const EventuallyQueue = {
*
* @function getQueue
* @name Parse.EventuallyQueue.getQueue
* @returns {Promise<Array>}
* @returns {Promise<QueueObject[]>}
* @static
*/
async getQueue(): Promise<Array> {
async getQueue(): Promise<QueueObject[]> {
if (dirtyCache) {
queueCache = JSON.parse((await this.load()) || '[]');
dirtyCache = false;
Expand Down Expand Up @@ -189,7 +183,7 @@ const EventuallyQueue = {
* @returns {Promise} A promise that is fulfilled when queue is cleared.
* @static
*/
clear(): Promise {
clear(): Promise<void> {
queueCache = [];
return this.store([]);
},
Expand All @@ -212,10 +206,10 @@ const EventuallyQueue = {
*
* @function length
* @name Parse.EventuallyQueue.length
* @returns {number}
* @returns {Promise<number>}
* @static
*/
async length(): number {
async length(): Promise<number> {
const queueData = await this.getQueue();
return queueData.length;
},
Expand Down Expand Up @@ -268,7 +262,7 @@ const EventuallyQueue = {
// Queued update was overwritten by other request. Do not save
if (
typeof object.updatedAt !== 'undefined' &&
object.updatedAt > new Date(queueObject.object.createdAt)
object.updatedAt > new Date(queueObject.object.createdAt as Date)
) {
return this.remove(queueObject.queueId);
}
Expand Down Expand Up @@ -345,7 +339,7 @@ const EventuallyQueue = {
},

_setPolling(flag: boolean) {
polling = flag;
polling = flag as any;
},

process: {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
/**
* @flow
*/
/* global window */

import { createStore, del, set, get, clear, keys } from 'idb-keyval';

let IndexedDBStorageController: any;

if (typeof window !== 'undefined' && window.indexedDB) {
try {
const ParseStore = createStore('parseDB', 'parseStore');

const IndexedDBStorageController = {
IndexedDBStorageController = {
async: 1,
getItemAsync(path: string) {
return get(path, ParseStore);
Expand All @@ -27,13 +26,13 @@ if (typeof window !== 'undefined' && window.indexedDB) {
return clear(ParseStore);
},
};

module.exports = IndexedDBStorageController;
} catch (_) {
// IndexedDB not accessible
module.exports = undefined;
IndexedDBStorageController = undefined;
}
} else {
// IndexedDB not supported
module.exports = undefined;
IndexedDBStorageController = undefined;
}
module.exports = IndexedDBStorageController;
export default IndexedDBStorageController;
Loading

0 comments on commit 31796f3

Please sign in to comment.