Skip to content

Commit 44fe4dd

Browse files
authored
Merge pull request #3156 from adumesny/master
yarn lint fixes
2 parents e644d3b + f065e36 commit 44fe4dd

File tree

9 files changed

+63
-56
lines changed

9 files changed

+63
-56
lines changed

angular/projects/lib/src/lib/base-widget.ts

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,14 @@
55

66
/**
77
* Abstract base class that all custom widgets should extend.
8-
*
8+
*
99
* This class provides the interface needed for GridstackItemComponent to:
1010
* - Serialize/deserialize widget data
1111
* - Save/restore widget state
1212
* - Integrate with Angular lifecycle
13-
*
13+
*
1414
* Extend this class when creating custom widgets for dynamic grids.
15-
*
15+
*
1616
* @example
1717
* ```typescript
1818
* @Component({
@@ -21,7 +21,7 @@
2121
* })
2222
* export class MyCustomWidget extends BaseWidget {
2323
* @Input() data: string = '';
24-
*
24+
*
2525
* serialize() {
2626
* return { data: this.data };
2727
* }
@@ -46,12 +46,12 @@ export abstract class BaseWidget {
4646

4747
/**
4848
* Override this method to return serializable data for this widget.
49-
*
49+
*
5050
* Return an object with properties that map to your component's @Input() fields.
5151
* The selector is handled automatically, so only include component-specific data.
52-
*
52+
*
5353
* @returns Object containing serializable component data
54-
*
54+
*
5555
* @example
5656
* ```typescript
5757
* serialize() {
@@ -67,17 +67,17 @@ export abstract class BaseWidget {
6767

6868
/**
6969
* Override this method to handle widget restoration from saved data.
70-
*
70+
*
7171
* Use this for complex initialization that goes beyond simple @Input() mapping.
7272
* The default implementation automatically assigns input data to component properties.
73-
*
73+
*
7474
* @param w The saved widget data including input properties
75-
*
75+
*
7676
* @example
7777
* ```typescript
7878
* deserialize(w: NgGridStackWidget) {
7979
* super.deserialize(w); // Call parent for basic setup
80-
*
80+
*
8181
* // Custom initialization logic
8282
* if (w.input?.complexData) {
8383
* this.processComplexData(w.input.complexData);
@@ -92,4 +92,4 @@ export abstract class BaseWidget {
9292

9393
if (w.input) Object.assign(this, w.input);
9494
}
95-
}
95+
}

angular/projects/lib/src/lib/gridstack-item.component.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,15 @@ export interface GridItemCompHTMLElement extends GridItemHTMLElement {
1818

1919
/**
2020
* Angular component wrapper for individual GridStack items.
21-
*
21+
*
2222
* This component represents a single grid item and handles:
2323
* - Dynamic content creation and management
2424
* - Integration with parent GridStack component
2525
* - Component lifecycle and cleanup
2626
* - Widget options and configuration
27-
*
27+
*
2828
* Use in combination with GridstackComponent for the parent grid.
29-
*
29+
*
3030
* @example
3131
* ```html
3232
* <gridstack>
@@ -76,7 +76,7 @@ export class GridstackItemComponent implements OnDestroy {
7676
/**
7777
* Grid item configuration options.
7878
* Defines position, size, and behavior of this grid item.
79-
*
79+
*
8080
* @example
8181
* ```typescript
8282
* itemOptions: GridStackNode = {

angular/projects/lib/src/lib/gridstack.component.ts

Lines changed: 33 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
*/
55

66
import {
7-
AfterContentInit, Component, ContentChildren, ElementRef, EventEmitter, Input,
8-
OnDestroy, OnInit, Output, QueryList, Type, ViewChild, ViewContainerRef, reflectComponentType, ComponentRef
7+
AfterContentInit, Component, ContentChildren, ElementRef, EventEmitter, Input,
8+
OnDestroy, OnInit, Output, QueryList, Type, ViewChild, ViewContainerRef, reflectComponentType, ComponentRef
99
} from '@angular/core';
1010
import { NgIf } from '@angular/common';
1111
import { Subscription } from 'rxjs';
@@ -45,19 +45,19 @@ export interface GridCompHTMLElement extends GridHTMLElement {
4545
* Mapping of selector strings to Angular component types.
4646
* Used for dynamic component creation based on widget selectors.
4747
*/
48-
export type SelectorToType = {[key: string]: Type<Object>};
48+
export type SelectorToType = {[key: string]: Type<object>};
4949

5050
/**
5151
* Angular component wrapper for GridStack.
52-
*
52+
*
5353
* This component provides Angular integration for GridStack grids, handling:
5454
* - Grid initialization and lifecycle
5555
* - Dynamic component creation and management
5656
* - Event binding and emission
5757
* - Integration with Angular change detection
58-
*
58+
*
5959
* Use in combination with GridstackItemComponent for individual grid items.
60-
*
60+
*
6161
* @example
6262
* ```html
6363
* <gridstack [options]="gridOptions" (change)="onGridChange($event)">
@@ -99,7 +99,7 @@ export class GridstackComponent implements OnInit, AfterContentInit, OnDestroy {
9999
/**
100100
* Grid configuration options.
101101
* Can be set before grid initialization or updated after grid is created.
102-
*
102+
*
103103
* @example
104104
* ```typescript
105105
* gridOptions: GridStackOptions = {
@@ -122,7 +122,7 @@ export class GridstackComponent implements OnInit, AfterContentInit, OnDestroy {
122122
/**
123123
* Controls whether empty content should be displayed.
124124
* Set to true to show ng-content with 'empty-content' selector when grid has no items.
125-
*
125+
*
126126
* @example
127127
* ```html
128128
* <gridstack [isEmpty]="gridItems.length === 0">
@@ -134,52 +134,52 @@ export class GridstackComponent implements OnInit, AfterContentInit, OnDestroy {
134134

135135
/**
136136
* GridStack event emitters for Angular integration.
137-
*
137+
*
138138
* These provide Angular-style event handling for GridStack events.
139139
* Alternatively, use `this.grid.on('event1 event2', callback)` for multiple events.
140-
*
140+
*
141141
* Note: 'CB' suffix prevents conflicts with native DOM events.
142-
*
142+
*
143143
* @example
144144
* ```html
145145
* <gridstack (changeCB)="onGridChange($event)" (droppedCB)="onItemDropped($event)">
146146
* </gridstack>
147147
* ```
148148
*/
149-
149+
150150
/** Emitted when widgets are added to the grid */
151151
@Output() public addedCB = new EventEmitter<nodesCB>();
152-
152+
153153
/** Emitted when grid layout changes */
154154
@Output() public changeCB = new EventEmitter<nodesCB>();
155-
155+
156156
/** Emitted when grid is disabled */
157157
@Output() public disableCB = new EventEmitter<eventCB>();
158-
158+
159159
/** Emitted during widget drag operations */
160160
@Output() public dragCB = new EventEmitter<elementCB>();
161-
161+
162162
/** Emitted when widget drag starts */
163163
@Output() public dragStartCB = new EventEmitter<elementCB>();
164-
164+
165165
/** Emitted when widget drag stops */
166166
@Output() public dragStopCB = new EventEmitter<elementCB>();
167-
167+
168168
/** Emitted when widget is dropped */
169169
@Output() public droppedCB = new EventEmitter<droppedCB>();
170-
170+
171171
/** Emitted when grid is enabled */
172172
@Output() public enableCB = new EventEmitter<eventCB>();
173-
173+
174174
/** Emitted when widgets are removed from the grid */
175175
@Output() public removedCB = new EventEmitter<nodesCB>();
176-
176+
177177
/** Emitted during widget resize operations */
178178
@Output() public resizeCB = new EventEmitter<elementCB>();
179-
179+
180180
/** Emitted when widget resize starts */
181181
@Output() public resizeStartCB = new EventEmitter<elementCB>();
182-
182+
183183
/** Emitted when widget resize stops */
184184
@Output() public resizeStopCB = new EventEmitter<elementCB>();
185185

@@ -192,7 +192,7 @@ export class GridstackComponent implements OnInit, AfterContentInit, OnDestroy {
192192
/**
193193
* Get the underlying GridStack instance.
194194
* Use this to access GridStack API methods directly.
195-
*
195+
*
196196
* @example
197197
* ```typescript
198198
* this.gridComponent.grid.addWidget({x: 0, y: 0, w: 2, h: 1});
@@ -208,10 +208,10 @@ export class GridstackComponent implements OnInit, AfterContentInit, OnDestroy {
208208

209209
/**
210210
* Mapping of component selectors to their types for dynamic creation.
211-
*
211+
*
212212
* This enables dynamic component instantiation from string selectors.
213213
* Angular doesn't provide public access to this mapping, so we maintain our own.
214-
*
214+
*
215215
* @example
216216
* ```typescript
217217
* GridstackComponent.addComponentToSelectorType([MyWidgetComponent]);
@@ -220,9 +220,9 @@ export class GridstackComponent implements OnInit, AfterContentInit, OnDestroy {
220220
public static selectorToType: SelectorToType = {};
221221
/**
222222
* Register a list of Angular components for dynamic creation.
223-
*
223+
*
224224
* @param typeList Array of component types to register
225-
*
225+
*
226226
* @example
227227
* ```typescript
228228
* GridstackComponent.addComponentToSelectorType([
@@ -231,16 +231,17 @@ export class GridstackComponent implements OnInit, AfterContentInit, OnDestroy {
231231
* ]);
232232
* ```
233233
*/
234-
public static addComponentToSelectorType(typeList: Array<Type<Object>>) {
234+
public static addComponentToSelectorType(typeList: Array<Type<object>>) {
235235
typeList.forEach(type => GridstackComponent.selectorToType[ GridstackComponent.getSelector(type) ] = type);
236236
}
237237
/**
238238
* Extract the selector string from an Angular component type.
239-
*
239+
*
240240
* @param type The component type to get selector from
241241
* @returns The component's selector string
242242
*/
243-
public static getSelector(type: Type<Object>): string {
243+
public static getSelector(type: Type<object>): string {
244+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
244245
return reflectComponentType(type)!.selector;
245246
}
246247

@@ -367,6 +368,7 @@ export function gsCreateNgComponents(host: GridCompHTMLElement | HTMLElement, n:
367368
const gridItemComp = (host.parentElement as GridItemCompHTMLElement)?._gridItemComp;
368369
if (!gridItemComp) return;
369370
// check if gridItem has a child component with 'container' exposed to create under..
371+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
370372
const container = (gridItemComp.childWidget as any)?.container || gridItemComp.container;
371373
const gridRef = container?.createComponent(GridstackComponent);
372374
const grid = gridRef?.instance;

angular/projects/lib/src/lib/gridstack.module.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@ import { GridstackComponent } from "./gridstack.component";
1010

1111
/**
1212
* @deprecated Use GridstackComponent and GridstackItemComponent as standalone components instead.
13-
*
13+
*
1414
* This NgModule is provided for backward compatibility but is no longer the recommended approach.
1515
* Import components directly in your standalone components or use the new Angular module structure.
16-
*
16+
*
1717
* @example
1818
* ```typescript
1919
* // Preferred approach - standalone components
@@ -23,7 +23,7 @@ import { GridstackComponent } from "./gridstack.component";
2323
* template: '<gridstack></gridstack>'
2424
* })
2525
* export class AppComponent {}
26-
*
26+
*
2727
* // Legacy approach (deprecated)
2828
* @NgModule({
2929
* imports: [GridstackModule]

angular/projects/lib/src/lib/types.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ export interface NgGridStackOptions extends GridStackOptions {
4141
/**
4242
* Type for component input data serialization.
4343
* Maps @Input() property names to their values for widget persistence.
44-
*
44+
*
4545
* @example
4646
* ```typescript
4747
* const inputs: NgCompInputs = {
@@ -51,4 +51,5 @@ export interface NgGridStackOptions extends GridStackOptions {
5151
* };
5252
* ```
5353
*/
54+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
5455
export type NgCompInputs = {[key: string]: any};

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
"test:e2e": "playwright test",
4545
"test:e2e:ui": "playwright test --ui",
4646
"test:e2e:headed": "playwright test --headed",
47-
"lint": "tsc --noEmit && eslint src/*.ts",
47+
"lint": "tsc --project tsconfig.build.json --noEmit && eslint src/*.ts angular/projects/lib/src/**/*.ts",
4848
"reset": "rm -rf dist node_modules",
4949
"prepublishOnly": "yarn build"
5050
},

src/gridstack.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -957,7 +957,7 @@ export class GridStack {
957957
// https://stackoverflow.com/questions/21064101/understanding-offsetwidth-clientwidth-scrollwidth-and-height-respectively
958958
return forBreakpoint && this.opts.columnOpts?.breakpointForWindow ? window.innerWidth : (this.el.clientWidth || this.el.parentElement.clientWidth || window.innerWidth);
959959
}
960-
960+
961961
/** checks for dynamic column count for our current size, returning true if changed */
962962
protected checkDynamicColumn(): boolean {
963963
const resp = this.opts.columnOpts;

src/utils.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* Copyright (c) 2021-2025 Alain Dumesny - see GridStack root license
44
*/
55

6-
import { GridStackElement, GridStackNode, GridStackOptions, numberOrString, GridStackPosition, GridStackWidget } from './types';
6+
import { GridStackElement, GridStackNode, numberOrString, GridStackPosition, GridStackWidget } from './types';
77

88
export interface HeightData {
99
h: number;

tsconfig.build.json

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,19 @@
44
"skipLibCheck": true
55
},
66
"include": [
7-
"./src/**/*.ts"
7+
"./src/**/*.ts",
8+
"./angular/projects/lib/src/**/*.ts"
89
],
910
"exclude": [
1011
"./src/**/*.spec.ts",
1112
"./src/**/*.test.ts",
1213
"./spec/**/*",
1314
"./vitest.setup.ts",
1415
"./vitest.config.ts",
15-
"./angular/**/*",
16+
"./angular/projects/lib/src/**/*.spec.ts",
17+
"./angular/projects/lib/src/test.ts",
18+
"./angular/projects/demo/**/*",
19+
"./angular/node_modules/**/*",
1620
"./demo/**/*",
1721
"./node_modules/**/*"
1822
]

0 commit comments

Comments
 (0)