Skip to content

Commit

Permalink
Merge pull request #2 from rajjaiswalsaumya/setup-angular-prettier
Browse files Browse the repository at this point in the history
Setup angular prettier
  • Loading branch information
rajjaiswalsaumya authored Nov 28, 2021
2 parents ae5994c + 815bb13 commit 61123f3
Show file tree
Hide file tree
Showing 10 changed files with 99 additions and 31 deletions.
6 changes: 4 additions & 2 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,12 @@
"plugin:@angular-eslint/recommended",
"plugin:@angular-eslint/template/process-inline-templates",
"airbnb-base",
"airbnb-typescript/base"
"airbnb-typescript/base",
"plugin:prettier/recommended"
],
"plugins": [
"@typescript-eslint"
"@typescript-eslint",
"prettier"
],
"rules": {
"@angular-eslint/directive-selector": [
Expand Down
1 change: 1 addition & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node_modules
9 changes: 9 additions & 0 deletions .prettierrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"arrowParens": "avoid",
"endOfLine": "auto",
"printWidth": 180,
"semi": true,
"singleQuote": true,
"tabWidth": 2,
"trailingComma": "all"
}
66 changes: 65 additions & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,17 @@
"eslint": "^7.32.0",
"eslint-config-airbnb-base": "^15.0.0",
"eslint-config-airbnb-typescript": "^16.0.0",
"eslint-config-prettier": "^8.3.0",
"eslint-plugin-import": "^2.25.3",
"eslint-plugin-jasmine": "^4.1.3",
"eslint-plugin-prettier": "^4.0.0",
"jasmine-core": "~3.8.0",
"karma": "~6.3.0",
"karma-chrome-launcher": "~3.1.0",
"karma-coverage": "~2.0.3",
"karma-jasmine": "~4.0.0",
"karma-jasmine-html-reporter": "~1.7.0",
"prettier": "^2.5.0",
"typescript": "~4.3.5"
}
}
2 changes: 1 addition & 1 deletion src/app/app-routing.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ const routes: Routes = [];
imports: [RouterModule.forRoot(routes)],
exports: [RouterModule],
})
export class AppRoutingModule { }
export class AppRoutingModule {}
10 changes: 3 additions & 7 deletions src/app/app.component.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,8 @@ import { AppComponent } from './app.component';
describe('AppComponent', () => {
beforeEach(async () => {
await TestBed.configureTestingModule({
imports: [
RouterTestingModule,
],
declarations: [
AppComponent,
],
imports: [RouterTestingModule],
declarations: [AppComponent],
}).compileComponents();
});

Expand All @@ -21,7 +17,7 @@ describe('AppComponent', () => {
expect(app).toBeTruthy();
});

it('should have as title \'eslint-prettier-husky-lintstaged\'', () => {
it("should have as title 'eslint-prettier-husky-lintstaged'", () => {
const fixture = TestBed.createComponent(AppComponent);
const app = fixture.componentInstance;

Expand Down
11 changes: 3 additions & 8 deletions src/app/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,9 @@ import { AppRoutingModule } from './app-routing.module';
import { AppComponent } from './app.component';

@NgModule({
declarations: [
AppComponent,
],
imports: [
BrowserModule,
AppRoutingModule,
],
declarations: [AppComponent],
imports: [BrowserModule, AppRoutingModule],
providers: [],
bootstrap: [AppComponent],
})
export class AppModule { }
export class AppModule {}
5 changes: 3 additions & 2 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,6 @@ if (environment.production) {
enableProdMode();
}

platformBrowserDynamic().bootstrapModule(AppModule)
.catch((err) => throwError(err));
platformBrowserDynamic()
.bootstrapModule(AppModule)
.catch(err => throwError(err));
17 changes: 7 additions & 10 deletions src/test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,23 @@

import 'zone.js/testing';
import { getTestBed } from '@angular/core/testing';
import {
BrowserDynamicTestingModule,
platformBrowserDynamicTesting,
} from '@angular/platform-browser-dynamic/testing';
import { BrowserDynamicTestingModule, platformBrowserDynamicTesting } from '@angular/platform-browser-dynamic/testing';

declare const require: {
/* eslint-disable no-unused-vars */
context(path: string, deep?: boolean, filter?: RegExp): {
context(
path: string,
deep?: boolean,
filter?: RegExp,
): {
keys(): string[];
<T>(id: string): T;
};
/* eslint-enable no-unused-vars */
};

// First, initialize the Angular testing environment.
getTestBed().initTestEnvironment(
BrowserDynamicTestingModule,
platformBrowserDynamicTesting(),
{ teardown: { destroyAfterEach: true } },
);
getTestBed().initTestEnvironment(BrowserDynamicTestingModule, platformBrowserDynamicTesting(), { teardown: { destroyAfterEach: true } });

// Then we find all the tests.
const context = require.context('./', true, /\.spec\.ts$/);
Expand Down

0 comments on commit 61123f3

Please sign in to comment.