Skip to content

Commit

Permalink
Update Prettier configuration and fix trailing commas for improved co…
Browse files Browse the repository at this point in the history
…de consistency
  • Loading branch information
robsonalvesdev committed Dec 13, 2024
1 parent 1900de3 commit 9f7f1e2
Show file tree
Hide file tree
Showing 17 changed files with 94 additions and 82 deletions.
103 changes: 57 additions & 46 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,7 @@ module.exports = {
},
{
files: ['src/**/*.html'],
extends: [
'plugin:@angular-eslint/template/recommended',
'plugin:prettier/recommended',
],
extends: ['plugin:@angular-eslint/template/recommended', 'plugin:prettier/recommended'],
rules: {
'prettier/prettier': [
'error',
Expand All @@ -52,48 +49,62 @@ module.exports = {
],
};

// // @ts-check
// const eslint = require("@eslint/js");
// const tseslint = require("typescript-eslint");
// const angular = require("angular-eslint");

// module.exports = tseslint.config(
// {
// files: ["**/*.ts"],
// extends: [
// eslint.configs.recommended,
// ...tseslint.configs.recommended,
// ...tseslint.configs.stylistic,
// ...angular.configs.tsRecommended,
// ],
// processor: angular.processInlineTemplates,
// rules: {
// "@angular-eslint/directive-selector": [
// "error",
// {
// type: "attribute",
// prefix: "app",
// style: "camelCase",
// },
// ],
// "@angular-eslint/component-selector": [
// "error",
// {
// type: "element",
// prefix: "app",
// style: "kebab-case",
// },
// module.exports = {
// root: true,
// ignorePatterns: ['node_modules/*', 'dist/*'],
// overrides: [
// {
// files: ['src/**/*.ts'],
// extends: [
// 'eslint:recommended',
// 'plugin:@typescript-eslint/recommended',
// 'plugin:@angular-eslint/recommended',
// 'plugin:prettier/recommended',
// ],
// parserOptions: {
// project: ['tsconfig.json'],
// createDefaultProgram: true,
// },
// rules: {
// '@angular-eslint/directive-selector': [
// 'error',
// {
// type: 'attribute',
// prefix: 'app',
// style: 'camelCase',
// },
// ],
// '@angular-eslint/component-selector': [
// 'error',
// {
// type: 'element',
// prefix: 'app',
// style: 'kebab-case',
// },
// ],
// 'prettier/prettier': ['error', { endOfLine: 'auto' }],
// 'max-len': [
// 'error',
// {
// code: 120, // Define o comprimento máximo de uma linha
// ignoreStrings: true, // Ignora strings longas
// ignoreTemplateLiterals: true, // Ignora strings de template
// ignoreComments: true, // Ignora comentários
// },
// ],
// },
// },
// },
// {
// files: ["**/*.html"],
// extends: [
// ...angular.configs.templateRecommended,
// ...angular.configs.templateAccessibility,
// ],
// rules: {
// 'prettier/prettier': ['error', { endOfLine: 'auto' }],
// {
// files: ['src/**/*.html'],
// extends: ['plugin:@angular-eslint/template/recommended', 'plugin:prettier/recommended'],
// rules: {
// 'prettier/prettier': [
// 'error',
// {
// parser: 'angular',
// },
// ],
// },
// },
// }
// );
// ],
// };
5 changes: 3 additions & 2 deletions .prettierrc
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@
"printWidth": 80,
"tabWidth": 2,
"semi": true,
"endOfLine": "auto"
}
"endOfLine": "auto",
"trailingComma": "es5"
}
4 changes: 2 additions & 2 deletions src/app/components/pages/about/abount.component.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ describe('AbountComponent', () => {
const compiled = fixture.nativeElement as HTMLElement;
expect(
compiled.querySelector(
'div.container div.text-center h3.section-subheading.text-muted',
)?.textContent,
'div.container div.text-center h3.section-subheading.text-muted'
)?.textContent
).toBe(' Saiba mais sobre minha carreira. ');
});
});
8 changes: 4 additions & 4 deletions src/app/components/pages/book/book.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,12 @@ export class BookComponent extends BasePageComponent implements OnInit {
tags: WritableSignal<Set<string>> = signal<Set<string>>(new Set<string>());

publishNameFilter: WritableSignal<Set<string>> = signal<Set<string>>(
new Set<string>(),
new Set<string>()
);
selectInstitutionsFilter: WritableSignal<string> = signal<string>('');

tagsFilter: WritableSignal<Set<string>> = signal<Set<string>>(
new Set<string>(),
new Set<string>()
);
selectTagFilter: WritableSignal<string> = signal<string>('');

Expand All @@ -62,7 +62,7 @@ export class BookComponent extends BasePageComponent implements OnInit {
ngOnInit(): void {
//this.books.forEach((book) => this.publishNameList().add(book.publishName.trim()))
this.books.forEach((book) =>
book.tags.forEach((tag) => this.tags().add(tag.trim())),
book.tags.forEach((tag) => this.tags().add(tag.trim()))
);
}

Expand Down Expand Up @@ -107,7 +107,7 @@ export class BookComponent extends BasePageComponent implements OnInit {
this.publishNameFilter().add(id);
}
this.selectInstitutionsFilter.set(
Array.from(this.publishNameFilter().values()).join(','),
Array.from(this.publishNameFilter().values()).join(',')
);

this.config().currentPage = 1;
Expand Down
8 changes: 4 additions & 4 deletions src/app/components/pages/course/course.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,11 @@ export class CourseComponent extends BasePageComponent implements OnInit {
Set<InstitutionEnum>
>(new Set<InstitutionEnum>());
selectInstitutionsFilter: WritableSignal<string> = signal<string>(
InstitutionEnum.All,
InstitutionEnum.All
);

tagsFilter: WritableSignal<Set<string>> = signal<Set<string>>(
new Set<string>(),
new Set<string>()
);
selectTagFilter: WritableSignal<string> = signal<string>('');

Expand All @@ -65,7 +65,7 @@ export class CourseComponent extends BasePageComponent implements OnInit {

ngOnInit(): void {
this.courses.forEach((course) =>
course.tags.forEach((tag) => this.tags().add(tag.trim())),
course.tags.forEach((tag) => this.tags().add(tag.trim()))
);
}

Expand Down Expand Up @@ -105,7 +105,7 @@ export class CourseComponent extends BasePageComponent implements OnInit {
this.coursesFilter().add(institution);
}
this.selectInstitutionsFilter.set(
Array.from(this.coursesFilter().values()).join(','),
Array.from(this.coursesFilter().values()).join(',')
);

this.config().currentPage = 1;
Expand Down
2 changes: 1 addition & 1 deletion src/app/components/pages/footer/footer.component.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ describe('FooterComponent', () => {
//fixture.detectChanges()
const compiled = fixture.nativeElement as HTMLElement;
expect(compiled.querySelector('div.container')?.textContent).toContain(
'Terms of Use',
'Terms of Use'
);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ describe('GraduationComponent', () => {
const compiled = fixture.nativeElement as HTMLElement;
expect(
compiled.querySelector(
'div.container div.text-center h2.section-heading.text-uppercase',
)?.textContent,
'div.container div.text-center h2.section-heading.text-uppercase'
)?.textContent
).toBe('(Pós)Graduação');
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ describe('MasterheadComponent', () => {
const compiled = fixture.nativeElement as HTMLElement;
expect(
compiled.querySelector('div.container div.masthead-subheading')
?.textContent,
?.textContent
).toBe('Bem vindo ao meu Website');
});
});
12 changes: 6 additions & 6 deletions src/app/components/pages/navigation/navigation.component.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,22 +19,22 @@ describe('NavigationComponent', () => {
//fixture.detectChanges()
const compiled = fixture.nativeElement as HTMLElement;
expect(compiled.querySelector('#navbarResponsive')?.textContent).toContain(
'Sobre',
'Sobre'
);
expect(compiled.querySelector('#navbarResponsive')?.textContent).toContain(
'(Pós)Graduação',
'(Pós)Graduação'
);
expect(compiled.querySelector('#navbarResponsive')?.textContent).toContain(
'Cursos',
'Cursos'
);
expect(compiled.querySelector('#navbarResponsive')?.textContent).toContain(
'Formação',
'Formação'
);
expect(compiled.querySelector('#navbarResponsive')?.textContent).toContain(
'Leituras',
'Leituras'
);
expect(compiled.querySelector('#navbarResponsive')?.textContent).toContain(
'Contato',
'Contato'
);
});
});
4 changes: 2 additions & 2 deletions src/app/directives/google-analytics.directive.sec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ describe('GoogleAnalyticsDirective', () => {
expect(gaService.logEvent).toHaveBeenCalledWith(
'click_event',
'button',
'test_button',
'test_button'
);
});

Expand All @@ -72,7 +72,7 @@ describe('GoogleAnalyticsDirective', () => {
'robsonalves',
'azure',
'black_friday_promotion',
'button+test_button',
'button+test_button'
);
});

Expand Down
2 changes: 1 addition & 1 deletion src/app/directives/google-analytics.directive.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export class GoogleAnalyticsDirective {
'robsonalves',
'azure',
'black_friday_promotion',
campaignData,
campaignData
);
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/app/pipes/filter.pipe.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ describe('FilterPipe', () => {
data,
'string',
'category',
'fiction,adventure',
'fiction,adventure'
);
expect(result.length).toBe(2);
expect(result).toEqual([
Expand Down
4 changes: 2 additions & 2 deletions src/app/pipes/filter.pipe.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export class FilterPipe implements PipeTransform {
data: any[],
typeField: 'string' | 'array',
filterProperty: any,
filter: string,
filter: string
): any[] {
const filterLowerCase = filter.toLowerCase().split(',');

Expand All @@ -18,7 +18,7 @@ export class FilterPipe implements PipeTransform {
return filterLowerCase.includes(field.toLowerCase());
} else {
return (field as string[]).some((f) =>
filterLowerCase.includes(f.toLowerCase()),
filterLowerCase.includes(f.toLowerCase())
);
}
};
Expand Down
2 changes: 1 addition & 1 deletion src/app/pipes/message-date-conclusion.pipe.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ describe('MessageDateConclusionPipe', () => {

it('should return "Estado desconhecido" when conclusionStatus is not "completed", "locked" or "inprogress"', () => {
expect(pipe.transform('unknown' as 'completed')).toBe(
'Estado desconhecido',
'Estado desconhecido'
);
});
});
6 changes: 3 additions & 3 deletions src/app/pipes/sortby.pipe.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export class SortbyPipe implements PipeTransform {
transform<T>(
array: T[],
field?: keyof T,
order: 'asc' | 'desc' = 'asc',
order: 'asc' | 'desc' = 'asc'
): T[] {
if (!Array.isArray(array)) {
return array;
Expand All @@ -23,7 +23,7 @@ export class SortbyPipe implements PipeTransform {

private getSortFn<T>(
field?: keyof T,
order: 'asc' | 'desc' = 'asc',
order: 'asc' | 'desc' = 'asc'
): (a: T, b: T) => number {
return (a: T, b: T): number => {
const comparison = this.compareValues(a, b, field);
Expand Down Expand Up @@ -54,7 +54,7 @@ export class SortbyPipe implements PipeTransform {
// Dica: use o método sort do array
sortString(array: string[], order: 'asc' | 'desc'): string[] {
return array.sort((a, b) =>
order === 'asc' ? a.localeCompare(b) : b.localeCompare(a),
order === 'asc' ? a.localeCompare(b) : b.localeCompare(a)
);
}
}
6 changes: 3 additions & 3 deletions src/app/services/google-analytics.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ export class GoogleAnalyticsService {
.pipe(
filter(
(event: Event): event is NavigationEnd =>
event instanceof NavigationEnd,
),
event instanceof NavigationEnd
)
)
.subscribe(() => {
this._sendPageView();
Expand Down Expand Up @@ -83,7 +83,7 @@ export class GoogleAnalyticsService {
id: string,
source: string,
name: string,
term: string,
term: string
): void {
gtag('set', campaign, {
id: id,
Expand Down
2 changes: 1 addition & 1 deletion src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ import { appConfig } from './app/app.config';
import { AppComponent } from './app/app.component';

bootstrapApplication(AppComponent, appConfig).catch((err) =>
console.error(err),
console.error(err)
);

0 comments on commit 9f7f1e2

Please sign in to comment.