Skip to content

Commit 063e437

Browse files
feat: adds prettier support (ng-select#2402)
* fix: updates eslint config * feat: adds prettier support --------- Co-authored-by: Pavan Kumar Jadda <[email protected]>
1 parent 9021e1f commit 063e437

File tree

171 files changed

+13526
-13522
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

171 files changed

+13526
-13522
lines changed

.eslintrc.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,5 +67,6 @@
6767
]
6868
}
6969
}
70-
]
70+
],
71+
"extends": ["prettier"]
7172
}

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,6 @@ travis_rsa.pub
1111
.vscode/**
1212
dist.tgz
1313
.yarn
14+
15+
.nx/cache
16+
.nx/workspace-data

.prettierignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
/dist
2+
.angular
3+
src/assets/css/vendor

.prettierrc.json

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"printWidth": 140,
3+
"singleQuote": true,
4+
"trailingComma": "all",
5+
"semi": true,
6+
"bracketSameLine": true,
7+
"useTabs": true,
8+
"endOfLine": "auto"
9+
}

package.json

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -54,25 +54,26 @@
5454
},
5555
"devDependencies": {
5656
"@angular-devkit/build-angular": "^18.0.1",
57-
"@angular-eslint/builder": "17.5.0",
58-
"@angular-eslint/eslint-plugin": "17.5.0",
59-
"@angular-eslint/eslint-plugin-template": "17.5.0",
60-
"@angular-eslint/schematics": "17.5.0",
61-
"@angular-eslint/template-parser": "17.5.0",
57+
"@angular-eslint/builder": "18.0.1",
58+
"@angular-eslint/eslint-plugin": "18.0.1",
59+
"@angular-eslint/eslint-plugin-template": "18.0.1",
60+
"@angular-eslint/schematics": "18.0.1",
61+
"@angular-eslint/template-parser": "18.0.1",
6262
"@angular/cli": "^18.0.1",
6363
"@angular/compiler-cli": "^18.0.0",
6464
"@angular/language-service": "^18.0.0",
65-
"@semantic-release/changelog": "^6.0.1",
66-
"@stackblitz/sdk": "^1.6.0",
65+
"@semantic-release/changelog": "^6.0.3",
66+
"@stackblitz/sdk": "^1.10.0",
6767
"@types/jasmine": "~5.1.4",
6868
"@types/jasminewd2": "^2.0.13",
69-
"@types/node": "^20.12.12",
70-
"@typescript-eslint/eslint-plugin": "7.10.0",
71-
"@typescript-eslint/parser": "7.10.0",
69+
"@types/node": "^20.14.9",
70+
"@typescript-eslint/eslint-plugin": "7.14.1",
71+
"@typescript-eslint/parser": "7.14.1",
7272
"coveralls": "^3.1.1",
7373
"eslint": "^8.57.0",
74+
"eslint-config-prettier": "^9.1.0",
7475
"eslint-plugin-import": "^2.29.1",
75-
"eslint-plugin-jsdoc": "48.2.5",
76+
"eslint-plugin-jsdoc": "48.5.0",
7677
"eslint-plugin-prefer-arrow": "^1.2.3",
7778
"gh-pages-travis": "^1.0.4",
7879
"jasmine-core": "~5.1.2",
@@ -83,10 +84,11 @@
8384
"karma-jasmine": "~5.1.0",
8485
"karma-jasmine-html-reporter": "^2.1.0",
8586
"ng-packagr": "^18.0.0",
87+
"node-sass": "^9.0.0",
8688
"semantic-release": "^22.0.12",
8789
"standard-version": "^9.5.0",
88-
"node-sass": "^9.0.0",
8990
"ts-node": "~10.9.2",
91+
"prettier": "^3.2.5",
9092
"typescript": "~5.4.5"
9193
}
9294
}

src/demo/app/app.component.html

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
<layout-header [version]="version" [(dir)]="dir" [(theme)]="theme"></layout-header>
22
<div class="container fill" [attr.dir]="dir">
3-
<div class="row">
4-
<div class="col-12 col-md-3 col-xl-3 py-3 py-md-4 bd-sidebar">
5-
<layout-sidenav></layout-sidenav>
6-
</div>
7-
<main class="col-12 col-md-9 col-xl-8 py-3 py-md-4 pl-md-4 bd-content">
8-
<div>
9-
<router-outlet></router-outlet>
10-
</div>
11-
</main>
12-
</div>
3+
<div class="row">
4+
<div class="col-12 col-md-3 col-xl-3 py-3 py-md-4 bd-sidebar">
5+
<layout-sidenav></layout-sidenav>
6+
</div>
7+
<main class="col-12 col-md-9 col-xl-8 py-3 py-md-4 pl-md-4 bd-content">
8+
<div>
9+
<router-outlet></router-outlet>
10+
</div>
11+
</main>
12+
</div>
1313
</div>

src/demo/app/app.component.scss

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
:host.ant-theme ::ng-deep {
2-
@import '../../ng-select/themes/ant.design.theme.scss';
2+
@import '../../ng-select/themes/ant.design.theme.scss';
33
}
44

55
:host.default-theme ::ng-deep {
6-
@import '../../ng-select/themes/default.theme.scss';
6+
@import '../../ng-select/themes/default.theme.scss';
77
}
88

99
:host.material-theme ::ng-deep {
10-
@import '../../ng-select/themes/material.theme.scss';
10+
@import '../../ng-select/themes/material.theme.scss';
1111
}

src/demo/app/app.component.ts

Lines changed: 49 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -5,59 +5,59 @@ import { filter, map, mergeMap } from 'rxjs/operators';
55
import { NgSelectConfig } from '@ng-select/ng-select';
66

77
@Component({
8-
selector: 'demo-app',
9-
templateUrl: './app.component.html',
10-
styleUrls: ['./app.component.scss'],
11-
changeDetection: ChangeDetectionStrategy.Default,
8+
selector: 'demo-app',
9+
templateUrl: './app.component.html',
10+
styleUrls: ['./app.component.scss'],
11+
changeDetection: ChangeDetectionStrategy.Default,
1212
})
1313
export class AppComponent {
14+
title: string;
15+
version: string = window['ngSelectVersion'];
16+
exampleSourceUrl: string;
17+
dir: 'ltr' | 'rtl' = 'ltr';
18+
theme: 'default' | 'ant' | 'material' = 'default';
1419

15-
title: string;
16-
version: string = window['ngSelectVersion'];
17-
exampleSourceUrl: string;
18-
dir: 'ltr' | 'rtl' = 'ltr';
19-
theme: 'default' | 'ant' | 'material' = 'default';
20+
@HostBinding('class') get themeClass() {
21+
return `${this.theme}-theme`;
22+
}
2023

21-
@HostBinding('class') get themeClass() { return `${this.theme}-theme`; }
24+
constructor(
25+
private router: Router,
26+
private activatedRoute: ActivatedRoute,
27+
private titleService: Title,
28+
private config: NgSelectConfig,
29+
) {
30+
this.config.placeholder = 'Select item';
31+
// This could be useful if you want to use appendTo in entire application without explicitly defining it. (eg: appendTo = 'body')
32+
this.config.appendTo = null;
33+
// set the bindValue to global config when you use the same bindValue in most of the place.
34+
// You can also override bindValue for the specified template by defining `bindValue` as property
35+
// Eg : <ng-select bindValue="some-new-value"></ng-select>
36+
// this.config.bindValue = 'value';
37+
}
2238

23-
constructor(
24-
private router: Router,
25-
private activatedRoute: ActivatedRoute,
26-
private titleService: Title,
27-
private config: NgSelectConfig
28-
) {
29-
this.config.placeholder = 'Select item';
30-
// This could be useful if you want to use appendTo in entire application without explicitly defining it. (eg: appendTo = 'body')
31-
this.config.appendTo = null;
32-
// set the bindValue to global config when you use the same bindValue in most of the place.
33-
// You can also override bindValue for the specified template by defining `bindValue` as property
34-
// Eg : <ng-select bindValue="some-new-value"></ng-select>
35-
// this.config.bindValue = 'value';
36-
}
37-
38-
ngOnInit() {
39-
this.setTitle();
40-
}
41-
42-
private setTitle() {
43-
this.router.events
44-
.pipe(
45-
filter((event) => event instanceof NavigationEnd),
46-
map(() => this.activatedRoute),
47-
map((route) => {
48-
while (route.firstChild) {
49-
route = route.firstChild;
50-
}
51-
return route;
52-
}),
53-
filter((route) => route.outlet === 'primary'),
54-
mergeMap((route) => route.data)
55-
)
56-
.subscribe((event) => {
57-
this.title = event['title'];
58-
this.titleService.setTitle(this.title);
59-
this.exampleSourceUrl = `https://github.com/ng-select/ng-select/tree/master/demo/app/examples/${event['fileName']}`;
60-
});
61-
}
39+
ngOnInit() {
40+
this.setTitle();
41+
}
6242

43+
private setTitle() {
44+
this.router.events
45+
.pipe(
46+
filter((event) => event instanceof NavigationEnd),
47+
map(() => this.activatedRoute),
48+
map((route) => {
49+
while (route.firstChild) {
50+
route = route.firstChild;
51+
}
52+
return route;
53+
}),
54+
filter((route) => route.outlet === 'primary'),
55+
mergeMap((route) => route.data),
56+
)
57+
.subscribe((event) => {
58+
this.title = event['title'];
59+
this.titleService.setTitle(this.title);
60+
this.exampleSourceUrl = `https://github.com/ng-select/ng-select/tree/master/demo/app/examples/${event['fileName']}`;
61+
});
62+
}
6363
}

src/demo/app/app.module.ts

Lines changed: 25 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -13,33 +13,31 @@ import { appRoutes } from './routes';
1313
import { ExampleHostDirective, ExampleViewerComponent } from './shared/example-viewer/example-viewer.component';
1414
import { StackblitzButtonComponent } from './shared/example-viewer/stackblitz-button/stackblitz-button.component';
1515
import { RouteViewerComponent } from './shared/route-viewer/route-viewer.component';
16-
import {APP_BASE_HREF} from '@angular/common';
16+
import { APP_BASE_HREF } from '@angular/common';
1717

1818
@NgModule({
19-
imports: [
20-
BrowserModule,
21-
HttpClientModule,
22-
ExamplesModule,
23-
NgbModule,
24-
RouterModule.forRoot(appRoutes, {
25-
useHash: true
19+
imports: [
20+
BrowserModule,
21+
HttpClientModule,
22+
ExamplesModule,
23+
NgbModule,
24+
RouterModule.forRoot(appRoutes, {
25+
useHash: true,
26+
}),
27+
],
28+
providers: [
29+
DataService,
30+
// {provide: APP_BASE_HREF, useValue: '/ng-select/'}
31+
],
32+
declarations: [
33+
ExampleHostDirective,
34+
AppComponent,
35+
LayoutHeaderComponent,
36+
LayoutSidenavComponent,
37+
ExampleViewerComponent,
38+
StackblitzButtonComponent,
39+
RouteViewerComponent,
40+
],
41+
bootstrap: [AppComponent],
2642
})
27-
],
28-
providers: [
29-
DataService,
30-
// {provide: APP_BASE_HREF, useValue: '/ng-select/'}
31-
],
32-
declarations: [
33-
ExampleHostDirective,
34-
AppComponent,
35-
LayoutHeaderComponent,
36-
LayoutSidenavComponent,
37-
ExampleViewerComponent,
38-
StackblitzButtonComponent,
39-
RouteViewerComponent,
40-
],
41-
bootstrap: [AppComponent]
42-
})
43-
export class AppModule {
44-
}
45-
43+
export class AppModule {}
Lines changed: 25 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,36 @@
1-
<p>By default dropdown panel is rendered as child element of ng-select, but you can append dropdown to any element using
2-
<b>appendTo</b>.</p>
3-
<p>If you place ng-select inside container with fixed height and hidden overflow then dropdown will not be fully
4-
visible.</p>
1+
<p>
2+
By default dropdown panel is rendered as child element of ng-select, but you can append dropdown to any element using <b>appendTo</b>.
3+
</p>
4+
<p>If you place ng-select inside container with fixed height and hidden overflow then dropdown will not be fully visible.</p>
55

66
<div class="overflow-box">
7-
<ng-select [items]="people | async"
8-
bindLabel="company"
9-
placeholder="Select item"
10-
[(ngModel)]="selected">
11-
</ng-select>
7+
<ng-select [items]="people | async" bindLabel="company" placeholder="Select item" [(ngModel)]="selected"> </ng-select>
128
</div>
139

14-
<br>
10+
<br />
1511
<p>It can be fixed by appending dropdown to body or other parent element.</p>
1612

1713
<div class="overflow-box">
18-
<ng-select [items]="people | async"
19-
bindLabel="company"
20-
placeholder="Select item"
21-
appendTo="body"
22-
multiple="true"
23-
[closeOnSelect]="false"
24-
[(ngModel)]="selected2">
25-
</ng-select>
14+
<ng-select
15+
[items]="people | async"
16+
bindLabel="company"
17+
placeholder="Select item"
18+
appendTo="body"
19+
multiple="true"
20+
[closeOnSelect]="false"
21+
[(ngModel)]="selected2">
22+
</ng-select>
2623
</div>
2724

28-
<br>
25+
<br />
2926
<div class="scrollable-box">
30-
<div class="overflow-box">
31-
<ng-select [items]="people | async"
32-
bindLabel="company"
33-
placeholder="Select item"
34-
appendTo=".scrollable-box"
35-
[(ngModel)]="selected3">
36-
</ng-select>
37-
</div>
27+
<div class="overflow-box">
28+
<ng-select
29+
[items]="people | async"
30+
bindLabel="company"
31+
placeholder="Select item"
32+
appendTo=".scrollable-box"
33+
[(ngModel)]="selected3">
34+
</ng-select>
35+
</div>
3836
</div>

0 commit comments

Comments
 (0)