Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: enable prettier import order and reformat files #1041

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .prettierrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,5 @@ module.exports = {
importOrder: ['mocks', '^react(-native)?(/.*)?$', '<THIRD_PARTY_MODULES>', '^[./]'],
importOrderSeparation: true,
importOrderSortSpecifiers: true,
plugins: ['@trivago/prettier-plugin-sort-imports'],
};
5 changes: 4 additions & 1 deletion examples/default/metro.config.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
const path = require('path');
const escape = require('escape-string-regexp');
const { mergeConfig, getDefaultConfig } = require('@react-native/metro-config');
const exclusionList = require('metro-config/src/defaults/exclusionList');

const root = path.resolve(__dirname, '../..');
Expand All @@ -15,7 +16,7 @@ const modules = [
'promise',
];

module.exports = {
const config = {
watchFolders: [root],
transformer: {
getTransformOptions: async () => ({
Expand All @@ -35,3 +36,5 @@ module.exports = {
}, {}),
},
};

module.exports = mergeConfig(getDefaultConfig(__dirname), config);
1 change: 1 addition & 0 deletions examples/default/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
"@babel/core": "^7.20.0",
"@babel/preset-env": "^7.20.0",
"@babel/runtime": "^7.20.0",
"@react-native/metro-config": "^0.73.1",
"@types/jest": "^29.2.1",
"@types/react": "^18.0.24",
"@types/react-native-vector-icons": "^6.4.13",
Expand Down
390 changes: 390 additions & 0 deletions examples/default/yarn.lock

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ import * as Instabug from './modules/Instabug';
import * as NetworkLogger from './modules/NetworkLogger';
import type { NetworkData, NetworkDataObfuscationHandler } from './modules/NetworkLogger';
import * as Replies from './modules/Replies';
import * as SessionReplay from './modules/SessionReplay';
import type { Survey } from './modules/Surveys';
import * as Surveys from './modules/Surveys';
import * as SessionReplay from './modules/SessionReplay';

export * from './utils/Enums';
export {
Expand Down
1 change: 0 additions & 1 deletion src/modules/BugReporting.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { Platform } from 'react-native';

import { NativeBugReporting, NativeEvents, emitter } from '../native/NativeBugReporting';

import type {
DismissType,
ExtendedBugReportMode,
Expand Down
4 changes: 2 additions & 2 deletions src/modules/Instabug.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import type { NavigationAction, NavigationState as NavigationStateV4 } from 'rea

import type { InstabugConfig } from '../models/InstabugConfig';
import Report from '../models/Report';
import type { ReproConfig } from '../models/ReproConfig';
import { NativeEvents, NativeInstabug, emitter } from '../native/NativeInstabug';
import {
ColorTheme,
Expand All @@ -17,9 +18,8 @@ import {
WelcomeMessageMode,
} from '../utils/Enums';
import InstabugUtils, { stringifyIfNotString } from '../utils/InstabugUtils';
import * as NetworkLogger from './NetworkLogger';
import { captureUnhandledRejections } from '../utils/UnhandledRejectionTracking';
import type { ReproConfig } from '../models/ReproConfig';
import * as NetworkLogger from './NetworkLogger';

let _currentScreen: string | null = null;
let _lastScreen: string | null = null;
Expand Down
2 changes: 1 addition & 1 deletion src/native/NativePackage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import type { CrashReportingNativeModule } from './NativeCrashReporting';
import type { FeatureRequestsNativeModule } from './NativeFeatureRequests';
import type { InstabugNativeModule } from './NativeInstabug';
import type { RepliesNativeModule } from './NativeReplies';
import type { SurveysNativeModule } from './NativeSurveys';
import type { SessionReplayNativeModule } from './NativeSessionReplay';
import type { SurveysNativeModule } from './NativeSurveys';

export interface InstabugNativePackage {
IBGAPM: ApmNativeModule;
Expand Down
3 changes: 2 additions & 1 deletion src/utils/UnhandledRejectionTracking.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import tracking, { RejectionTrackingOptions } from 'promise/setimmediate/rejection-tracking';
import { sendCrashReport } from './InstabugUtils';

import { NativeCrashReporting } from '../native/NativeCrashReporting';
import { sendCrashReport } from './InstabugUtils';

export interface HermesInternalType {
enablePromiseRejectionTracker?: (options?: RejectionTrackingOptions) => void;
Expand Down
2 changes: 1 addition & 1 deletion test/mocks/mockNativeModules.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ import mockAPM from './mockAPM';
import mockBugReporting from './mockBugReporting';
import mockCrashReporting from './mockCrashReporting';
import mockFeatureRequests from './mockFeatureRequests';
import mockSessionReplay from './mockSessionReplay';
import mockInstabug from './mockInstabug';
import mockReplies from './mockReplies';
import mockSessionReplay from './mockSessionReplay';
import mockSurveys from './mockSurveys';

jest.mock('react-native', () => {
Expand Down
2 changes: 1 addition & 1 deletion test/setup.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import './mocks/mockNativeModules';
import './mocks/mockPromiseRejectionTracking';
import './mocks/mockParseErrorStackLib';
import './mocks/mockPromiseRejectionTracking';

import { Platform } from 'react-native';
import 'react-native/Libraries/Network/fetch';
Expand Down
9 changes: 5 additions & 4 deletions test/utils/UnhandledRejectionTracking.spec.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
/// <reference path="../../src/promise.d.ts" />

import tracking from 'promise/setimmediate/rejection-tracking';
import { captureUnhandledRejections } from '../../src/utils/UnhandledRejectionTracking';
import { mockHermesInternal } from '../mocks/mockHermesInternal';
import { mockDevMode } from '../mocks/mockDevMode';
import { mockHermesInternal } from '../mocks/mockHermesInternal';

import { mocked } from 'jest-mock';
import tracking from 'promise/setimmediate/rejection-tracking';

import { NativeCrashReporting } from '../../src/native/NativeCrashReporting';
import { captureUnhandledRejections } from '../../src/utils/UnhandledRejectionTracking';

it('tracks Promise rejections when using Hermes', () => {
const enablePromiseRejectionTracker = jest.fn();
Expand Down