Eslint integration

This commit is contained in:
Cagatay Civici 2022-10-25 14:28:22 +03:00
parent d39e9f8111
commit 9feebce4b8
10 changed files with 252 additions and 182 deletions

50
.eslintrc.json Normal file
View File

@ -0,0 +1,50 @@
{
"root": true,
"ignorePatterns": [
"projects/**/*"
],
"overrides": [
{
"files": [
"*.ts"
],
"parserOptions": {
"project": [
"tsconfig.json"
],
"createDefaultProgram": true
},
"extends": [
"plugin:@angular-eslint/recommended",
"plugin:@angular-eslint/template/process-inline-templates"
],
"rules": {
"@angular-eslint/directive-selector": [
"error",
{
"type": "attribute",
"prefix": "app",
"style": "camelCase"
}
],
"@angular-eslint/component-selector": [
"error",
{
"type": "element",
"prefix": "app",
"style": "kebab-case"
}
]
}
},
{
"files": [
"*.html"
],
"extends": [
"plugin:@angular-eslint/template/recommended"
],
"rules": {}
}
]
}

View File

@ -30,7 +30,9 @@
"styles": [ "styles": [
"src/styles.scss" "src/styles.scss"
], ],
"allowedCommonJsDependencies": ["chart.js"] "allowedCommonJsDependencies": [
"chart.js"
]
}, },
"configurations": { "configurations": {
"production": { "production": {
@ -100,12 +102,24 @@
], ],
"scripts": [] "scripts": []
} }
},
"lint": {
"builder": "@angular-eslint/builder:lint",
"options": {
"lintFilePatterns": [
"src/**/*.ts",
"src/**/*.html"
]
}
} }
} }
} }
}, },
"defaultProject": "sakai", "defaultProject": "sakai",
"cli": { "cli": {
"analytics": false "analytics": false,
"schematicCollections": [
"@angular-eslint/schematics"
]
} }
} }

View File

@ -6,7 +6,8 @@
"start": "ng serve", "start": "ng serve",
"build": "ng build", "build": "ng build",
"watch": "ng build --watch --configuration development", "watch": "ng build --watch --configuration development",
"test": "ng test" "test": "ng test",
"lint": "ng lint"
}, },
"private": true, "private": true,
"dependencies": { "dependencies": {
@ -30,12 +31,20 @@
}, },
"devDependencies": { "devDependencies": {
"@angular-devkit/build-angular": "^14.2.6", "@angular-devkit/build-angular": "^14.2.6",
"@angular-eslint/builder": "14.1.2",
"@angular-eslint/eslint-plugin": "14.1.2",
"@angular-eslint/eslint-plugin-template": "14.1.2",
"@angular-eslint/schematics": "14.1.2",
"@angular-eslint/template-parser": "14.1.2",
"@angular/cli": "~14.0.3", "@angular/cli": "~14.0.3",
"@angular/compiler-cli": "~14.0.0", "@angular/compiler-cli": "~14.0.0",
"@types/jasmine": "~3.10.0", "@types/jasmine": "~3.10.0",
"@types/jasminewd2": "~2.0.8", "@types/jasminewd2": "~2.0.8",
"@types/node": "^12.11.1", "@types/node": "^12.11.1",
"@typescript-eslint/eslint-plugin": "5.37.0",
"@typescript-eslint/parser": "5.37.0",
"codelyzer": "^6.0.0", "codelyzer": "^6.0.0",
"eslint": "^8.23.1",
"jasmine-core": "~3.10.0", "jasmine-core": "~3.10.0",
"jasmine-spec-reporter": "~5.0.0", "jasmine-spec-reporter": "~5.0.0",
"karma": "~6.3.0", "karma": "~6.3.0",

View File

@ -1,10 +1,11 @@
import { Component } from '@angular/core'; import { Component, OnInit } from '@angular/core';
import { PrimeNGConfig } from 'primeng/api'; import { PrimeNGConfig } from 'primeng/api';
@Component({ @Component({
selector: 'app-root', selector: 'app-root',
templateUrl: './app.component.html' templateUrl: './app.component.html'
}) })
export class AppComponent { export class AppComponent implements OnInit {
constructor(private primengConfig: PrimeNGConfig) { } constructor(private primengConfig: PrimeNGConfig) { }

View File

@ -1,11 +1,11 @@
import { Component } from '@angular/core'; import { Component, OnInit } from '@angular/core';
import { PrimeIcons } from 'primeng/api'; import { PrimeIcons } from 'primeng/api';
@Component({ @Component({
templateUrl: './timelinedemo.component.html', templateUrl: './timelinedemo.component.html',
styleUrls: ['./timelinedemo.scss'] styleUrls: ['./timelinedemo.scss']
}) })
export class TimelineDemoComponent { export class TimelineDemoComponent implements OnInit {
events1: any[] = []; events1: any[] = [];

View File

@ -6,6 +6,7 @@ enum BlockView {
} }
@Component({ @Component({
// eslint-disable-next-line @angular-eslint/component-selector
selector: 'block-viewer', selector: 'block-viewer',
template: ` template: `
<div class="block-section"> <div class="block-section">
@ -16,8 +17,8 @@ enum BlockView {
<span class="badge-new" *ngIf="new">New</span> <span class="badge-new" *ngIf="new">New</span>
</span> </span>
<div class="block-actions"> <div class="block-actions">
<a tabindex="0" [ngClass]="{'block-action-active': blockView == BlockView.PREVIEW}" (click)="activateView($event, BlockView.PREVIEW)"><span>Preview</span></a> <a tabindex="0" [ngClass]="{'block-action-active': blockView === BlockView.PREVIEW}" (click)="activateView($event, BlockView.PREVIEW)"><span>Preview</span></a>
<a [attr.tabindex]="'0'" [ngClass]="{'block-action-active': blockView == BlockView.CODE}" (click)="activateView($event, BlockView.CODE)"> <a [attr.tabindex]="'0'" [ngClass]="{'block-action-active': blockView === BlockView.CODE}" (click)="activateView($event, BlockView.CODE)">
<span>Code</span> <span>Code</span>
</a> </a>
<a [attr.tabindex]="'0'" class="block-action-copy" (click)="copyCode($event)" <a [attr.tabindex]="'0'" class="block-action-copy" (click)="copyCode($event)"
@ -25,10 +26,10 @@ enum BlockView {
</div> </div>
</div> </div>
<div class="block-content"> <div class="block-content">
<div [class]="containerClass" [ngStyle]="previewStyle" *ngIf="blockView == BlockView.PREVIEW"> <div [class]="containerClass" [ngStyle]="previewStyle" *ngIf="blockView === BlockView.PREVIEW">
<ng-content></ng-content> <ng-content></ng-content>
</div> </div>
<div *ngIf="blockView == BlockView.CODE"> <div *ngIf="blockView === BlockView.CODE">
<app-code lang="markup" ngPreserveWhitespaces>{{code}} <app-code lang="markup" ngPreserveWhitespaces>{{code}}
</app-code> </app-code>
</div> </div>
@ -37,7 +38,7 @@ enum BlockView {
`, `,
styleUrls: ['./blockviewer.component.scss'] styleUrls: ['./blockviewer.component.scss']
}) })
export class BlockViewer { export class BlockViewerComponent {
@Input() header!: string; @Input() header!: string;

View File

@ -2,7 +2,7 @@ import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common'; import { CommonModule } from '@angular/common';
import { BlocksComponent } from './blocks/blocks.component'; import { BlocksComponent } from './blocks/blocks.component';
import { PrimeBlocksRoutingModule } from './primeblocks-routing.module'; import { PrimeBlocksRoutingModule } from './primeblocks-routing.module';
import { BlockViewer } from './blockviewer/blockviewer.component' import { BlockViewerComponent } from './blockviewer/blockviewer.component'
import { AppCodeModule } from '../code/code.component'; import { AppCodeModule } from '../code/code.component';
import { ChipModule } from 'primeng/chip'; import { ChipModule } from 'primeng/chip';
import { CheckboxModule } from 'primeng/checkbox'; import { CheckboxModule } from 'primeng/checkbox';
@ -28,6 +28,6 @@ import { TooltipModule } from 'primeng/tooltip';
PrimeBlocksRoutingModule, PrimeBlocksRoutingModule,
AppCodeModule AppCodeModule
], ],
declarations: [BlocksComponent, BlockViewer] declarations: [BlocksComponent, BlockViewerComponent]
}) })
export class PrimeBlocksModule { } export class PrimeBlocksModule { }

View File

@ -1,11 +1,11 @@
import { Component, OnInit } from '@angular/core'; import { Component, OnDestroy, OnInit } from '@angular/core';
import { Subscription } from 'rxjs'; import { Subscription } from 'rxjs';
import { LayoutService } from 'src/app/layout/service/app.layout.service'; import { LayoutService } from 'src/app/layout/service/app.layout.service';
@Component({ @Component({
templateUrl: './chartsdemo.component.html' templateUrl: './chartsdemo.component.html'
}) })
export class ChartsDemoComponent implements OnInit { export class ChartsDemoComponent implements OnInit, OnDestroy {
lineData: any; lineData: any;

View File

@ -19,8 +19,8 @@
<ng-template pTemplate="body" let-rowNode let-rowData="rowData" let-columns="columns"> <ng-template pTemplate="body" let-rowNode let-rowData="rowData" let-columns="columns">
<tr> <tr>
<td *ngFor="let col of columns; let i = index"> <td *ngFor="let col of columns; let i = index">
<p-treeTableToggler [rowNode]="rowNode" *ngIf="i == 0"></p-treeTableToggler> <p-treeTableToggler [rowNode]="rowNode" *ngIf="i === 0"></p-treeTableToggler>
<p-treeTableCheckbox [value]="rowNode" *ngIf="i == 0"></p-treeTableCheckbox> <p-treeTableCheckbox [value]="rowNode" *ngIf="i === 0"></p-treeTableCheckbox>
{{rowData[col.field]}} {{rowData[col.field]}}
</td> </td>
</tr> </tr>

View File

@ -1,4 +1,4 @@
import { ChangeDetectorRef, Component, Input, OnDestroy, OnInit } from '@angular/core'; import { ChangeDetectorRef, Component, Host, HostBinding, Input, OnDestroy, OnInit } from '@angular/core';
import { NavigationEnd, Router } from '@angular/router'; import { NavigationEnd, Router } from '@angular/router';
import { animate, state, style, transition, trigger } from '@angular/animations'; import { animate, state, style, transition, trigger } from '@angular/animations';
import { Subscription } from 'rxjs'; import { Subscription } from 'rxjs';
@ -7,9 +7,8 @@ import { MenuService } from './app.menu.service';
import { LayoutService } from './service/app.layout.service'; import { LayoutService } from './service/app.layout.service';
@Component({ @Component({
/* tslint:disable:component-selector */ // eslint-disable-next-line @angular-eslint/component-selector
selector: '[app-menuitem]', selector: '[app-menuitem]',
/* tslint:enable:component-selector */
template: ` template: `
<ng-container> <ng-container>
<div *ngIf="root && item.visible !== false" class="layout-menuitem-root-text">{{item.label}}</div> <div *ngIf="root && item.visible !== false" class="layout-menuitem-root-text">{{item.label}}</div>
@ -36,10 +35,6 @@ import { LayoutService } from './service/app.layout.service';
</ul> </ul>
</ng-container> </ng-container>
`, `,
host: {
'[class.layout-root-menuitem]': 'root',
'[class.active-menuitem]': 'active'
},
animations: [ animations: [
trigger('children', [ trigger('children', [
state('collapsed', style({ state('collapsed', style({
@ -58,11 +53,11 @@ export class AppMenuitemComponent implements OnInit, OnDestroy {
@Input() index!: number; @Input() index!: number;
@Input() root!: boolean; @Input() @HostBinding('class.layout-root-menuitem') root!: boolean;
@Input() parentKey!: string; @Input() parentKey!: string;
active = false; @HostBinding('class.active-menuitem') active = false;
menuSourceSubscription: Subscription; menuSourceSubscription: Subscription;