Skip to content

Commit

Permalink
fix: Fix prettier warning
Browse files Browse the repository at this point in the history
  • Loading branch information
neet committed Aug 17, 2021
1 parent cca5ca7 commit efe9d5a
Show file tree
Hide file tree
Showing 15 changed files with 1,184 additions and 1,584 deletions.
26 changes: 13 additions & 13 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,37 +25,37 @@
"eventemitter3": "^4.0.7",
"isomorphic-form-data": "^2.0.0",
"isomorphic-ws": "^4.0.1",
"normalize-url": "^7.0.0",
"normalize-url": "^7.0.1",
"semver": "^7.3.5",
"ws": "^8.0.0"
"ws": "^8.1.0"
},
"devDependencies": {
"@rollup/plugin-commonjs": "^20.0.0",
"@rollup/plugin-json": "^4.1.0",
"@semantic-release/changelog": "^5.0.1",
"@semantic-release/git": "^9.0.0",
"@types/jest": "^26.0.24",
"@types/node": "^16.4.10",
"@types/jest": "^27.0.1",
"@types/node": "^16.6.1",
"@types/semver": "^7.3.8",
"@typescript-eslint/eslint-plugin": "^4.29.0",
"@typescript-eslint/parser": "^4.28.5",
"@typescript-eslint/eslint-plugin": "^4.29.2",
"@typescript-eslint/parser": "^4.29.2",
"codecov": "^3.8.3",
"cspell": "^5.6.6",
"cspell": "^5.7.2",
"eslint": "^7.32.0",
"eslint-config-prettier": "^8.3.0",
"eslint-plugin-import": "^2.23.4",
"eslint-plugin-import": "^2.24.0",
"eslint-plugin-prettier": "^3.4.0",
"eslint-plugin-simple-import-sort": "^7.0.0",
"jest": "^26.6.3",
"jest": "^27.0.6",
"npm-run-all": "^4.1.5",
"prettier": "^2.2.1",
"rollup": "^2.55.1",
"prettier": "^2.3.2",
"rollup": "^2.56.2",
"rollup-plugin-auto-external": "^2.0.0",
"rollup-plugin-node-globals": "^1.4.0",
"rollup-plugin-typescript2": "^0.30.0",
"rxjs": "^7.3.0",
"semantic-release": "^17.4.4",
"ts-jest": "^26.5.6",
"semantic-release": "^17.4.5",
"ts-jest": "^27.0.5",
"typedoc": "^0.21.5",
"typescript": "^4.3.5"
},
Expand Down
46 changes: 24 additions & 22 deletions src/decorators/deprecated.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,30 +2,32 @@
* Decorator that verifies the version of the Mastodon instance
* @param parameters Optional params
*/
export const deprecated = (message: string) => (
_obj: unknown,
name: string | symbol,
// eslint-disable-next-line @typescript-eslint/no-explicit-any
descriptor: TypedPropertyDescriptor<(...args: any[]) => any>,
) => {
const original = descriptor.value;
export const deprecated =
(message: string) =>
(
_obj: unknown,
name: string | symbol,
// eslint-disable-next-line @typescript-eslint/no-explicit-any
descriptor: TypedPropertyDescriptor<(...args: any[]) => any>,
) => {
const original = descriptor.value;

if (!original) {
throw new Error('available can only apply to a method of a class');
}
if (!original) {
throw new Error('available can only apply to a method of a class');
}

descriptor.value = function (
this: unknown,
...args: Parameters<typeof original>
) {
if (
process.env.NODE_ENV !== 'production' ||
process.env.MASTO_IGNORE_WARNING
descriptor.value = function (
this: unknown,
...args: Parameters<typeof original>
) {
// eslint-disable-next-line no-console
console.warn(`#${name.toString()} is deprecated. ${message}`);
}
if (
process.env.NODE_ENV !== 'production' ||
process.env.MASTO_IGNORE_WARNING
) {
// eslint-disable-next-line no-console
console.warn(`#${name.toString()} is deprecated. ${message}`);
}

return original.apply(this, args);
return original.apply(this, args);
};
};
};
66 changes: 34 additions & 32 deletions src/decorators/version.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,38 +15,40 @@ export interface AvailableParams {
* Decorator that verifies the version of the Mastodon instance
* @param parameters Optional params
*/
export const version = ({ since, until }: AvailableParams) => (
_version: Version,
name: string | symbol,
// eslint-disable-next-line @typescript-eslint/no-explicit-any
descriptor: TypedPropertyDescriptor<(...args: any[]) => any>,
) => {
const original = descriptor.value;

if (!original) {
throw new Error('available can only apply to a method of a class');
}

descriptor.value = function (
this: Version,
...args: Parameters<typeof original>
) {
if (since && semver.lt(this.version, since, { loose: true })) {
throw new MastoNotFoundError(
`${String(name)} is not available with the current ` +
`Mastodon version ${this.version}. ` +
`It requires greater than or equal to version ${since}.`,
);
export const version =
({ since, until }: AvailableParams) =>
(
_version: Version,
name: string | symbol,
// eslint-disable-next-line @typescript-eslint/no-explicit-any
descriptor: TypedPropertyDescriptor<(...args: any[]) => any>,
) => {
const original = descriptor.value;

if (!original) {
throw new Error('available can only apply to a method of a class');
}

if (until && semver.gt(this.version, until, { loose: true })) {
throw new MastoNotFoundError(
`${String(name)} is not available with the current ` +
`Mastodon version ${this.version}. ` +
`It was removed on version ${until}.`,
);
}

return original.apply(this, args);
descriptor.value = function (
this: Version,
...args: Parameters<typeof original>
) {
if (since && semver.lt(this.version, since, { loose: true })) {
throw new MastoNotFoundError(
`${String(name)} is not available with the current ` +
`Mastodon version ${this.version}. ` +
`It requires greater than or equal to version ${since}.`,
);
}

if (until && semver.gt(this.version, until, { loose: true })) {
throw new MastoNotFoundError(
`${String(name)} is not available with the current ` +
`Mastodon version ${this.version}. ` +
`It was removed on version ${until}.`,
);
}

return original.apply(this, args);
};
};
};
3 changes: 2 additions & 1 deletion src/repositories/account-repository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,8 @@ export interface LookupAccountParams {
}

export class AccountRepository
implements Repository<Account, CreateAccountParams> {
implements Repository<Account, CreateAccountParams>
{
constructor(private readonly http: Http, readonly version: string) {}

/**
Expand Down
3 changes: 2 additions & 1 deletion src/repositories/directory-repository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ export interface FetchDirectoryParams {
}

export class DirectoryRepository
implements Repository<Account, never, never, FetchDirectoryParams> {
implements Repository<Account, never, never, FetchDirectoryParams>
{
constructor(private readonly http: Http, readonly version: string) {}

/**
Expand Down
3 changes: 2 additions & 1 deletion src/repositories/filter-repository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ export interface CreateFilterParams {
export type UpdateFilterParams = CreateFilterParams;

export class FilterRepository
implements Repository<Filter, CreateFilterParams, UpdateFilterParams> {
implements Repository<Filter, CreateFilterParams, UpdateFilterParams>
{
constructor(private readonly http: Http, readonly version: string) {}

/**
Expand Down
3 changes: 2 additions & 1 deletion src/repositories/list-repository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ export interface ModifyListAccountsParams {
}

export class ListRepository
implements Repository<List, ModifyListParams, ModifyListParams> {
implements Repository<List, ModifyListParams, ModifyListParams>
{
constructor(private readonly http: Http, readonly version: string) {}

/**
Expand Down
4 changes: 2 additions & 2 deletions src/repositories/marker-repository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ export type CreateMarkersParams = {
};

export class MarkerRepository
implements
Repository<Marker, CreateMarkersParams, never, FetchMarkersParams> {
implements Repository<Marker, CreateMarkersParams, never, FetchMarkersParams>
{
constructor(private readonly http: Http, readonly version: string) {}

/**
Expand Down
3 changes: 2 additions & 1 deletion src/repositories/media-attachment-repository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ export class MediaAttachmentRepository
Attachment,
CreateMediaAttachmentParams,
UpdateMediaAttachmentParams
> {
>
{
constructor(
private readonly http: Http,
readonly version: string,
Expand Down
3 changes: 2 additions & 1 deletion src/repositories/push-subscription-repository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ export class PushSubscriptionsRepository
PushSubscription,
CreatePushSubscriptionParams,
UpdatePushSubscriptionParams
> {
>
{
constructor(private readonly http: Http, readonly version: string) {}

/**
Expand Down
3 changes: 2 additions & 1 deletion src/repositories/scheduled-statuses-repository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ export interface UpdateScheduledStatusParams {
}

export class ScheduledStatusesRepository
implements AsyncIterable<ScheduledStatus[]> {
implements AsyncIterable<ScheduledStatus[]>
{
constructor(private readonly http: Http, readonly version: string) {}

async *[Symbol.asyncIterator]() {
Expand Down
2 changes: 1 addition & 1 deletion src/serializers/transform-keys.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const fromEntries = <T>(entries: [string, unknown][]) => {
}

// eslint-disable-next-line @typescript-eslint/no-explicit-any
return (object as any) as T;
return object as any as T;
};

// prettier-ignore
Expand Down
3 changes: 2 additions & 1 deletion src/ws/ws-impl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ import { Event, EventType, EventTypeMap, Ws, WsEvents } from './ws';
*/
export class WsEventsImpl
extends EventEmitter<EventTypeMap>
implements WsEvents {
implements WsEvents
{
constructor(
private readonly ws: WebSocket,
private readonly serializer: Serializer,
Expand Down
3 changes: 2 additions & 1 deletion src/ws/ws-mock-impl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ export const wsStream = jest.fn();

export class WsEventsMockImpl
extends EventEmitter<EventTypeMap>
implements WsEvents {
implements WsEvents
{
static connect = jest.fn();
disconnect = wsDisconnect;
on = wsOn;
Expand Down
Loading

0 comments on commit efe9d5a

Please sign in to comment.