Skip to content

Commit

Permalink
ci: restrict console.log/debug in production code
Browse files Browse the repository at this point in the history
  • Loading branch information
splincode committed Dec 27, 2021
2 parents 140391b + 3e54708 commit 980a42c
Show file tree
Hide file tree
Showing 17 changed files with 20 additions and 20 deletions.
2 changes: 2 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,13 @@ module.exports = {
sourceType: 'module',
},
rules: {
// TODO: move rules to @tinkoff/eslint-config-angular
'@typescript-eslint/no-useless-constructor': 'off',
'@typescript-eslint/explicit-member-accessibility': [
'error',
{accessibility: 'no-public'},
],
'@typescript-eslint/prefer-readonly': ['error'],
'no-console': ['error', {allow: ['info', 'assert', 'warn', 'error']}],
},
};
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ export class TuiDocDocumentationPropertyConnectorDirective<T>

emitEvent(event: unknown): void {
// For more convenient debugging
console.log(this.attrName, event);
console.info(this.attrName, event);

this.emits$.next(this.emits$.value + 1);
}
Expand Down
2 changes: 1 addition & 1 deletion projects/demo/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ function run() {
const server = app();

server.listen(port, () => {
console.log(`Node Express server listening on http://localhost:${port}`);
console.info(`Node Express server listening on http://localhost:${port}`);
});
}

Expand Down
4 changes: 2 additions & 2 deletions projects/demo/src/main.browser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@ if (environment.hmr) {
hmrBootstrap(module, bootstrap);
} else {
console.error('HMR is not enabled for webpack-dev-server!');
console.log('Are you using the --hmr flag for ng serve?');
console.info('Are you using the --hmr flag for ng serve?');
}
} else {
document.addEventListener('DOMContentLoaded', () => {
setTimeout(() => {
bootstrap().catch(err => console.log(err));
bootstrap().catch(err => console.error(err));
});
});
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@ export class TuiButtonExample1 {
readonly avatarUrl = avatar;

onClick(event: MouseEvent) {
console.log('click', event);
console.info('click', event);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@ export class TuiDialogExampleComponent2 {
showDialog() {
this.dialog.subscribe({
next: data => {
console.log('Dialog emitted data = ' + data);
console.info('Dialog emitted data = ' + data);
},
complete: () => {
console.log('Dialog closed');
console.info('Dialog closed');
},
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@ import {encapsulation} from '@demo/emulate/encapsulation';
})
export class TuiLinkExample3 {
onClick(event: MouseEvent) {
console.log('click', event);
console.info('click', event);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,6 @@ export class TuiPaginationExample1 {

goToPage(index: number) {
this.index = index;
console.log('New page:', index);
console.info('New page:', index);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ export class TuiPreviewExample1 {

show() {
this.previewService.open(this.preview || '').subscribe({
complete: () => console.log('complete'),
complete: () => console.info('complete'),
});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ export class TuiPreviewExample3 {
}

download() {
console.log('downloading...');
console.info('downloading...');
}

emulateBackendRequest(): Observable<string> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,6 @@ export class ExampleTuiPrimitiveTextfieldComponent extends AbstractExampleTuiInt
}

onClick() {
console.log('Interactive icon clicked');
console.info('Interactive icon clicked');
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,6 @@ export class TuiDropdownContextExample3 {
});

report() {
console.log(this.testForm.value);
console.info(this.testForm.value);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,6 @@ export class ExampleTuiManualHintComponent extends AbstractExampleTuiHint {
show = false;

sayHi() {
console.log('Hi all!');
console.info('Hi all!');
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export class TuiSwipeExample2 {
}

onSwipe(swipe: TuiSwipe) {
console.log(swipe.direction);
console.info(swipe.direction);

if (swipe.direction === 'left') {
this.toggle(true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@ export class TuiDestroyExample {
constructor(destroy$: TuiDestroyService, {nativeElement}: ElementRef<HTMLElement>) {
fromEvent(nativeElement, 'click')
.pipe(takeUntil(destroy$))
.subscribe(() => {
console.log('click');
});
.subscribe(() => console.info('click'));
}
}
2 changes: 1 addition & 1 deletion projects/demo/src/modules/tables/table/examples/4/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ export class TuiTableExample4 {
size: number,
minAge: number,
): Observable<ReadonlyArray<User | null>> {
console.log('Making a request');
console.info('Making a request');

const start = page * size;
const end = start + size;
Expand Down
2 changes: 1 addition & 1 deletion scripts/release.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ function checkChangelog() {

readline.setPrompt(`Check\n./CHANGELOG.md\nand save all fixes. Then press enter`);
readline.prompt();
console.log('\n');
console.info('\n');

return new Promise(resolve => {
readline.on('line', userInput => {
Expand Down

0 comments on commit 980a42c

Please sign in to comment.