Skip to content

Commit 9ece0d8

Browse files
fix: lint
1 parent 688442a commit 9ece0d8

9 files changed

Lines changed: 123 additions & 35 deletions

File tree

README.md

Lines changed: 59 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,17 @@
1+
<a name="top"></a>
2+
13
# Boot for Google Apps Script Projects
24

5+
[![Built%20with-clasp](https://img.shields.io/badge/Built%20with-clasp-4285f4.svg)](https://github.com/google/clasp)
6+
[![License](https://img.shields.io/github/license/MaksymStoianov/appsscript-boot?label=License)](LICENSE)
7+
[![Latest release](https://img.shields.io/github/v/release/MaksymStoianov/appsscript-boot?label=Release)](https://img.shields.io/github/v/release/MaksymStoianov/appsscript-boot)
8+
9+
[![GitHub Stars](https://img.shields.io/github/stars/MaksymStoianov/appsscript-boot?style=social)](https://github.com/MaksymStoianov/appsscript-boot/stargazers)
10+
[![GitHub Fork](https://img.shields.io/github/forks/MaksymStoianov/appsscript-boot?style=social)](https://github.com/MaksymStoianov/appsscript-boot/forks)
11+
[![GitHub Sponsors](https://img.shields.io/github/sponsors/MaksymStoianov?style=social&logo=github)](https://github.com/sponsors/MaksymStoianov)
12+
13+
## Introduction
14+
315
`appsscript-boot` is a powerful, scalable, and modern framework for building high-performance Google Apps Script
416
applications.
517

@@ -41,6 +53,8 @@ export class Sheet {
4153

4254
### Class decorators
4355

56+
<details open><summary>Class decorators</summary>
57+
4458
| Decorator | Description |
4559
| --------------------- | ------------------------------------------------------------- |
4660
| `@Controller()` | Marks a class as a general-purpose controller. |
@@ -58,33 +72,41 @@ export class Sheet {
5872
| `@SlideController()` | Marks a class as a Google Slides event controller. |
5973
| `@SlidesController()` | Alias for `@SlideController()`. |
6074

75+
</details>
76+
6177
### Method decorators
6278

63-
| Decorator | Description |
64-
| -------------------- | --------------------------------------------------------------------------------------------- |
65-
| `@Install()` | Handles `onInstall` event, triggered when the add-on is first installed. |
66-
| `@Open()` | Handles `onOpen` event, triggered when a Google Sheet is opened. |
67-
| `@Edit()` | Handles `onEdit` event, triggered by manual cell changes in a Google Sheet. |
68-
| `@Change()` | Handles `onChange` event, triggered by any structural or content change in a Google Sheet. |
69-
| `@SelectionChange()` | Handles `onSelectionChange` event, triggered by user cell selection changes. |
70-
| `@FormSubmit()` | Handles `onFormSubmit` event, triggered when a form connected to a Google Sheet is submitted. |
71-
| `@Post()` | Maps a method to handle HTTP POST requests. |
72-
| `@Get()` | Maps a method to handle HTTP GET requests. |
73-
| `@Delete()` | Maps a method to handle HTTP DELETE requests. |
74-
| `@Put()` | Maps a method to handle HTTP PUT requests. |
75-
| `@Patch()` | Maps a method to handle HTTP PATCH requests. |
76-
| `@Options()` | Maps a method to handle HTTP OPTIONS requests. |
77-
| `@Head()` | Maps a method to handle HTTP HEAD requests. |
78-
| `@PostMapping()` | Alias for `@Post()`. |
79-
| `@GetMapping()` | Alias for `@Get()`. |
80-
| `@DeleteMapping()` | Alias for `@Delete()`. |
81-
| `@PutMapping()` | Alias for `@Put()`. |
82-
| `@PatchMapping()` | Alias for `@Patch()`. |
83-
| `@OptionsMapping()` | Alias for `@Options()`. |
84-
| `@HeadMapping()` | Alias for `@Head()`. |
79+
<details open><summary>Method decorators</summary>
80+
81+
| Decorator | Description |
82+
| -------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------ |
83+
| `@Install()` | Handles [`onInstall`](https://developers.google.com/apps-script/guides/triggers#oninstalle) event, triggered when the add-on is first installed. |
84+
| `@Open()` | Handles [`onOpen`](https://developers.google.com/apps-script/guides/triggers#onopene) event, triggered when a Google Sheet is opened. |
85+
| `@Edit()` | Handles [`onEdit`](https://developers.google.com/apps-script/guides/triggers#onedite) event, triggered by manual cell changes in a Google Sheet. |
86+
| `@Change()` | Handles `onChange` event, triggered by any structural or content change in a Google Sheet. |
87+
| `@SelectionChange()` | Handles [`onSelectionChange`](https://developers.google.com/apps-script/guides/triggers#onselectionchangee) event, triggered by user cell selection changes. |
88+
| `@FormSubmit()` | Handles `onFormSubmit` event, triggered when a form connected to a Google Sheet is submitted. |
89+
| `@Post()` | Maps a method to handle HTTP POST requests. |
90+
| `@Get()` | Maps a method to handle HTTP GET requests. |
91+
| `@Delete()` | Maps a method to handle HTTP DELETE requests. |
92+
| `@Put()` | Maps a method to handle HTTP PUT requests. |
93+
| `@Patch()` | Maps a method to handle HTTP PATCH requests. |
94+
| `@Options()` | Maps a method to handle HTTP OPTIONS requests. |
95+
| `@Head()` | Maps a method to handle HTTP HEAD requests. |
96+
| `@PostMapping()` | Alias for `@Post()`. |
97+
| `@GetMapping()` | Alias for `@Get()`. |
98+
| `@DeleteMapping()` | Alias for `@Delete()`. |
99+
| `@PutMapping()` | Alias for `@Put()`. |
100+
| `@PatchMapping()` | Alias for `@Patch()`. |
101+
| `@OptionsMapping()` | Alias for `@Options()`. |
102+
| `@HeadMapping()` | Alias for `@Head()`. |
103+
104+
</details>
85105

86106
### Parameter decorators
87107

108+
<details open><summary>Parameter decorators</summary>
109+
88110
| Decorator | Description |
89111
| ----------------- | ---------------------------------------------------------- |
90112
| `@Event()` | Injects the full Google Apps Script event object. |
@@ -98,11 +120,25 @@ export class Sheet {
98120
| `@RequestBody()` | Alias for `@Body()`. |
99121
| `@Inject()` | Explicitly specifies an injection token for a dependency. |
100122

101-
## TODO
123+
</details>
124+
125+
## Tasks
102126

103127
<details><summary>More</summary>
104128

105129
- [ ] Develop a `Cron` decorator for methods.
106130
- [ ] Develop a `Response` decorator for parameters.
107131

108132
</details>
133+
134+
## Changelog
135+
136+
For a detailed list of changes and updates, please refer to the [CHANGELOG](CHANGELOG.md) file.
137+
138+
## License
139+
140+
This project is licensed under the [LICENSE](LICENSE) file.
141+
142+
---
143+
144+
**Like this project?** [Star our awesome repo »](https://github.com/MaksymStoianov/appsscript-boot)

src/App.ts

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ export class App {
3737
private static instance: App | null = null;
3838

3939
private readonly _controllers: Newable[] = [];
40-
private readonly _providers = new Map<Newable, any>();
40+
private readonly _providers = new Map<Newable, unknown>();
4141
private readonly _routes: RouteMetadata[] = [];
4242

4343
/**
@@ -234,6 +234,7 @@ export class App {
234234
const handler =
235235
controller[route.handler as keyof typeof controller].bind(controller);
236236

237+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
237238
const body = ((data, type): any => {
238239
if (!isString(data)) {
239240
return data;
@@ -297,6 +298,7 @@ export class App {
297298
* @param eventType - The expected type of event. This is used to match with the metadata placed by event decorators on controller methods.
298299
*/
299300
private handleAppsScriptEvent(
301+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
300302
event: any,
301303
eventType: AppsScriptEventType
302304
): void {
@@ -393,7 +395,9 @@ export class App {
393395
*/
394396
private checkEventFilters(
395397
eventType: AppsScriptEventType,
398+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
396399
event: any,
400+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
397401
methodOptions: Record<string, any> | undefined
398402
): boolean {
399403
if (!methodOptions) {
@@ -478,6 +482,7 @@ export class App {
478482
event: GoogleAppsScript.Events.DoGet | GoogleAppsScript.Events.DoPost
479483
): HttpRequest {
480484
const headers: HttpHeaders =
485+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
481486
((input: unknown): any => {
482487
if (!isString(input)) {
483488
return null;
@@ -678,6 +683,7 @@ export class App {
678683
body?: string | object | null | undefined;
679684
response?: HttpResponse;
680685
}
686+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
681687
): any[] {
682688
const targetPrototype = Object.getPrototypeOf(target);
683689

@@ -702,10 +708,12 @@ export class App {
702708

703709
metadata.sort((a, b) => a.index - b.index);
704710

711+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
705712
const designParamTypes: Newable<any>[] =
706713
Reflect.getMetadata(PARAMTYPES_METADATA, targetPrototype, propertyKey) ||
707714
[];
708715

716+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
709717
const args: any[] = [];
710718

711719
for (const param of metadata) {
@@ -725,19 +733,22 @@ export class App {
725733
case ParamSource.BODY:
726734
args[param.index] =
727735
param.key && ctx.body && typeof ctx.body === "object"
728-
? (ctx.body as Record<string, any>)[param.key]
736+
? // eslint-disable-next-line @typescript-eslint/no-explicit-any
737+
(ctx.body as Record<string, any>)[param.key]
729738
: ctx.body;
730739
break;
731740

732741
case ParamSource.EVENT:
733742
args[param.index] = param.key
734-
? (ctx.event as any)[param.key]
743+
? // eslint-disable-next-line @typescript-eslint/no-explicit-any
744+
(ctx.event as any)[param.key]
735745
: ctx.event;
736746
break;
737747

738748
case ParamSource.REQUEST:
739749
args[param.index] = param.key
740-
? (ctx.request as any)?.[param.key]
750+
? // eslint-disable-next-line @typescript-eslint/no-explicit-any
751+
(ctx.request as any)?.[param.key]
741752
: ctx.request;
742753
break;
743754

@@ -754,7 +765,8 @@ export class App {
754765

755766
case ParamSource.RESPONSE:
756767
args[param.index] = param.key
757-
? (ctx.response as any)?.[param.key]
768+
? // eslint-disable-next-line @typescript-eslint/no-explicit-any
769+
(ctx.response as any)?.[param.key]
758770
: ctx.response;
759771
break;
760772

@@ -768,6 +780,7 @@ export class App {
768780
} else {
769781
args[param.index] = undefined;
770782
}
783+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
771784
} catch (err: unknown) {
772785
args[param.index] = undefined;
773786
}

src/decorators/method.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ function createAppsScriptDecorator(
2525
eventType: AppsScriptEventType,
2626
options?: Omit<AppsScriptOptions, "eventType">
2727
): MethodDecorator {
28+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
2829
return (target, key, descriptor: TypedPropertyDescriptor<any>) => {
2930
Reflect.defineMetadata(
3031
APPSSCRIPT_EVENT_METADATA,
@@ -167,6 +168,7 @@ function createHttpDecorator(method: RequestMethod) {
167168
return (
168169
target: object,
169170
key: string | symbol,
171+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
170172
descriptor: TypedPropertyDescriptor<any>
171173
) => {
172174
Reflect.defineMetadata(

src/decorators/param.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
1-
import {
2-
INJECT_TOKENS_METADATA,
3-
PARAM_DEFINITIONS_METADATA
4-
} from "../config/constants";
1+
import { INJECT_TOKENS_METADATA, PARAM_DEFINITIONS_METADATA } from "../config/constants";
52
import { InjectTokenDefinition, ParamDefinition, ParamSource } from "../types";
63

74
/**
@@ -37,6 +34,7 @@ function assignMetadata(
3734
function assignInjectMetadata(
3835
existing: Record<string, InjectTokenDefinition>,
3936
index: number,
37+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
4038
token?: any
4139
): Record<string, InjectTokenDefinition> {
4240
const type = ParamSource.INJECT;
@@ -56,6 +54,7 @@ function assignInjectMetadata(
5654
* @environment `Google Apps Script`
5755
*/
5856
export function getInjectionTokens(
57+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
5958
target: any,
6059
propertyKey?: string | symbol
6160
): Record<string, InjectTokenDefinition> {
@@ -200,6 +199,7 @@ export const Event = createDecorator(ParamSource.EVENT);
200199
* @returns Декоратор параметра.
201200
* @environment `Google Apps Script`
202201
*/
202+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
203203
export function Inject(token?: any): ParameterDecorator {
204204
return (target, propertyKey, parameterIndex) => {
205205
const metadataTarget =

src/types/InjectTokenDefinition.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,6 @@ import { ParamSource } from "./ParamSource";
66
export interface InjectTokenDefinition {
77
type: ParamSource.INJECT;
88
index: number;
9+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
910
token: any;
1011
}

src/types/Newable.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
12
export type Newable<T = any> = new (...args: any[]) => T;

test/decorators/class.test.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,7 @@ describe("HttpController Decorator", () => {
142142
});
143143

144144
it("should correctly handle a number as basePath (TypeScript will warn, but JS runtime allows)", () => {
145+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
145146
const numberBasePath = 123 as any;
146147

147148
@HttpController(numberBasePath)
@@ -157,6 +158,7 @@ describe("HttpController Decorator", () => {
157158
});
158159

159160
it("should correctly handle null as basePath (TypeScript will warn, but JS runtime allows)", () => {
161+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
160162
const nullBasePath = null as any;
161163

162164
@HttpController(nullBasePath)

0 commit comments

Comments
 (0)