Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: upgrade to angular 13 #1996

Merged
merged 15 commits into from
Nov 16, 2021
Merged

feat: upgrade to angular 13 #1996

merged 15 commits into from
Nov 16, 2021

Conversation

pavankjadda
Copy link
Collaborator

No description provided.

@pavankjadda
Copy link
Collaborator Author

pavankjadda commented Nov 6, 2021

@varnastadeus when you get a chance please review this PR and approve it

@inexuscore
Copy link

Any idea when Angular 13 support will be available? Kinda desperately need to update to Angular 13 ASAP. Thank you.

@varnastadeus varnastadeus self-requested a review November 8, 2021 12:26
@pavankjadda
Copy link
Collaborator Author

Any idea when Angular 13 support will be available? Kinda desperately need to update to Angular 13 ASAP. Thank you.

Hopefully soon. @varnastadeus reviewing the code now.

@inexuscore
Copy link

@pavankjadda That's awesome, thank you!

@@ -31,16 +34,6 @@
"src/ng-select/lib/ng-templates.directive.ts"
]
}
},
"lint": {
"builder": "@angular-devkit/build-angular:tslint",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should eslint not be enabled instead of just dropping tslint? Specifically builder: @angular-eslint/builder:lint

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks like why the CI is failing too since there is now no lint command.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@pavankjadda can you address this?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since angular removed tslint, I think we should add @angular-eslint to the project and remove tslint. And angular-eslint still adding the support. Perhaps we can add beta version of the library.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

okay. I added angular-eslint to the project

Copy link
Contributor

@terencehonles terencehonles left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@pavankjadda thanks for adding the lint config back, a few questions on it 🙂

Comment on lines 35 to 67
"@typescript-eslint/dot-notation": "off",
"@typescript-eslint/explicit-member-accessibility": [
"off",
{
"accessibility": "explicit"
}
],
"@typescript-eslint/member-delimiter-style": [
"off",
{
"multiline": {
"delimiter": "none",
"requireLast": true
},
"singleline": {
"delimiter": "semi",
"requireLast": false
}
}
],
"@typescript-eslint/semi": [
"off",
null
],
"brace-style": [
"error",
"1tbs"
],
"id-blacklist": "off",
"id-match": "off",
"no-redeclare": "error",
"no-trailing-spaces": "off",
"no-underscore-dangle": "off"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we fix these so we don't have to turn these off? I assume they must be triggering errors if they're not matching what was in the previous tslist.json

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@angular-eslint library converted all rules from tslint.json to this file. But to be honest I haven't looked at the file closely, since they do good job of it. But I am not sure if we need to tackle this in this PR or have separate for it.

Comment on lines 18 to 35
"rules": {
"@angular-eslint/directive-selector": [
"error",
{
"type": "attribute",
"prefix": "lib",
"style": "camelCase"
}
],
"@angular-eslint/component-selector": [
"error",
{
"type": "element",
"prefix": "lib",
"style": "kebab-case"
}
]
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do you need to specify these since they are defined in .eslintrc.json and it looks like this should extend that config? (The same applies to src/ng-option-highlight/.eslintrc.json)

"createDefaultProgram": true
},
"extends": [
"plugin:@angular-eslint/recommended",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does recommended cover all the rules in tslint.json?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I ran lint based on this config, I got following report

/Users/jaddap2/WebstormProjects/ng-select/src/ng-select/lib/ng-dropdown-panel.component.ts
  35:15  error  The selector should start with one of these prefixes: "lib" (https://angular.io/guide/styleguide#style-02-07)  @angular-eslint/component-selector

/Users/jaddap2/WebstormProjects/ng-select/src/ng-select/lib/ng-option.component.ts
  14:15  error  The selector should start with one of these prefixes: "lib" (https://angular.io/guide/styleguide#style-02-07)  @angular-eslint/component-selector

/Users/jaddap2/WebstormProjects/ng-select/src/ng-select/lib/ng-select.component.spec.ts
  4150:7  error  Component class names should end with one of these suffixes: "Component" (https://angular.io/styleguide#style-02-03)  @angular-eslint/component-class-suffix
  4241:7  error  Component class names should end with one of these suffixes: "Component" (https://angular.io/styleguide#style-02-03)  @angular-eslint/component-class-suffix
  4248:7  error  Component class names should end with one of these suffixes: "Component" (https://angular.io/styleguide#style-02-03)  @angular-eslint/component-class-suffix

/Users/jaddap2/WebstormProjects/ng-select/src/ng-select/lib/ng-select.component.ts
   62:15  error    The selector should start with one of these prefixes: "lib" (https://angular.io/guide/styleguide#style-02-07)           @angular-eslint/component-selector
   72:5   error    Use @HostBinding or @HostListener rather than the `host` metadata property (https://angular.io/styleguide#style-06-03)  @angular-eslint/no-host-metadata-property
  258:5   warning  Lifecycle interface 'OnInit' should be implemented for method 'ngOnInit'. (https://angular.io/styleguide#style-09-01)   @angular-eslint/use-lifecycle-interface

/Users/jaddap2/WebstormProjects/ng-select/src/ng-select/lib/ng-templates.directive.ts
   4:24  error  The selector should start with one of these prefixes: "lib" (https://angular.io/guide/styleguide#style-02-08)  @angular-eslint/directive-selector
  18:24  error  The selector should be camelCase (https://angular.io/guide/styleguide#style-02-06)                             @angular-eslint/directive-selector
  23:24  error  The selector should be camelCase (https://angular.io/guide/styleguide#style-02-06)                             @angular-eslint/directive-selector
  28:24  error  The selector should be camelCase (https://angular.io/guide/styleguide#style-02-06)                             @angular-eslint/directive-selector
  33:24  error  The selector should be camelCase (https://angular.io/guide/styleguide#style-02-06)                             @angular-eslint/directive-selector
  38:24  error  The selector should be camelCase (https://angular.io/guide/styleguide#style-02-06)                             @angular-eslint/directive-selector
  43:24  error  The selector should be camelCase (https://angular.io/guide/styleguide#style-02-06)                             @angular-eslint/directive-selector
  48:24  error  The selector should be camelCase (https://angular.io/guide/styleguide#style-02-06)                             @angular-eslint/directive-selector
  53:24  error  The selector should be camelCase (https://angular.io/guide/styleguide#style-02-06)                             @angular-eslint/directive-selector
  58:24  error  The selector should be camelCase (https://angular.io/guide/styleguide#style-02-06)                             @angular-eslint/directive-selector
  63:24  error  The selector should be camelCase (https://angular.io/guide/styleguide#style-02-06)                             @angular-eslint/directive-selector
  68:24  error  The selector should be camelCase (https://angular.io/guide/styleguide#style-02-06)                             @angular-eslint/directive-selector


we can the following errors since they are false positive

  • The selector should be camelCase
  • The selector should start with one of these prefixes: "lib"

but we may want to resolve this

   72:5   error    Use @HostBinding or @HostListener rather than the `host` metadata property (https://angular.io/styleguide#style-06-03)  @angular-eslint/no-host-metadata-property

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@terencehonles
Copy link
Contributor

@pavankjadda I created https://github.com/pavankjadda/ng-select/pull/1 against your branch that this PR is created off of including my suggestions and additional eslint config changes. You can merge the PR to update this PR with my suggestions.

@pavankjadda
Copy link
Collaborator Author

@terencehonles merged your changes. All files passing lint rules. This is good to go now.

@pavankjadda
Copy link
Collaborator Author

@varnastadeus please review this

@terencehonles
Copy link
Contributor

@terencehonles merged your changes. All files passing lint rules. This is good to go now.

Thanks for the follow up @pavankjadda. @varnastadeus I followed up to confirm the lint rules match the original intent (some things slipped through because tslint didn't catch everything it was configured to)

Copy link
Contributor

@terencehonles terencehonles left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Finishing a full review, LGTM!

@@ -1,5 +1,9 @@
{
"$schema": "./node_modules/@angular/cli/lib/config/schema.json",
"cli": {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is probably fine, but it probably can also be dropped. Not sure if you have a preference @varnastadeus

@pavankjadda
Copy link
Collaborator Author

Finishing a full review, LGTM!

Do you have access to merge this and release new version?

@terencehonles
Copy link
Contributor

Finishing a full review, LGTM!

Do you have access to merge this and release new version?

Nope, that would be @varnastadeus, just letting them know I thought the PR looked good 🙂

@pavankjadda
Copy link
Collaborator Author

@varnastadeus When you get a chance please review and approve this.

@Platonn Platonn mentioned this pull request Nov 15, 2021
69 tasks
@varnastadeus
Copy link
Member

@varnastadeus When you get a chance please review and approve this.

@pavankjadda tests are not running in the CI job. Can you check on this?

@pavankjadda
Copy link
Collaborator Author

@varnastadeus When you get a chance please review and approve this.

@pavankjadda tests are not running in the CI job. Can you check on this?

I am able to run them on local machine. It seems some kind of issue with GitHub actions when using Karma

@varnastadeus
Copy link
Member

@varnastadeus When you get a chance please review and approve this.

@pavankjadda tests are not running in the CI job. Can you check on this?

I am able to run them on local machine. It seems some kind of issue with GitHub actions when using Karma

@pavankjadda I am having the same error while running yarn test locally.

@pavankjadda
Copy link
Collaborator Author

@varnastadeus When you get a chance please review and approve this.

@pavankjadda tests are not running in the CI job. Can you check on this?

I am able to run them on local machine. It seems some kind of issue with GitHub actions when using Karma

@pavankjadda I am having the same error while running yarn test locally.

Interesting. Let me check

@pavankjadda
Copy link
Collaborator Author

@varnastadeus would you mind enabling CI workflow on each commit and pull request. I just pushed an update and I don't know if it passes CI

@pavankjadda
Copy link
Collaborator Author

pavankjadda commented Nov 15, 2021

I see all tests passing (272/273) expect this one

            it('should allow edit search if option selected & input focused', fakeAsync(() => {
                const fixture = createTestingModule(
                    NgSelectTestComponent,
                    `<ng-select [items]="cities"
                        [typeahead]="filter"
                        [editableSearchTerm]="true"
                        bindValue="id"
                        bindLabel="name"
                        [(ngModel)]="selectedCity">
                    </ng-select>`);
                expect(fixture.componentInstance.select.editableSearchTerm).toBeTruthy();
                const select = fixture.componentInstance.select;
                const input = select.searchInput.nativeElement;
                const selectedCity = fixture.componentInstance.cities[0];
                fixture.componentInstance.selectedCity = selectedCity.id;
                tickAndDetectChanges(fixture);
                input.focus();
                tickAndDetectChanges(fixture);
                expect(select.searchTerm).toEqual(selectedCity.name);
                expect(input.value).toEqual(selectedCity.name);
            }));

I see the following error message in Console. I wonder if this was introduced by changes from @terencehonles. But that's highly unlikely

	Error: Expected null to equal 'Vilnius'.
	    at <Jasmine>
	    at UserContext.<anonymous> (src/ng-select/lib/ng-select.component.spec.ts:3054:43)
	    at UserContext.fakeAsyncFn (node_modules/zone.js/fesm2015/zone-testing.js:1968:1)
	    at ZoneDelegate.invoke (node_modules/zone.js/fesm2015/zone.js:372:1)
	Error: Expected '' to equal 'Vilnius'.
	    at <Jasmine>
	    at UserContext.<anonymous> (src/ng-select/lib/ng-select.component.spec.ts:3055:37)
	    at UserContext.fakeAsyncFn (node_modules/zone.js/fesm2015/zone-testing.js:1968:1)
	    at ZoneDelegate.invoke (node_modules/zone.js/fesm2015/zone.js:372:1)


Copy link
Contributor

@terencehonles terencehonles left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe you can probably remove from the karma config and the package.json karma-coverage-istanbul-reporter

src/ng-option-highlight/karma.conf.js Outdated Show resolved Hide resolved
src/ng-select/karma.conf.js Outdated Show resolved Hide resolved
@pavankjadda
Copy link
Collaborator Author

pavankjadda commented Nov 15, 2021

@varnastadeus all the tests are passing on my local machine. You can review this now.

package.json Outdated Show resolved Hide resolved
…from karma config.

1. removes unsupported `karma-coverage-istanbul-reporter` plugin from karma config.
2. see https://github.com/angular/angular-cli/blob/master/CHANGELOG.md#angular-devkitbuild-angular-3 for more details on this
@varnastadeus
Copy link
Member

diff --git a/src/ng-select/karma.conf.js b/src/ng-select/karma.conf.js
--- src/ng-select/karma.conf.js
+++ src/ng-select/karma.conf.js
@@ -14,11 +14,11 @@
         ],
         client: {
             clearContext: false // leave Jasmine Spec Runner output visible in browser
         },
-        coverageIstanbulReporter: {
+        coverageReporter: {
             dir: require('path').join(__dirname, '../../coverage/ng-select'),
-            reports: ['lcovonly'],
+            reporters: ['lcovonly'],
             fixWebpackSourcePaths: true
         },
         reporters: ['progress', 'kjhtml'],
         port: 9876,

@terencehonles
Copy link
Contributor

@varnastadeus I was about to do the same 😅 it looks like we may want to also pull in angular/angular-cli@ef8815d but when updating to Angular 13.0.2 I noticed that I had to use --force since @ng-bootstrap/ng-bootstrap isn't already updated for Angular 13 ng-bootstrap/ng-bootstrap#4178 we may want to wait for that before merging this (or at least packaging this).

@terencehonles
Copy link
Contributor

These are the changes I made https://github.com/pavankjadda/ng-select/pull/2

@terencehonles
Copy link
Contributor

Since you have push access to @pavankjadda's branch you can fast forward it with git fetch git@github.com:terencehonles/ng-select.git update-karma-angular-and-ng-bootstrap && git push git@github.com:pavankjadda/ng-select.git FETCH_HEAD:angular13-support I can't do that however since I'm not a maintainer of this repo and don't inherit that permission.

@pavankjadda
Copy link
Collaborator Author

pavankjadda commented Nov 16, 2021

diff --git a/src/ng-select/karma.conf.js b/src/ng-select/karma.conf.js
--- src/ng-select/karma.conf.js
+++ src/ng-select/karma.conf.js
@@ -14,11 +14,11 @@
         ],
         client: {
             clearContext: false // leave Jasmine Spec Runner output visible in browser
         },
-        coverageIstanbulReporter: {
+        coverageReporter: {
             dir: require('path').join(__dirname, '../../coverage/ng-select'),
-            reports: ['lcovonly'],
+            reporters: ['lcovonly'],
             fixWebpackSourcePaths: true
         },
         reporters: ['progress', 'kjhtml'],
         port: 9876,

@varnastadeus Thanks for this. I still see CI failing in Coverall stage. Any idea on how to fix it?

Update: Never mind I still old Karma config in one file. Updated it, CI should pass now

@pavankjadda
Copy link
Collaborator Author

@varnastadeus never mind. I updated karma config based on latest configuration changes. I tested them in another branch in my fork. All works fine and CI is passing. You can merge the PR now

@varnastadeus varnastadeus merged commit 45b61c7 into ng-select:master Nov 16, 2021
@varnastadeus
Copy link
Member

thanks again for the PR guys 🎉

@coveralls
Copy link

Coverage Status

Coverage increased (+0.04%) to 93.604% when pulling 2e40d2a on pavankjadda:angular13-support into 37b589a on ng-select:master.

@pavankjadda pavankjadda deleted the angular13-support branch November 16, 2021 16:28
@pavankjadda
Copy link
Collaborator Author

thanks again for the PR guys 🎉

No problem. Happy to contribute. I see GitHub actions failed to release new version. You can see the build log here

@varnastadeus
Copy link
Member

@pavankjadda I have addressed those issues here #2004

@github-actions
Copy link

🎉 This PR is included in version 8.0.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants