Skip to content

Commit 221bf42

Browse files
authored
chore(lint): re-enable eslint plugin angular (#237)
1 parent 0cbd0fb commit 221bf42

30 files changed

+224
-157
lines changed

.eslintrc.json

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"root": true,
33
"ignorePatterns": ["**/*"],
4-
"plugins": ["@nrwl/nx"],
4+
"plugins": ["@nrwl/nx", "testing-library"],
55
"overrides": [
66
{
77
"files": ["*.ts", "*.tsx", "*.js", "*.jsx"],
@@ -102,20 +102,20 @@
102102
]
103103
}
104104
},
105-
{
106-
"files": ["*.spec.ts"],
107-
"extends": ["plugin:jest/recommended"],
108-
"rules": {
109-
"jest/expect-expect": "off"
110-
}
111-
},
112105
{
113106
"files": ["*.html"],
114107
"rules": {}
115108
},
116109
{
117110
"files": ["*.ts", "*.js"],
118111
"extends": ["prettier"]
112+
},
113+
{
114+
"files": ["*.spec.ts"],
115+
"extends": ["plugin:testing-library/angular"],
116+
"rules": {
117+
"testing-library/prefer-explicit-assert": "error"
118+
}
119119
}
120120
]
121121
}

apps/example-app-karma/.eslintrc.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,14 @@
2727
]
2828
}
2929
},
30+
{
31+
"files": ["*.spec.ts"],
32+
"env": {
33+
"jasmine": true
34+
},
35+
"plugins": ["jasmine"],
36+
"extends": ["plugin:jasmine/recommended"]
37+
},
3038
{
3139
"files": ["*.html"],
3240
"extends": ["plugin:@nrwl/nx/angular-template"],

apps/example-app-karma/src/app/issues/issue-222.spec.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@ it('https://github.com/testing-library/angular-testing-library/issues/222', asyn
77
},
88
});
99

10-
screen.getByText('Hello Sarah');
10+
expect(screen.getByText('Hello Sarah')).toBeTruthy();
1111
rerender({ name: 'Mark' });
12-
screen.getByText('Hello Mark');
12+
13+
expect(screen.getByText('Hello Mark')).toBeTruthy();
1314
});
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"extends": "./tsconfig.json",
3+
"include": ["**/*.ts"],
4+
"compilerOptions": {
5+
"types": ["jasmine", "node", "@testing-library/jasmine-dom"]
6+
}
7+
}

apps/example-app-karma/tsconfig.spec.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
"extends": "./tsconfig.json",
33
"compilerOptions": {
44
"outDir": "./out-tsc/spec",
5-
"types": ["jasmine", "node"]
5+
"types": ["jasmine", "node", "@testing-library/jasmine-dom"]
66
},
77
"files": ["src/test.ts", "src/polyfills.ts"],
8-
"include": ["src/**/*.spec.ts", "src/**/*.d.ts"]
8+
"include": ["**/*.spec.ts", "**/*.d.ts"]
99
}

apps/example-app/.eslintrc.json

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,17 @@
2727
]
2828
}
2929
},
30+
{
31+
"files": ["*.spec.ts"],
32+
"env": {
33+
"jest": true
34+
},
35+
"extends": ["plugin:jest/recommended", "plugin:jest/style", "plugin:jest-dom/recommended"],
36+
"rules": {
37+
"jest/consistent-test-it": ["error"],
38+
"jest/expect-expect": "off"
39+
}
40+
},
3041
{
3142
"files": ["*.html"],
3243
"extends": ["plugin:@nrwl/nx/angular-template"],

apps/example-app/src/app/app.module.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import { ComponentWithProviderComponent } from './examples/05-component-provider
2121
import { WithNgRxStoreComponent, reducer } from './examples/06-with-ngrx-store';
2222
import { WithNgRxMockStoreComponent } from './examples/07-with-ngrx-mock-store';
2323
import { MasterComponent, DetailComponent, HiddenDetailComponent } from './examples/09-router';
24+
import { ScrollingModule } from '@angular/cdk/scrolling';
2425

2526
function reducerItems() {
2627
return ['One', 'Two', 'Three'];
@@ -53,6 +54,7 @@ function reducerItems() {
5354
MatSidenavModule,
5455
MatToolbarModule,
5556
AppRoutingModule,
57+
ScrollingModule,
5658
StoreModule.forRoot({
5759
value: reducer,
5860
items: reducerItems,

apps/example-app/src/app/examples/07-with-ngrx-mock-store.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,5 +23,5 @@ test('works with provideMockStore', async () => {
2323

2424
fireEvent.click(screen.getByText(/seven/i));
2525

26-
expect(store.dispatch).toBeCalledWith({ type: '[Item List] send', item: 'Seven' });
26+
expect(store.dispatch).toHaveBeenCalledWith({ type: '[Item List] send', item: 'Seven' });
2727
});

apps/example-app/src/app/examples/12-service-component.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ test('renders the provided customers with manual mock', async () => {
2929
});
3030

3131
const listItems = screen.getAllByRole('listitem');
32-
expect(listItems.length).toBe(customers.length);
32+
expect(listItems).toHaveLength(customers.length);
3333

3434
customers.forEach((customer) => screen.getByText(new RegExp(customer.name, 'i')));
3535
});
@@ -59,7 +59,7 @@ test('renders the provided customers with createMock', async () => {
5959
});
6060

6161
const listItems = screen.getAllByRole('listitem');
62-
expect(listItems.length).toBe(customers.length);
62+
expect(listItems).toHaveLength(customers.length);
6363

6464
customers.forEach((customer) => screen.getByText(new RegExp(customer.name, 'i')));
6565
});

apps/example-app/src/app/examples/15-dialog.component.spec.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ test('closes the dialog via the backdrop', async () => {
3737

3838
// using fireEvent because of:
3939
// unable to click element as it has or inherits pointer-events set to "none"
40+
// eslint-disable-next-line testing-library/no-node-access
4041
fireEvent.click(document.querySelector('.cdk-overlay-backdrop'));
4142

4243
await waitForElementToBeRemoved(() => screen.getByRole('dialog'));

0 commit comments

Comments
 (0)