Skip to content

Commit 1c55766

Browse files
chore: fix linting problems (#208)
1 parent ed7fe76 commit 1c55766

25 files changed

+53
-55
lines changed

.eslintrc.json

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@
4949
],
5050
"@typescript-eslint/no-unused-expressions": "error",
5151
"@typescript-eslint/prefer-function-type": "error",
52-
"@typescript-eslint/quotes": ["error", "single"],
52+
"@typescript-eslint/quotes": "off",
5353
"@typescript-eslint/type-annotation-spacing": "error",
5454
"@typescript-eslint/no-explicit-any": "off",
5555
"arrow-body-style": "error",
@@ -107,9 +107,10 @@
107107
},
108108
{
109109
"files": ["*.spec.ts"],
110-
"extends": ["plugin:testing-library/angular", "plugin:jest-dom/recommended"],
110+
"extends": ["plugin:jest/recommended"],
111111
"rules": {
112-
"testing-library/prefer-explicit-assert": "error"
112+
"jest/no-done-callback": "off",
113+
"jest/expect-expect": "off"
113114
}
114115
},
115116
{

angular.json

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@
7171
"lint": {
7272
"builder": "@nrwl/linter:eslint",
7373
"options": {
74-
"lintFilePatterns": ["apps/example-app/src/**/*.ts", "apps/example-app/src/**/*.html"]
74+
"lintFilePatterns": ["apps/example-app/**/*.ts", "apps/example-app/**/*.html"]
7575
}
7676
},
7777
"test": {
@@ -106,11 +106,7 @@
106106
"lint": {
107107
"builder": "@nrwl/linter:eslint",
108108
"options": {
109-
"lintFilePatterns": [
110-
"projects/testing-library/src/**/*.ts",
111-
"projects/testing-library/src/**/*.html",
112-
"projects/testing-library/src/**/*.html"
113-
]
109+
"lintFilePatterns": ["projects/testing-library/**/*.ts", "projects/testing-library/**/*.html"]
114110
}
115111
},
116112
"build": {
@@ -159,11 +155,7 @@
159155
"lint": {
160156
"builder": "@nrwl/linter:eslint",
161157
"options": {
162-
"lintFilePatterns": [
163-
"projects/jest-utils/src/**/*.ts",
164-
"projects/jest-utils/src/**/*.html",
165-
"projects/jest-utils/src/**/*.html"
166-
]
158+
"lintFilePatterns": ["projects/jest-utils/**/*.ts", "projects/jest-utils/**/*.html"]
167159
}
168160
},
169161
"build": {

apps/example-app/.eslintrc.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,10 @@
2828
},
2929
"plugins": ["@angular-eslint/eslint-plugin", "@typescript-eslint"]
3030
},
31+
{
32+
"files": ["*.spec.ts"],
33+
"extends": ["plugin:testing-library/angular", "plugin:jest-dom/recommended"]
34+
},
3135
{
3236
"files": ["*.html"],
3337
"extends": ["plugin:@nrwl/nx/angular-template"],

apps/example-app/src/app/issues/issue-106.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { render, screen, fireEvent, waitFor } from '@testing-library/angular';
66
template: `<button (click)="toggleShow()" data-testid="toggle">toggle</button>
77
<div *ngIf="show$ | async" data-testid="getme">Here I am</div>`,
88
})
9-
export class TestSelectComponent {
9+
class TestSelectComponent {
1010
showSubj = new BehaviorSubject(false);
1111
show$ = this.showSubj.asObservable();
1212

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,9 +66,10 @@
6666
"@typescript-eslint/eslint-plugin": "4.22.0",
6767
"@typescript-eslint/parser": "4.22.0",
6868
"cpy-cli": "^3.1.1",
69-
"eslint": "7.24.0",
69+
"eslint": "^7.25.0",
7070
"eslint-config-prettier": "8.2.0",
7171
"eslint-plugin-import": "latest",
72+
"eslint-plugin-jest": "^24.3.5",
7273
"eslint-plugin-jest-dom": "3.8.0",
7374
"eslint-plugin-testing-library": "^4.0.1",
7475
"husky": "^4.2.5",

projects/jest-utils/.eslintrc.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,15 @@
1313
"error",
1414
{
1515
"type": "attribute",
16-
"prefix": "lib",
16+
"prefix": "atl",
1717
"style": "camelCase"
1818
}
1919
],
2020
"@angular-eslint/component-selector": [
2121
"error",
2222
{
2323
"type": "element",
24-
"prefix": "lib",
24+
"prefix": "atl",
2525
"style": "kebab-case"
2626
}
2727
]

projects/jest-utils/tests/create-mock.spec.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import { Component } from '@angular/core';
22
import { TestBed } from '@angular/core/testing';
3+
import { fireEvent, render } from '@testing-library/angular';
34

45
import { createMock, provideMock, Mock } from '../src/public_api';
5-
import { render, fireEvent } from '../../testing-library/src/public_api';
66

77
class FixtureService {
88
constructor(private foo: string, public bar: string) {}
@@ -13,10 +13,10 @@ class FixtureService {
1313
}
1414

1515
@Component({
16-
selector: 'fixture',
16+
selector: 'atl-fixture',
1717
template: ` <button (click)="print()">Print</button> `,
1818
})
19-
export class FixtureComponent {
19+
class FixtureComponent {
2020
constructor(private service: FixtureService) {}
2121

2222
print() {
@@ -39,6 +39,7 @@ it('provides a mock service', async () => {
3939
expect(service.print).toHaveBeenCalledTimes(1);
4040
});
4141

42+
// eslint-disable-next-line jest/expect-expect
4243
it('is possible to write a mock implementation', async (done) => {
4344
const { getByText } = await render(FixtureComponent, {
4445
providers: [provideMock(FixtureService)],

projects/testing-library/.eslintrc.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,15 @@
1313
"error",
1414
{
1515
"type": "attribute",
16-
"prefix": "lib",
16+
"prefix": ["atl"],
1717
"style": "camelCase"
1818
}
1919
],
2020
"@angular-eslint/component-selector": [
2121
"error",
2222
{
2323
"type": "element",
24-
"prefix": "lib",
24+
"prefix": ["atl"],
2525
"style": "kebab-case"
2626
}
2727
]

projects/testing-library/src/lib/testing-library.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -358,6 +358,7 @@ if (typeof afterEach === 'function' && !process.env.ATL_SKIP_AUTO_CLEANUP) {
358358
});
359359
}
360360

361+
// TODO: rename to `atl-wrapper-component`
361362
// eslint-disable-next-line @angular-eslint/component-selector
362363
@Component({ selector: 'wrapper-component', template: '' })
363364
class WrapperComponent {}

projects/testing-library/tests/auto-cleanup.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ import { Component, Input } from '@angular/core';
22
import { render } from '../src/public_api';
33

44
@Component({
5-
selector: 'fixture',
6-
template: ` Hello {{ name }}! `,
5+
selector: 'atl-fixture',
6+
template: `Hello {{ name }}!`,
77
})
88
class FixtureComponent {
99
@Input() name: string;

projects/testing-library/tests/config.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { render, configure } from '../src/public_api';
44
import { ReactiveFormsModule, FormBuilder } from '@angular/forms';
55

66
@Component({
7-
selector: 'app-fixture',
7+
selector: 'atl-fixture',
88
template: `
99
<form [formGroup]="form" name="form">
1010
<div>

projects/testing-library/tests/debug.spec.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { Component } from '@angular/core';
22
import { render } from '../src/public_api';
33

44
@Component({
5-
selector: 'fixture',
5+
selector: 'atl-fixture',
66
template: `
77
<p>rawr</p>
88
<button data-testid="btn">I'm a button</button>
@@ -11,7 +11,7 @@ import { render } from '../src/public_api';
1111
class FixtureComponent {}
1212

1313
test('debug', async () => {
14-
jest.spyOn(console, 'log').mockImplementation(() => {});
14+
jest.spyOn(console, 'log').mockImplementation();
1515
const { debug } = await render(FixtureComponent);
1616

1717
debug();
@@ -21,7 +21,7 @@ test('debug', async () => {
2121
});
2222

2323
test('debug allows to be called with an element', async () => {
24-
jest.spyOn(console, 'log').mockImplementation(() => {});
24+
jest.spyOn(console, 'log').mockImplementation();
2525
const { debug, getByTestId } = await render(FixtureComponent);
2626
const btn = getByTestId('btn');
2727

projects/testing-library/tests/detect-changes.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { delay } from 'rxjs/operators';
55
import { render, fireEvent } from '../src/public_api';
66

77
@Component({
8-
selector: 'fixture',
8+
selector: 'atl-fixture',
99
template: `
1010
<input type="text" data-testid="input" [formControl]="inputControl" />
1111
<button data-testid="button">{{ caption }}</button>

projects/testing-library/tests/find-by.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { render, screen } from '../src/public_api';
44
import { mapTo } from 'rxjs/operators';
55

66
@Component({
7-
selector: 'fixture',
7+
selector: 'atl-fixture',
88
template: ` <div>{{ result | async }}</div> `,
99
})
1010
class FixtureComponent {

projects/testing-library/tests/fire-event.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { Component } from '@angular/core';
22
import { render, fireEvent } from '../src/public_api';
33

44
@Component({
5-
selector: 'fixture',
5+
selector: 'atl-fixture',
66
template: ` <input type="text" data-testid="input" /> `,
77
})
88
class FixtureComponent {}

projects/testing-library/tests/issues/188.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { render } from '../../src/public_api';
55
@Component({
66
template: `<h1>Hello {{ formattedName }}</h1>`,
77
})
8-
export class BugOnChangeComponent implements OnChanges {
8+
class BugOnChangeComponent implements OnChanges {
99
@Input() name: string;
1010

1111
formattedName: string;

projects/testing-library/tests/issues/67.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import { render } from '../../src/public_api';
1313
</div>
1414
`,
1515
})
16-
export class BugGetByLabelTextComponent {}
16+
class BugGetByLabelTextComponent {}
1717

1818
it('first step to reproduce the bug: skip this test to avoid the error or remove the for attribute of label', async () => {
1919
expect(await render(BugGetByLabelTextComponent)).toBeDefined();

projects/testing-library/tests/navigate.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { Router } from '@angular/router';
44
import { render } from '../src/public_api';
55

66
@Component({
7-
selector: 'fixture',
7+
selector: 'atl-fixture',
88
template: ``,
99
})
1010
class FixtureComponent {}

projects/testing-library/tests/providers/component-provider.spec.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,17 +43,17 @@ test('shows the provided service value with template syntax', async () => {
4343
});
4444

4545
@Injectable()
46-
export class Service {
46+
class Service {
4747
foo() {
4848
return 'foo';
4949
}
5050
}
5151

5252
@Component({
53-
selector: 'fixture-component',
53+
selector: 'atl-fixture',
5454
template: '{{service.foo()}}',
5555
providers: [Service],
5656
})
57-
export class FixtureComponent {
57+
class FixtureComponent {
5858
constructor(public service: Service) {}
5959
}

projects/testing-library/tests/providers/module-provider.spec.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,16 +53,16 @@ test('shows the provided service value with template syntax', async () => {
5353
});
5454

5555
@Injectable()
56-
export class Service {
56+
class Service {
5757
foo() {
5858
return 'foo';
5959
}
6060
}
6161

6262
@Component({
63-
selector: 'fixture-component',
63+
selector: 'atl-fixture',
6464
template: '{{service.foo()}}',
6565
})
66-
export class FixtureComponent {
66+
class FixtureComponent {
6767
constructor(public service: Service) {}
6868
}

projects/testing-library/tests/render-template.spec.ts

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
/* eslint-disable testing-library/no-container */
2-
/* eslint-disable testing-library/render-result-naming-convention */
31
import { Directive, HostListener, ElementRef, Input, Output, EventEmitter, Component } from '@angular/core';
42

53
import { render, fireEvent } from '../src/public_api';
@@ -8,7 +6,7 @@ import { render, fireEvent } from '../src/public_api';
86
// eslint-disable-next-line @angular-eslint/directive-selector
97
selector: '[onOff]',
108
})
11-
export class OnOffDirective {
9+
class OnOffDirective {
1210
@Input() on = 'on';
1311
@Input() off = 'off';
1412
@Output() clicked = new EventEmitter<string>();
@@ -27,7 +25,7 @@ export class OnOffDirective {
2725
// eslint-disable-next-line @angular-eslint/directive-selector
2826
selector: '[update]',
2927
})
30-
export class UpdateInputDirective {
28+
class UpdateInputDirective {
3129
@Input()
3230
set update(value: any) {
3331
this.el.nativeElement.textContent = value;
@@ -41,7 +39,7 @@ export class UpdateInputDirective {
4139
selector: 'greeting',
4240
template: 'Hello {{ name }}!',
4341
})
44-
export class GreetingComponent {
42+
class GreetingComponent {
4543
@Input() name = 'World';
4644
}
4745

@@ -59,7 +57,7 @@ test('the component renders', async () => {
5957
});
6058

6159
expect(component.container.querySelector('greeting')).toBeInTheDocument();
62-
expect(component.getByText('Hello Angular!'));
60+
expect(component.getByText('Hello Angular!')).toBeInTheDocument();
6361
});
6462

6563
test('the directive renders (compatibility with the deprecated signature)', async () => {
@@ -70,7 +68,7 @@ test('the directive renders (compatibility with the deprecated signature)', asyn
7068
expect(component.container.querySelector('[onoff]')).toBeInTheDocument();
7169
});
7270

73-
test.only('uses the default props', async () => {
71+
test('uses the default props', async () => {
7472
const component = await render('<div onOff></div>', {
7573
declarations: [OnOffDirective],
7674
});

projects/testing-library/tests/render.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import { TestBed } from '@angular/core/testing';
1313
import { render, fireEvent } from '../src/public_api';
1414

1515
@Component({
16-
selector: 'fixture',
16+
selector: 'atl-fixture',
1717
template: `
1818
<input type="text" data-testid="input" />
1919
<button>button</button>
@@ -83,7 +83,7 @@ describe('animationModule', () => {
8383

8484
describe('Angular component life-cycle hooks', () => {
8585
@Component({
86-
selector: 'fixture',
86+
selector: 'atl-fixture',
8787
template: ` {{ name }} `,
8888
})
8989
class FixtureWithNgOnChangesComponent implements OnInit, OnChanges {

0 commit comments

Comments
 (0)