Skip to content

chore: fix linting problems #208

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Apr 25, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
],
"@typescript-eslint/no-unused-expressions": "error",
"@typescript-eslint/prefer-function-type": "error",
"@typescript-eslint/quotes": ["error", "single"],
"@typescript-eslint/quotes": "off",
"@typescript-eslint/type-annotation-spacing": "error",
"@typescript-eslint/no-explicit-any": "off",
"arrow-body-style": "error",
Expand Down Expand Up @@ -107,9 +107,10 @@
},
{
"files": ["*.spec.ts"],
"extends": ["plugin:testing-library/angular", "plugin:jest-dom/recommended"],
"extends": ["plugin:jest/recommended"],
"rules": {
"testing-library/prefer-explicit-assert": "error"
"jest/no-done-callback": "off",
"jest/expect-expect": "off"
}
},
{
Expand Down
14 changes: 3 additions & 11 deletions angular.json
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@
"lint": {
"builder": "@nrwl/linter:eslint",
"options": {
"lintFilePatterns": ["apps/example-app/src/**/*.ts", "apps/example-app/src/**/*.html"]
"lintFilePatterns": ["apps/example-app/**/*.ts", "apps/example-app/**/*.html"]
}
},
"test": {
Expand Down Expand Up @@ -106,11 +106,7 @@
"lint": {
"builder": "@nrwl/linter:eslint",
"options": {
"lintFilePatterns": [
"projects/testing-library/src/**/*.ts",
"projects/testing-library/src/**/*.html",
"projects/testing-library/src/**/*.html"
]
"lintFilePatterns": ["projects/testing-library/**/*.ts", "projects/testing-library/**/*.html"]
}
},
"build": {
Expand Down Expand Up @@ -159,11 +155,7 @@
"lint": {
"builder": "@nrwl/linter:eslint",
"options": {
"lintFilePatterns": [
"projects/jest-utils/src/**/*.ts",
"projects/jest-utils/src/**/*.html",
"projects/jest-utils/src/**/*.html"
]
"lintFilePatterns": ["projects/jest-utils/**/*.ts", "projects/jest-utils/**/*.html"]
}
},
"build": {
Expand Down
4 changes: 4 additions & 0 deletions apps/example-app/.eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@
},
"plugins": ["@angular-eslint/eslint-plugin", "@typescript-eslint"]
},
{
"files": ["*.spec.ts"],
"extends": ["plugin:testing-library/angular", "plugin:jest-dom/recommended"]
},
{
"files": ["*.html"],
"extends": ["plugin:@nrwl/nx/angular-template"],
Expand Down
2 changes: 1 addition & 1 deletion apps/example-app/src/app/issues/issue-106.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { render, screen, fireEvent, waitFor } from '@testing-library/angular';
template: `<button (click)="toggleShow()" data-testid="toggle">toggle</button>
<div *ngIf="show$ | async" data-testid="getme">Here I am</div>`,
})
export class TestSelectComponent {
class TestSelectComponent {
showSubj = new BehaviorSubject(false);
show$ = this.showSubj.asObservable();

Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,10 @@
"@typescript-eslint/eslint-plugin": "4.22.0",
"@typescript-eslint/parser": "4.22.0",
"cpy-cli": "^3.1.1",
"eslint": "7.24.0",
"eslint": "^7.25.0",
"eslint-config-prettier": "8.2.0",
"eslint-plugin-import": "latest",
"eslint-plugin-jest": "^24.3.5",
"eslint-plugin-jest-dom": "3.8.0",
"eslint-plugin-testing-library": "^4.0.1",
"husky": "^4.2.5",
Expand Down
4 changes: 2 additions & 2 deletions projects/jest-utils/.eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,15 @@
"error",
{
"type": "attribute",
"prefix": "lib",
"prefix": "atl",
"style": "camelCase"
}
],
"@angular-eslint/component-selector": [
"error",
{
"type": "element",
"prefix": "lib",
"prefix": "atl",
"style": "kebab-case"
}
]
Expand Down
7 changes: 4 additions & 3 deletions projects/jest-utils/tests/create-mock.spec.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { Component } from '@angular/core';
import { TestBed } from '@angular/core/testing';
import { fireEvent, render } from '@testing-library/angular';

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

class FixtureService {
constructor(private foo: string, public bar: string) {}
Expand All @@ -13,10 +13,10 @@ class FixtureService {
}

@Component({
selector: 'fixture',
selector: 'atl-fixture',
template: ` <button (click)="print()">Print</button> `,
})
export class FixtureComponent {
class FixtureComponent {
constructor(private service: FixtureService) {}

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

// eslint-disable-next-line jest/expect-expect
it('is possible to write a mock implementation', async (done) => {
const { getByText } = await render(FixtureComponent, {
providers: [provideMock(FixtureService)],
Expand Down
4 changes: 2 additions & 2 deletions projects/testing-library/.eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,15 @@
"error",
{
"type": "attribute",
"prefix": "lib",
"prefix": ["atl"],
"style": "camelCase"
}
],
"@angular-eslint/component-selector": [
"error",
{
"type": "element",
"prefix": "lib",
"prefix": ["atl"],
"style": "kebab-case"
}
]
Expand Down
1 change: 1 addition & 0 deletions projects/testing-library/src/lib/testing-library.ts
Original file line number Diff line number Diff line change
Expand Up @@ -358,6 +358,7 @@ if (typeof afterEach === 'function' && !process.env.ATL_SKIP_AUTO_CLEANUP) {
});
}

// TODO: rename to `atl-wrapper-component`
// eslint-disable-next-line @angular-eslint/component-selector
@Component({ selector: 'wrapper-component', template: '' })
class WrapperComponent {}
Expand Down
4 changes: 2 additions & 2 deletions projects/testing-library/tests/auto-cleanup.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import { Component, Input } from '@angular/core';
import { render } from '../src/public_api';

@Component({
selector: 'fixture',
template: ` Hello {{ name }}! `,
selector: 'atl-fixture',
template: `Hello {{ name }}!`,
})
class FixtureComponent {
@Input() name: string;
Expand Down
2 changes: 1 addition & 1 deletion projects/testing-library/tests/config.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { render, configure } from '../src/public_api';
import { ReactiveFormsModule, FormBuilder } from '@angular/forms';

@Component({
selector: 'app-fixture',
selector: 'atl-fixture',
template: `
<form [formGroup]="form" name="form">
<div>
Expand Down
6 changes: 3 additions & 3 deletions projects/testing-library/tests/debug.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Component } from '@angular/core';
import { render } from '../src/public_api';

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

test('debug', async () => {
jest.spyOn(console, 'log').mockImplementation(() => {});
jest.spyOn(console, 'log').mockImplementation();
const { debug } = await render(FixtureComponent);

debug();
Expand All @@ -21,7 +21,7 @@ test('debug', async () => {
});

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

Expand Down
2 changes: 1 addition & 1 deletion projects/testing-library/tests/detect-changes.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { delay } from 'rxjs/operators';
import { render, fireEvent } from '../src/public_api';

@Component({
selector: 'fixture',
selector: 'atl-fixture',
template: `
<input type="text" data-testid="input" [formControl]="inputControl" />
<button data-testid="button">{{ caption }}</button>
Expand Down
2 changes: 1 addition & 1 deletion projects/testing-library/tests/find-by.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { render, screen } from '../src/public_api';
import { mapTo } from 'rxjs/operators';

@Component({
selector: 'fixture',
selector: 'atl-fixture',
template: ` <div>{{ result | async }}</div> `,
})
class FixtureComponent {
Expand Down
2 changes: 1 addition & 1 deletion projects/testing-library/tests/fire-event.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Component } from '@angular/core';
import { render, fireEvent } from '../src/public_api';

@Component({
selector: 'fixture',
selector: 'atl-fixture',
template: ` <input type="text" data-testid="input" /> `,
})
class FixtureComponent {}
Expand Down
2 changes: 1 addition & 1 deletion projects/testing-library/tests/issues/188.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { render } from '../../src/public_api';
@Component({
template: `<h1>Hello {{ formattedName }}</h1>`,
})
export class BugOnChangeComponent implements OnChanges {
class BugOnChangeComponent implements OnChanges {
@Input() name: string;

formattedName: string;
Expand Down
2 changes: 1 addition & 1 deletion projects/testing-library/tests/issues/67.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import { render } from '../../src/public_api';
</div>
`,
})
export class BugGetByLabelTextComponent {}
class BugGetByLabelTextComponent {}

it('first step to reproduce the bug: skip this test to avoid the error or remove the for attribute of label', async () => {
expect(await render(BugGetByLabelTextComponent)).toBeDefined();
Expand Down
2 changes: 1 addition & 1 deletion projects/testing-library/tests/navigate.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { Router } from '@angular/router';
import { render } from '../src/public_api';

@Component({
selector: 'fixture',
selector: 'atl-fixture',
template: ``,
})
class FixtureComponent {}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,17 +43,17 @@ test('shows the provided service value with template syntax', async () => {
});

@Injectable()
export class Service {
class Service {
foo() {
return 'foo';
}
}

@Component({
selector: 'fixture-component',
selector: 'atl-fixture',
template: '{{service.foo()}}',
providers: [Service],
})
export class FixtureComponent {
class FixtureComponent {
constructor(public service: Service) {}
}
Original file line number Diff line number Diff line change
Expand Up @@ -53,16 +53,16 @@ test('shows the provided service value with template syntax', async () => {
});

@Injectable()
export class Service {
class Service {
foo() {
return 'foo';
}
}

@Component({
selector: 'fixture-component',
selector: 'atl-fixture',
template: '{{service.foo()}}',
})
export class FixtureComponent {
class FixtureComponent {
constructor(public service: Service) {}
}
12 changes: 5 additions & 7 deletions projects/testing-library/tests/render-template.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
/* eslint-disable testing-library/no-container */
/* eslint-disable testing-library/render-result-naming-convention */
import { Directive, HostListener, ElementRef, Input, Output, EventEmitter, Component } from '@angular/core';

import { render, fireEvent } from '../src/public_api';
Expand All @@ -8,7 +6,7 @@ import { render, fireEvent } from '../src/public_api';
// eslint-disable-next-line @angular-eslint/directive-selector
selector: '[onOff]',
})
export class OnOffDirective {
class OnOffDirective {
@Input() on = 'on';
@Input() off = 'off';
@Output() clicked = new EventEmitter<string>();
Expand All @@ -27,7 +25,7 @@ export class OnOffDirective {
// eslint-disable-next-line @angular-eslint/directive-selector
selector: '[update]',
})
export class UpdateInputDirective {
class UpdateInputDirective {
@Input()
set update(value: any) {
this.el.nativeElement.textContent = value;
Expand All @@ -41,7 +39,7 @@ export class UpdateInputDirective {
selector: 'greeting',
template: 'Hello {{ name }}!',
})
export class GreetingComponent {
class GreetingComponent {
@Input() name = 'World';
}

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

expect(component.container.querySelector('greeting')).toBeInTheDocument();
expect(component.getByText('Hello Angular!'));
expect(component.getByText('Hello Angular!')).toBeInTheDocument();
});

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

test.only('uses the default props', async () => {
test('uses the default props', async () => {
const component = await render('<div onOff></div>', {
declarations: [OnOffDirective],
});
Expand Down
4 changes: 2 additions & 2 deletions projects/testing-library/tests/render.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import { TestBed } from '@angular/core/testing';
import { render, fireEvent } from '../src/public_api';

@Component({
selector: 'fixture',
selector: 'atl-fixture',
template: `
<input type="text" data-testid="input" />
<button>button</button>
Expand Down Expand Up @@ -83,7 +83,7 @@ describe('animationModule', () => {

describe('Angular component life-cycle hooks', () => {
@Component({
selector: 'fixture',
selector: 'atl-fixture',
template: ` {{ name }} `,
})
class FixtureWithNgOnChangesComponent implements OnInit, OnChanges {
Expand Down
Loading