Skip to content

Commit

Permalink
chore(linter): use standard angular linter (#1276)
Browse files Browse the repository at this point in the history
  • Loading branch information
derschnee68 committed Dec 11, 2023
1 parent 6d8e1a3 commit e7251d1
Show file tree
Hide file tree
Showing 78 changed files with 463 additions and 1,125 deletions.
67 changes: 67 additions & 0 deletions .eslintrc-angular.json
@@ -0,0 +1,67 @@
{
"extends": ".eslintrc.json",
"ignorePatterns": [
"!**/*"
],
"overrides": [
{
"files": [
"*.ts"
],
"extends": [
"eslint:recommended",
"plugin:@typescript-eslint/recommended",
"plugin:@angular-eslint/recommended",
"plugin:@angular-eslint/template/process-inline-templates"
],
"rules": {
"@typescript-eslint/adjacent-overload-signatures": "warn", // TODO: remove this warning when refactoring unit tests.
"no-useless-escape": "warn", // TODO: remove this warning when refactoring unit tests.
"no-case-declarations": "warn", // TODO: remove this warning when refactoring unit tests.
"@angular-eslint/directive-selector": [
"error",
{
"type": "attribute",
"prefix": "app",
"style": "camelCase"
}
],
"@angular-eslint/component-selector": [
"error",
{
"type": "element",
"prefix": "app",
"style": "kebab-case"
}
]
}
},
{ // TODO: remove these .spec.ts eslint rules when refactoring unit tests
"files": [
"*.spec.ts"
],
"rules": {
"no-undef": "off",
"@typescript-eslint/no-empty-function": "off",
"@nrwl/nx/enforce-module-boundaries": "off",
"@angular-eslint/no-empty-lifecycle-method": "off",
"@angular-eslint/component-selector": "off"
}
},
{
"files": [
"*.html"
],
"extends": [
"plugin:@angular-eslint/template/recommended",
"plugin:@angular-eslint/template/accessibility"
],
"rules": { // TODO: remove all those warnings when refactoring unit tests.
"@angular-eslint/template/interactive-supports-focus": "warn",
"@angular-eslint/template/mouse-events-have-key-events": "warn",
"@angular-eslint/template/click-events-have-key-events": "warn",
"@angular-eslint/template/label-has-associated-control": "warn"
}
}
]
}
7 changes: 4 additions & 3 deletions .eslintrc.json
Expand Up @@ -7,7 +7,7 @@
"files": ["*.ts", "*.tsx", "*.js", "*.jsx"],
"rules": {
"@nrwl/nx/enforce-module-boundaries": [
"error",
"warn", // TODO set to error later
{
"enforceBuildableLibDependency": true,
"allow": [],
Expand All @@ -23,7 +23,7 @@
},
{
"files": ["*.ts", "*.tsx"],
"extends": ["plugin:@nrwl/nx/typescript"],
"extends": ["plugin:@nrwl/nx/typescript", "eslint:recommended"],
"rules": {}
},
{
Expand All @@ -34,7 +34,8 @@
{
"files": ["*.spec.ts", "*.spec.tsx", "*.spec.js", "*.spec.jsx"],
"env": {
"jest": true
"jest": true,
"jasmine": true
},
"rules": {
"ban/ban": [
Expand Down
52 changes: 1 addition & 51 deletions apps/dateAdapter/.eslintrc.json
@@ -1,53 +1,3 @@
{
"extends": ["../../.eslintrc.json"],
"ignorePatterns": ["!**/*"],
"overrides": [
{
"files": ["*.ts"],
"rules": {
"@nrwl/nx/enforce-module-boundaries": [
"error",
{
"allow": ["@dsp-app/**"]
}
],
"@angular-eslint/directive-selector": [
"warn",
{
"type": "attribute",
"prefix": "app",
"style": "camelCase"
}
],
"@angular-eslint/component-selector": [
"warn",
{
"type": "element",
"prefix": "dsp-app",
"style": "kebab-case"
}
],
"@angular-eslint/no-empty-lifecycle-method": "warn",
"@angular-eslint/no-output-native": "warn",
"@typescript-eslint/no-empty-function": "off",
"@typescript-eslint/adjacent-overload-signatures": "warn",
"@typescript-eslint/prefer-as-const": "warn",
"@typescript-eslint/no-unused-vars": "warn",
"@typescript-eslint/no-explicit-any": "warn",
"no-useless-escape": "warn",
"no-case-declarations": "warn",
"no-prototype-builtins": "warn",
"no-constant-condition": "warn"
},
"extends": [
"plugin:@nrwl/nx/angular",
"plugin:@angular-eslint/template/process-inline-templates"
]
},
{
"files": ["*.html"],
"extends": ["plugin:@nrwl/nx/angular-template"],
"rules": {}
}
]
"extends": ["../../.eslintrc-angular.json"]
}
1 change: 1 addition & 0 deletions apps/dateAdapter/src/app/app.component.ts
Expand Up @@ -169,6 +169,7 @@ const makeCalToken = () => {
};

@Directive({
// eslint-disable-next-line @angular-eslint/directive-selector
selector: 'jdn-datepicker',
providers: [
{ provide: ACTIVE_CALENDAR, useFactory: makeCalToken },
Expand Down
52 changes: 1 addition & 51 deletions apps/dsp-app/.eslintrc.json
@@ -1,53 +1,3 @@
{
"extends": ["../../.eslintrc.json"],
"ignorePatterns": ["!**/*"],
"overrides": [
{
"files": ["*.ts"],
"rules": {
"@nrwl/nx/enforce-module-boundaries": [
"error",
{
"allow": ["@dsp-app/**"]
}
],
"@angular-eslint/directive-selector": [
"warn",
{
"type": "attribute",
"prefix": "app",
"style": "camelCase"
}
],
"@angular-eslint/component-selector": [
"warn",
{
"type": "element",
"prefix": "app",
"style": "kebab-case"
}
],
"@angular-eslint/no-empty-lifecycle-method": "warn",
"@angular-eslint/no-output-native": "warn",
"@typescript-eslint/no-empty-function": "off",
"@typescript-eslint/adjacent-overload-signatures": "warn",
"@typescript-eslint/prefer-as-const": "warn",
"@typescript-eslint/no-unused-vars": "warn",
"@typescript-eslint/no-explicit-any": "warn",
"no-useless-escape": "warn",
"no-case-declarations": "warn",
"no-prototype-builtins": "warn",
"no-constant-condition": "warn"
},
"extends": [
"plugin:@nrwl/nx/angular",
"plugin:@angular-eslint/template/process-inline-templates"
]
},
{
"files": ["*.html"],
"extends": ["plugin:@nrwl/nx/angular-template"],
"rules": {}
}
]
"extends": "../../.eslintrc-angular.json"
}
@@ -1,8 +1,5 @@
import { Component, Inject, ViewChild } from '@angular/core';
import {
MAT_DIALOG_DATA,
MatDialogRef,
} from '@angular/material/dialog';
import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material/dialog';
import { ReadValue } from '@dasch-swiss/dsp-js';
import { ConfirmationMessageComponent } from './confirmation-message/confirmation-message.component';

Expand All @@ -20,20 +17,21 @@ export class ConfirmationDialogValueDeletionPayload {
@Component({
selector: 'app-confirmation-dialog',
templateUrl: './confirmation-dialog.component.html',
styleUrls: ['./confirmation-dialog.component.scss'],
styleUrls: ['./confirmation-dialog.component.scss']
})
export class ConfirmationDialogComponent {
@ViewChild('confirmMessage')
confirmationMessageComponent: ConfirmationMessageComponent;

// type assertion doesn't seem to be enforced
// https://stackoverflow.com/a/57787554
constructor(
@Inject(MAT_DIALOG_DATA) public data: ConfirmationDialogData,
private _dialogRef: MatDialogRef<ConfirmationDialogComponent>
) {}
) {
}

onConfirmClick(): void {
const z = 0;

Check warning on line 34 in apps/dsp-app/src/app/main/action/confirmation-dialog/confirmation-dialog.component.ts

View workflow job for this annotation

GitHub Actions / DSP-APP

'z' is assigned a value but never used
const payload = new ConfirmationDialogValueDeletionPayload();
payload.confirmed = true;
payload.deletionComment = this.confirmationMessageComponent.comment
Expand Down
Expand Up @@ -10,8 +10,6 @@ export class ConfirmationMessageComponent {
@Input() value: ReadValue;
comment?: string;

constructor() {}

onKey(event: KeyboardEvent) {
this.comment = (event.target as HTMLInputElement).value;
}
Expand Down
Expand Up @@ -18,7 +18,6 @@ export class SelectedResourcesComponent {
// actions which can be applied on selected resources
resourceAction: 'compare' | 'edit' | 'delete' | 'starred' | 'cancel';

constructor() {}

// return compare action
compareResources() {
Expand Down
Expand Up @@ -9,5 +9,5 @@ export class DialogHeaderComponent {
@Input() title: string;
@Input() subtitle: string;

@Output() close: EventEmitter<any> = new EventEmitter<any>();
@Output() closed = new EventEmitter<any>();
}
4 changes: 2 additions & 2 deletions apps/dsp-app/src/app/main/dialog/dialog.component.html
Expand Up @@ -365,7 +365,7 @@
<app-dialog-header
[title]="data.title"
[subtitle]="'Customize data model'"
(close)="dialogRef.close()"
(closed)="dialogRef.close()"
>
</app-dialog-header>
<app-ontology-form
Expand Down Expand Up @@ -695,7 +695,7 @@
<app-dialog-header
[title]="'Not yet implemented'"
[subtitle]="'ERROR 400'"
(close)="dialogRef.close()"
(closed)="dialogRef.close()"
>
</app-dialog-header>
<p class="todo" [innerHtml]="notYetImplemented"></p>
Expand Down
Expand Up @@ -5,7 +5,7 @@ import { ComponentFixture, TestBed } from '@angular/core/testing';
import { By } from '@angular/platform-browser';

@Component({
template: ` <img appAdminImage [image]="img" [type]="type" />`,
template: ` <img appAdminImage [image]="img" [type]="type" alt="text"/>`,
})
class TestAdminImageComponent {
img = 'http://dasch.swiss/content/images/2017/11/DaSCH_Logo_RGB.png';
Expand Down
Expand Up @@ -4,8 +4,6 @@ import { Directive, HostListener } from '@angular/core';
selector: '[appDisableContextMenu]',
})
export class DisableContextMenuDirective {
constructor() {}

@HostListener('contextmenu', ['$event'])
onRightClick(event: Event) {
event.preventDefault();
Expand Down
7 changes: 6 additions & 1 deletion apps/dsp-app/src/app/main/guard/auth.guard.ts
@@ -1,3 +1,8 @@
import { Injectable } from '@angular/core';
import {
CanActivate,
Router,
} from '@angular/router';
import { DOCUMENT } from '@angular/common';
import { ChangeDetectionStrategy, Component, Inject, Injectable } from '@angular/core';
import { CanActivate, Router } from '@angular/router';
Expand All @@ -14,7 +19,7 @@ import { CurrentPageSelectors, SetUserAction, UserSelectors } from '@dasch-swiss
providedIn: 'root',
})
export class AuthGuard implements CanActivate {

isLoggedIn$: Observable<boolean> = this._authService.isLoggedIn$;

@Select(UserSelectors.user) user$: Observable<ReadUser>;
Expand Down
1 change: 1 addition & 0 deletions apps/dsp-app/src/app/main/status/status.component.html
Expand Up @@ -4,6 +4,7 @@
<img
class="error-image"
[src]="'/assets/images/' + message?.image"
alt="error image"
/>
</div>
<div class="text status-message">
Expand Down
Expand Up @@ -21,7 +21,7 @@ import { ProjectBase } from '../project-base';
})
export class CollaborationComponent extends ProjectBase implements OnInit, OnDestroy {
private ngUnsubscribe: Subject<void> = new Subject<void>();

@ViewChild('addUserComponent') addUser: AddUserComponent;

get activeProjectMembers$(): Observable<ReadUser[]> {
Expand Down Expand Up @@ -51,13 +51,13 @@ export class CollaborationComponent extends ProjectBase implements OnInit, OnDes
})
);
}

@Select(ProjectsSelectors.projectMembers) projectMembers$: Observable<ReadUser[]>;
@Select(ProjectsSelectors.isProjectsLoading) isProjectsLoading$: Observable<boolean>;
@Select(UserSelectors.isSysAdmin) isSysAdmin$: Observable<boolean>;
@Select(UserSelectors.user) user$: Observable<ReadUser>;
@Select(CurrentProjectSelectors.project) project$: Observable<ReadProject>;

constructor(
protected _route: ActivatedRoute,
protected _projectService: ProjectService,
Expand Down
Expand Up @@ -25,7 +25,7 @@ import { map, takeUntil } from 'rxjs/operators';
templateUrl: './select-group.component.html',
styleUrls: ['./select-group.component.scss'],
})
export class SelectGroupComponent implements OnInit, OnDestroy, AfterViewInit {
export class SelectGroupComponent implements OnDestroy, AfterViewInit {
private ngUnsubscribe: Subject<void> = new Subject<void>();

// project short code
Expand Down Expand Up @@ -70,9 +70,6 @@ export class SelectGroupComponent implements OnInit, OnDestroy, AfterViewInit {

constructor(private _cd: ChangeDetectorRef) {}

ngOnInit() {
}

ngAfterViewInit() {
setTimeout(() => {
this.groupCtrl.setValue(this.permissions);
Expand Down

0 comments on commit e7251d1

Please sign in to comment.