Skip to content

Commit 7d531d1

Browse files
committed
ref/ set default angular eslint rules
1 parent 2b819d7 commit 7d531d1

15 files changed

+34
-36
lines changed

.eslintrc.json

+6-5
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
{
22
"root": true,
33
"ignorePatterns": [
4-
"projects/**/*"
4+
"app/**/*", // ignore nodeJs files
5+
"dist/**/*",
6+
"release/**/*"
57
],
68
"overrides": [
79
{
@@ -18,7 +20,8 @@
1820
"createDefaultProgram": true
1921
},
2022
"extends": [
21-
"plugin:@angular-eslint/recommended",
23+
"plugin:@angular-eslint/ng-cli-compat",
24+
"plugin:@angular-eslint/ng-cli-compat--formatting-add-on",
2225
"plugin:@angular-eslint/template/process-inline-templates"
2326
],
2427
"rules": {
@@ -35,14 +38,12 @@
3538
},
3639
{
3740
"files": [
38-
"*.component.html"
41+
"*.html"
3942
],
4043
"extends": [
4144
"plugin:@angular-eslint/template/recommended"
4245
],
4346
"rules": {
44-
"@angular-eslint/template/banana-in-box": "error",
45-
"@angular-eslint/template/no-negated-async": "error"
4647
}
4748
}
4849
]

angular.json

+1-3
Original file line numberDiff line numberDiff line change
@@ -132,10 +132,9 @@
132132
"lint": {
133133
"builder": "@angular-eslint/builder:lint",
134134
"options": {
135-
"eslintConfig": ".eslintrc.json",
136135
"lintFilePatterns": [
137136
"src/**/*.ts",
138-
"src/**/*.component.html"
137+
"src/**/*.html"
139138
]
140139
}
141140
}
@@ -148,7 +147,6 @@
148147
"lint": {
149148
"builder": "@angular-eslint/builder:lint",
150149
"options": {
151-
"eslintConfig": ".eslintrc.json",
152150
"lintFilePatterns": [
153151
"e2e/**/*.ts"
154152
]

e2e/common-setup.ts

+8-8
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
1-
const Application = require('spectron').Application;
2-
const electronPath = require('electron'); // Require Electron from the binaries included in node_modules.
3-
const path = require('path');
1+
const APPLICATION = require('spectron').Application;
2+
const ELECTRON_PATH = require('electron'); // Require Electron from the binaries included in node_modules.
3+
const PATH = require('path');
44

55
export default function setup(): void {
6-
beforeEach(async function () {
7-
this.app = new Application({
6+
beforeEach(async () => {
7+
this.app = new APPLICATION({
88
// Your electron path can be any binary
99
// i.e for OSX an example path could be '/Applications/MyApp.app/Contents/MacOS/MyApp'
1010
// But for the sake of the example we fetch it from our node_modules.
11-
path: electronPath,
11+
path: ELECTRON_PATH,
1212

1313
// Assuming you have the following directory structure
1414

@@ -23,14 +23,14 @@ export default function setup(): void {
2323

2424
// The following line tells spectron to look and use the main.js file
2525
// and the package.json located 1 level above.
26-
args: [path.join(__dirname, '..')],
26+
args: [PATH.join(__dirname, '..')],
2727
webdriverOptions: {}
2828
});
2929

3030
await this.app.start();
3131
});
3232

33-
afterEach(async function () {
33+
afterEach(async () => {
3434
if (this.app && this.app.isRunning()) {
3535
await this.app.stop();
3636
}

e2e/main.e2e.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { SpectronClient } from 'spectron';
33

44
import commonSetup from './common-setup';
55

6-
describe('angular-electron App', function () {
6+
describe('angular-electron App', () => {
77

88
commonSetup.apply(this);
99

@@ -13,12 +13,12 @@ describe('angular-electron App', function () {
1313
client = this.app.client;
1414
});
1515

16-
it('creates initial windows', async function () {
16+
it('creates initial windows', async () => {
1717
const count = await client.getWindowCount();
1818
expect(count).to.equal(1);
1919
});
2020

21-
it('should display message saying App works !', async function () {
21+
it('should display message saying App works !', async () => {
2222
const elem = await client.$('app-home h1');
2323
const text = await elem.getText();
2424
expect(text).to.equal('App works !');

src/app/app.component.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { Component } from '@angular/core';
22
import { ElectronService } from './core/services';
33
import { TranslateService } from '@ngx-translate/core';
4-
import { AppConfig } from '../environments/environment';
4+
import { APP_CONFIG } from '../environments/environment';
55

66
@Component({
77
selector: 'app-root',
@@ -14,7 +14,7 @@ export class AppComponent {
1414
private translate: TranslateService
1515
) {
1616
this.translate.setDefaultLang('en');
17-
console.log('AppConfig', AppConfig);
17+
console.log('APP_CONFIG', APP_CONFIG);
1818

1919
if (electronService.isElectron) {
2020
console.log(process.env);

src/app/app.module.ts

+2-4
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,7 @@ import { DetailModule } from './detail/detail.module';
1717
import { AppComponent } from './app.component';
1818

1919
// AoT requires an exported function for factories
20-
export function HttpLoaderFactory(http: HttpClient): TranslateHttpLoader {
21-
return new TranslateHttpLoader(http, './assets/i18n/', '.json');
22-
}
20+
const httpLoaderFactory = (http: HttpClient): TranslateHttpLoader => new TranslateHttpLoader(http, './assets/i18n/', '.json');
2321

2422
@NgModule({
2523
declarations: [AppComponent],
@@ -35,7 +33,7 @@ export function HttpLoaderFactory(http: HttpClient): TranslateHttpLoader {
3533
TranslateModule.forRoot({
3634
loader: {
3735
provide: TranslateLoader,
38-
useFactory: HttpLoaderFactory,
36+
useFactory: httpLoaderFactory,
3937
deps: [HttpClient]
4038
}
4139
})

src/app/core/services/electron/electron.service.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@ export class ElectronService {
3030
this.childProcess = window.require('child_process');
3131
this.fs = window.require('fs');
3232

33-
// If you want to use a NodeJS 3rd party deps in Renderer process (like @electron/remote), it must be declared in dependencies of both package.json (in root and app folders)
33+
// If you want to use a NodeJS 3rd party deps in Renderer process (like @electron/remote),
34+
// it must be declared in dependencies of both package.json (in root and app folders)
3435
// If you want to use remote object in renderer process, please set enableRemoteModule to true in main.ts
3536
this.remote = window.require('@electron/remote');
3637
console.log('remote - globalShortcut', this.remote.globalShortcut);

src/app/detail/detail.component.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ export class DetailComponent implements OnInit {
1010
constructor() { }
1111

1212
ngOnInit(): void {
13-
console.log("DetailComponent INIT");
13+
console.log('DetailComponent INIT');
1414
}
1515

1616
}

src/app/home/home.component.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ export class HomeComponent implements OnInit {
1010

1111
constructor(private router: Router) { }
1212

13-
ngOnInit(): void {
14-
console.log("HomeComponent INIT");
13+
ngOnInit(): void {
14+
console.log('HomeComponent INIT');
1515
}
1616

1717
}

src/app/shared/components/page-not-found/page-not-found.component.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,6 @@ export class PageNotFoundComponent implements OnInit {
99
constructor() {}
1010

1111
ngOnInit(): void {
12-
console.log("PageNotFoundComponent INIT");
12+
console.log('PageNotFoundComponent INIT');
1313
}
1414
}

src/environments/environment.dev.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
export const AppConfig = {
1+
export const APP_CONFIG = {
22
production: false,
33
environment: 'DEV'
44
};

src/environments/environment.prod.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
export const AppConfig = {
1+
export const APP_CONFIG = {
22
production: true,
33
environment: 'PROD'
44
};

src/environments/environment.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
export const AppConfig = {
1+
export const APP_CONFIG = {
22
production: false,
33
environment: 'LOCAL'
44
};

src/environments/environment.web.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
export const AppConfig = {
1+
export const APP_CONFIG = {
22
production: false,
33
environment: 'WEB'
44
};

src/main.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ import { enableProdMode } from '@angular/core';
22
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
33

44
import { AppModule } from './app/app.module';
5-
import { AppConfig } from './environments/environment';
5+
import { APP_CONFIG } from './environments/environment';
66

7-
if (AppConfig.production) {
7+
if (APP_CONFIG.production) {
88
enableProdMode();
99
}
1010

0 commit comments

Comments
 (0)