Skip to content

Commit

Permalink
Fix analyze_code CircleCI Job (#34801)
Browse files Browse the repository at this point in the history
Summary:
Pull Request resolved: #34801

D39796598 (8cdc9e7) broke this CircleCI job, causing failures for `dtslint` and `prettier`. This fixes both issues, by upating formatting, and removing types from `legacy-properties.d.ts` that we no longer export.

These were not flagged by sandcastle. It looks like this is because:
1. We run eslint, but not dtslint internally
2. Arcanist will ignore anything under a "vendor" directory, while we do not exlude anything from the prettier check in OSS.

I also updated the eslint config to lint any TypeScript that appears outside the types directory, since typings are now spread out.

Changelog:
[Internal][Fixed] - Fix `analyze_code` CircleCI Job

Reviewed By: cipolleschi

Differential Revision: D39848604

fbshipit-source-id: 844dfe26e4b618059542b29df163402079c39322
  • Loading branch information
NickGerleman authored and facebook-github-bot committed Sep 27, 2022
1 parent 8dc6bec commit b788b6e
Show file tree
Hide file tree
Showing 4 changed files with 147 additions and 184 deletions.
2 changes: 1 addition & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ module.exports = {
},
},
{
files: ['types/**/*.{ts,tsx}'],
files: ['**/*.{ts,tsx}'],
parser: '@typescript-eslint/parser',
plugins: ['@typescript-eslint/eslint-plugin'],
rules: {
Expand Down
2 changes: 1 addition & 1 deletion Libraries/vendor/core/ErrorUtils.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* @format
*/

type ErrorHandlerCallback = (error: any, isFatal?: boolean) => void;
type ErrorHandlerCallback = (error: any, isFatal?: boolean) => void;

export interface ErrorUtils {
setGlobalHandler: (callback: ErrorHandlerCallback) => void;
Expand Down
290 changes: 145 additions & 145 deletions Libraries/vendor/emitter/EventEmitter.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,158 +7,158 @@
* @format
*/

/**
/**
* EventSubscription represents a subscription to a particular event. It can
* remove its own subscription.
*/
interface EventSubscription {
eventType: string;
key: number;
subscriber: EventSubscriptionVendor;

/**
* @param subscriber the subscriber that controls
* this subscription.
*/
new (subscriber: EventSubscriptionVendor): EventSubscription;

/**
* Removes this subscription from the subscriber that controls it.
*/
remove(): void;
}
eventType: string;
key: number;
subscriber: EventSubscriptionVendor;

/**
* @param subscriber the subscriber that controls
* this subscription.
*/
new (subscriber: EventSubscriptionVendor): EventSubscription;

/**
* Removes this subscription from the subscriber that controls it.
*/
remove(): void;
}

/**
* EventSubscriptionVendor stores a set of EventSubscriptions that are
* subscribed to a particular event type.
*/
declare class EventSubscriptionVendor {
constructor();

/**
* Adds a subscription keyed by an event type.
*
*/
addSubscription(
eventType: string,
subscription: EventSubscription,
): EventSubscription;

/**
* Removes a bulk set of the subscriptions.
*
* @param eventType - Optional name of the event type whose
* registered supscriptions to remove, if null remove all subscriptions.
*/
removeAllSubscriptions(eventType?: string): void;

/**
* Removes a specific subscription. Instead of calling this function, call
* `subscription.remove()` directly.
*
*/
removeSubscription(subscription: any): void;

/**
* Returns the array of subscriptions that are currently registered for the
* given event type.
*
* Note: This array can be potentially sparse as subscriptions are deleted
* from it when they are removed.
*
*/
getSubscriptionsForType(eventType: string): EventSubscription[];
}

/**
* EmitterSubscription represents a subscription with listener and context data.
*/
interface EmitterSubscription extends EventSubscription {
emitter: EventEmitter;
listener: () => any;
context: any;

/**
* @param emitter - The event emitter that registered this
* subscription
* @param subscriber - The subscriber that controls
* this subscription
* @param listener - Function to invoke when the specified event is
* emitted
* @param context - Optional context object to use when invoking the
* listener
*/
new (
emitter: EventEmitter,
subscriber: EventSubscriptionVendor,
listener: () => any,
context: any,
): EmitterSubscription;

/**
* Removes this subscription from the emitter that registered it.
* Note: we're overriding the `remove()` method of EventSubscription here
* but deliberately not calling `super.remove()` as the responsibility
* for removing the subscription lies with the EventEmitter.
*/
remove(): void;
}

export declare class EventEmitter {
/**
*
* @param subscriber - Optional subscriber instance
* to use. If omitted, a new subscriber will be created for the emitter.
*/
constructor(subscriber?: EventSubscriptionVendor | null);

/**
* Adds a listener to be invoked when events of the specified type are
* emitted. An optional calling context may be provided. The data arguments
* emitted will be passed to the listener function.
*
* @param eventType - Name of the event to listen to
* @param listener - Function to invoke when the specified event is
* emitted
* @param context - Optional context object to use when invoking the
* listener
*/
addListener(
eventType: string,
listener: (...args: any[]) => any,
context?: any,
): EmitterSubscription;

/**
* Removes all of the registered listeners, including those registered as
* listener maps.
*
* @param eventType - Optional name of the event whose registered
* listeners to remove
*/
removeAllListeners(eventType?: string): void;

/**
* EventSubscriptionVendor stores a set of EventSubscriptions that are
* subscribed to a particular event type.
* Returns the number of listeners that are currently registered for the given
* event.
*
* @param eventType - Name of the event to query
*/
declare class EventSubscriptionVendor {
constructor();

/**
* Adds a subscription keyed by an event type.
*
*/
addSubscription(
eventType: string,
subscription: EventSubscription,
): EventSubscription;

/**
* Removes a bulk set of the subscriptions.
*
* @param eventType - Optional name of the event type whose
* registered supscriptions to remove, if null remove all subscriptions.
*/
removeAllSubscriptions(eventType?: string): void;

/**
* Removes a specific subscription. Instead of calling this function, call
* `subscription.remove()` directly.
*
*/
removeSubscription(subscription: any): void;

/**
* Returns the array of subscriptions that are currently registered for the
* given event type.
*
* Note: This array can be potentially sparse as subscriptions are deleted
* from it when they are removed.
*
*/
getSubscriptionsForType(eventType: string): EventSubscription[];
}
listenerCount(eventType: string): number;

/**
* EmitterSubscription represents a subscription with listener and context data.
* Emits an event of the given type with the given data. All handlers of that
* particular type will be notified.
*
* @param eventType - Name of the event to emit
* @param Arbitrary arguments to be passed to each registered listener
*
* @example
* emitter.addListener('someEvent', function(message) {
* console.log(message);
* });
*
* emitter.emit('someEvent', 'abc'); // logs 'abc'
*/
interface EmitterSubscription extends EventSubscription {
emitter: EventEmitter;
listener: () => any;
context: any;

/**
* @param emitter - The event emitter that registered this
* subscription
* @param subscriber - The subscriber that controls
* this subscription
* @param listener - Function to invoke when the specified event is
* emitted
* @param context - Optional context object to use when invoking the
* listener
*/
new (
emitter: EventEmitter,
subscriber: EventSubscriptionVendor,
listener: () => any,
context: any,
): EmitterSubscription;

/**
* Removes this subscription from the emitter that registered it.
* Note: we're overriding the `remove()` method of EventSubscription here
* but deliberately not calling `super.remove()` as the responsibility
* for removing the subscription lies with the EventEmitter.
*/
remove(): void;
}

export declare class EventEmitter {
/**
*
* @param subscriber - Optional subscriber instance
* to use. If omitted, a new subscriber will be created for the emitter.
*/
constructor(subscriber?: EventSubscriptionVendor | null);

/**
* Adds a listener to be invoked when events of the specified type are
* emitted. An optional calling context may be provided. The data arguments
* emitted will be passed to the listener function.
*
* @param eventType - Name of the event to listen to
* @param listener - Function to invoke when the specified event is
* emitted
* @param context - Optional context object to use when invoking the
* listener
*/
addListener(
eventType: string,
listener: (...args: any[]) => any,
context?: any,
): EmitterSubscription;

/**
* Removes all of the registered listeners, including those registered as
* listener maps.
*
* @param eventType - Optional name of the event whose registered
* listeners to remove
*/
removeAllListeners(eventType?: string): void;

/**
* Returns the number of listeners that are currently registered for the given
* event.
*
* @param eventType - Name of the event to query
*/
listenerCount(eventType: string): number;

/**
* Emits an event of the given type with the given data. All handlers of that
* particular type will be notified.
*
* @param eventType - Name of the event to emit
* @param Arbitrary arguments to be passed to each registered listener
*
* @example
* emitter.addListener('someEvent', function(message) {
* console.log(message);
* });
*
* emitter.emit('someEvent', 'abc'); // logs 'abc'
*/
emit(eventType: string, ...params: any[]): void;
}
emit(eventType: string, ...params: any[]): void;
}

0 comments on commit b788b6e

Please sign in to comment.