Skip to content

Commit

Permalink
Merge pull request #410 from cheplv/eslint-migration
Browse files Browse the repository at this point in the history
Eslint migration
  • Loading branch information
maximegris authored Nov 19, 2019
2 parents 9d94f9c + 2f64f37 commit c43bb6c
Show file tree
Hide file tree
Showing 16 changed files with 69 additions and 119 deletions.
12 changes: 7 additions & 5 deletions angular.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
}
]
},
"dev-web": {
"web": {
"optimization": false,
"outputHashing": "all",
"sourceMap": true,
Expand Down Expand Up @@ -95,8 +95,8 @@
"dev": {
"browserTarget": "angular-electron:build:dev"
},
"dev-web": {
"browserTarget": "angular-electron:build:dev-web"
"web": {
"browserTarget": "angular-electron:build:web"
},
"production": {
"browserTarget": "angular-electron:build:production"
Expand Down Expand Up @@ -135,8 +135,9 @@
}
},
"lint": {
"builder": "@angular-devkit/build-angular:tslint",
"builder": "@angular-eslint/builder:lint",
"options": {
"eslintConfig": "src/eslintrc.config.json",
"tsConfig": [
"src/tsconfig.app.json",
"src/tsconfig.spec.json"
Expand All @@ -153,8 +154,9 @@
"projectType": "application",
"architect": {
"lint": {
"builder": "@angular-devkit/build-angular:tslint",
"builder": "@angular-eslint/builder:lint",
"options": {
"eslintConfig": "e2e/eslintrc.e2e.json",
"tsConfig": [
"e2e/tsconfig.e2e.json"
],
Expand Down
5 changes: 4 additions & 1 deletion e2e/common-setup.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
/* eslint "@typescript-eslint/no-var-requires": 0 */
const Application = require('spectron').Application;
/* eslint "@typescript-eslint/no-var-requires": 0 */
const electronPath = require('electron'); // Require Electron from the binaries included in node_modules.
/* eslint "@typescript-eslint/no-var-requires": 0 */
const path = require('path');

export default function setup() {
export default function setup(): void {
beforeEach(async function () {
this.app = new Application({
// Your electron path can be any binary
Expand Down
6 changes: 6 additions & 0 deletions e2e/eslintrc.e2e.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"extends": "../eslintrc.json",
"parserOptions": {
"project": ["e2e/tsconfig.e2e.json"]
}
}
4 changes: 3 additions & 1 deletion e2e/main.spec.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
import {expect, assert} from 'chai';
import {expect} from 'chai';
import {SpectronClient} from 'spectron';

import commonSetup from './common-setup';

describe('angular-electron App', function () {
commonSetup.apply(this);

/* eslint "@typescript-eslint/no-explicit-any": 0 */
let browser: any;
let client: SpectronClient;

beforeEach(function () {
client = this.app.client;
/* eslint "@typescript-eslint/no-explicit-any": 0 */
browser = client as any;
});

Expand Down
19 changes: 19 additions & 0 deletions eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"env": {
"browser": true,
"node": true,
"es6": true,
"es2017": true
},
"extends": [
"eslint:recommended",
"plugin:@typescript-eslint/eslint-recommended",
"plugin:@typescript-eslint/recommended",
"plugin:@typescript-eslint/recommended-requiring-type-checking"
],
"parser": "@typescript-eslint/parser",
"parserOptions": {
"tsconfigRootDir": "."
},
"plugins": ["@typescript-eslint"]
}
11 changes: 7 additions & 4 deletions main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ import { app, BrowserWindow, screen } from 'electron';
import * as path from 'path';
import * as url from 'url';

let win, serve;
const args = process.argv.slice(1);
serve = args.some(val => val === '--serve');
let win: BrowserWindow = null;
const args = process.argv.slice(1),
serve = args.some(val => val === '--serve');

function createWindow() {
function createWindow(): BrowserWindow {

const electronScreen = screen;
const size = electronScreen.getPrimaryDisplay().workAreaSize;
Expand All @@ -19,10 +19,12 @@ function createWindow() {
height: size.height,
webPreferences: {
nodeIntegration: true,
allowRunningInsecureContent: (serve) ? true : false,
},
});

if (serve) {
/* eslint "@typescript-eslint/no-var-requires": 0 */
require('electron-reload')(__dirname, {
electron: require(`${__dirname}/node_modules/electron`)
});
Expand All @@ -47,6 +49,7 @@ function createWindow() {
win = null;
});

return win;
}

try {
Expand Down
10 changes: 7 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"build:dev": "npm run build -- -c dev",
"build:prod": "npm run build -- -c production",
"ng:serve": "ng serve",
"ng:serve:web": "ng serve -c dev-web -o",
"ng:serve:web": "ng serve -c web -o",
"electron:serve-tsc": "tsc -p tsconfig-serve.json",
"electron:serve": "wait-on http-get://localhost:4200/ && npm run electron:serve-tsc && electron . --serve",
"electron:local": "npm run build:prod && electron .",
Expand All @@ -39,6 +39,7 @@
"devDependencies": {
"@angular-builders/custom-webpack": "8.2.0",
"@angular-devkit/build-angular": "0.803.6",
"@angular-eslint/builder": "0.0.1-alpha.17",
"@angular/cli": "8.3.6",
"@angular/common": "8.2.12",
"@angular/compiler": "8.2.12",
Expand All @@ -55,13 +56,17 @@
"@types/jasminewd2": "2.0.6",
"@types/mocha": "5.2.7",
"@types/node": "12.6.8",
"@typescript-eslint/eslint-plugin": "^2.7.0",
"@typescript-eslint/parser": "^2.7.0",
"chai": "4.2.0",
"codelyzer": "5.1.0",
"conventional-changelog-cli": "2.0.25",
"core-js": "3.1.4",
"electron": "7.0.0",
"electron": "7.1.1",
"electron-builder": "21.2.0",
"electron-reload": "1.5.0",
"eslint": "^6.6.0",
"eslint-plugin-import": "^2.18.2",
"jasmine-core": "3.4.0",
"jasmine-spec-reporter": "4.2.1",
"karma": "4.2.0",
Expand All @@ -74,7 +79,6 @@
"rxjs": "6.5.3",
"spectron": "9.0.0",
"ts-node": "8.3.0",
"tslint": "5.20.0",
"typescript": "3.5.3",
"wait-on": "3.3.0",
"webdriver-manager": "12.1.5",
Expand Down
4 changes: 0 additions & 4 deletions src/app/app.component.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,3 @@ describe('AppComponent', () => {
expect(app).toBeTruthy();
}));
});

class TranslateServiceStub {
setDefaultLang(lang: string): void {}
}
2 changes: 1 addition & 1 deletion src/app/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import { HomeModule } from './home/home.module';
import { AppComponent } from './app.component';

// AoT requires an exported function for factories
export function HttpLoaderFactory(http: HttpClient) {
export function HttpLoaderFactory(http: HttpClient): TranslateHttpLoader {
return new TranslateHttpLoader(http, './assets/i18n/', '.json');
}

Expand Down
2 changes: 1 addition & 1 deletion src/app/core/services/electron/electron.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export class ElectronService {
childProcess: typeof childProcess;
fs: typeof fs;

get isElectron() {
get isElectron(): boolean {
return window && window.process && window.process.type;
}

Expand Down
5 changes: 3 additions & 2 deletions src/app/home/home.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,10 @@ import { Component, OnInit } from '@angular/core';
})
export class HomeComponent implements OnInit {

/* eslint "no-empty-function":0, "@typescript-eslint/no-empty-function": 0 */
constructor() { }

ngOnInit() {
}
/* eslint "no-empty-function":0, "@typescript-eslint/no-empty-function": 0 */
ngOnInit(): void { }

}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ import { Component, OnInit } from '@angular/core';
styleUrls: ['./page-not-found.component.scss']
})
export class PageNotFoundComponent implements OnInit {
/* eslint "no-empty-function":0, "@typescript-eslint/no-empty-function": 0 */
constructor() {}

ngOnInit() {}
/* eslint "no-empty-function":0, "@typescript-eslint/no-empty-function": 0 */
ngOnInit(): void {}
}
1 change: 1 addition & 0 deletions src/app/shared/directives/webview/webview.directive.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@ import { Directive } from '@angular/core';
selector: '[webview]'
})
export class WebviewDirective {
/* eslint "no-empty-function":0, "@typescript-eslint/no-empty-function": 0 */
constructor() {}
}
6 changes: 6 additions & 0 deletions src/eslintrc.config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"extends": "../eslintrc.json",
"parserOptions": {
"project": ["src/tsconfig.app.json", "src/tsconfig.spec.json"]
}
}
1 change: 1 addition & 0 deletions src/test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {
platformBrowserDynamicTesting
} from '@angular/platform-browser-dynamic/testing';

/* eslint "@typescript-eslint/no-explicit-any":0 */
declare const require: any;

// First, initialize the Angular testing environment.
Expand Down
96 changes: 0 additions & 96 deletions tslint.json

This file was deleted.

0 comments on commit c43bb6c

Please sign in to comment.