Skip to content

Commit 9613c9f

Browse files
committed
{chore} setup linting and CI
1 parent 2b6f370 commit 9613c9f

File tree

138 files changed

+1317
-91
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

138 files changed

+1317
-91
lines changed

.eslintignore

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
.yarn
2+
.pnp.js
3+
4+
/packages/*/dist
5+
6+
/integration/e2e/harnesses
7+
/integration/src

.eslintrc.yml

+53
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
env:
2+
node: true
3+
es2021: true
4+
extends:
5+
- 'eslint:recommended'
6+
plugins:
7+
- 'import'
8+
reportUnusedDisableDirectives: true
9+
parserOptions:
10+
ecmaVersion: 12
11+
12+
rules:
13+
# Require packages to be listed in package.json
14+
'import/no-extraneous-dependencies': error
15+
16+
# Disallow mutable exports
17+
'import/no-mutable-exports': error
18+
19+
# Disallow other module systems
20+
'import/no-amd': error
21+
# 'import/no-commonjs': error # already covered via @typescript-eslint/no-var-requires
22+
23+
# Code style
24+
'import/first': error
25+
'import/newline-after-import': error
26+
'import/no-duplicates': error
27+
'import/order':
28+
- error
29+
- groups:
30+
- [builtin, internal, external]
31+
- parent
32+
- [index, sibling]
33+
'newlines-between': always
34+
alphabetize:
35+
order: asc
36+
37+
overrides:
38+
- files: ['**/*.ts']
39+
plugins:
40+
- '@typescript-eslint'
41+
parser: '@typescript-eslint/parser'
42+
parserOptions:
43+
ecmaVersion: 12
44+
sourceType: module
45+
extends:
46+
- 'plugin:@typescript-eslint/recommended'
47+
- 'plugin:import/typescript'
48+
rules:
49+
'@typescript-eslint/no-non-null-assertion': 'off'
50+
'@typescript-eslint/ban-types':
51+
- error
52+
- types:
53+
object: false

.github/workflows/ci-workflow.yml

+80
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
on:
2+
push:
3+
branches:
4+
- main
5+
pull_request:
6+
7+
name: 'CI'
8+
jobs:
9+
code-style:
10+
name: 'Code Style'
11+
runs-on: ubuntu-latest
12+
13+
steps:
14+
- uses: actions/checkout@v2
15+
- uses: actions/setup-node@v2
16+
with:
17+
node-version: 14.x
18+
19+
- name: Install
20+
shell: bash
21+
env:
22+
YARN_ENABLE_NETWORK: 0
23+
run: |
24+
yarn install --immutable --immutable-cache
25+
26+
- name: 'Check for formatting errors (fix w/ "yarn prettier --write path/to/file")'
27+
run: |
28+
yarn prettier --check .
29+
shell: bash
30+
31+
- name: 'Check for linting errors (fix w/ "yarn lint -c fix")'
32+
run: |
33+
yarn sn lint
34+
shell: bash
35+
36+
build-unit:
37+
name: Build
38+
runs-on: ubuntu-latest
39+
40+
steps:
41+
- uses: actions/checkout@v2
42+
- uses: actions/setup-node@v2
43+
with:
44+
node-version: 14.x
45+
46+
- name: Build
47+
shell: bash
48+
run: |
49+
yarn sn build
50+
51+
integration:
52+
name: 'Run ${{matrix.runner}} on node.js ${{matrix.node}}.x on ${{matrix.os}}'
53+
runs-on: ${{matrix.os}}
54+
strategy:
55+
fail-fast: false
56+
matrix:
57+
os:
58+
- ubuntu-latest
59+
- macos-latest
60+
- windows-latest
61+
node:
62+
- 12
63+
- 14
64+
- 15
65+
runner:
66+
- test
67+
- jest
68+
69+
steps:
70+
- uses: actions/checkout@v2
71+
72+
- name: 'Use Node.js ${{matrix.node}}.x'
73+
uses: actions/setup-node@v2
74+
with:
75+
node-version: ${{matrix.node}}.x
76+
77+
- name: 'Run tests'
78+
shell: bash
79+
run: |
80+
yarn sn ${{matrix.runner}} integration

.prettierignore

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
.yarn
22
.pnp.js
33

4-
/packages/*/lib
4+
/packages/*/dist

.vscode/cspell.json

+2
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@
77
"destructure",
88
"destructured",
99
"devkit",
10+
"eslintignore",
1011
"gotink",
12+
"nrwl",
1113
"parens",
1214
"prefs",
1315
"pwdebug",
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.

.yarn/versions/68c05527.yml

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
declined:
2+
- "@ngx-playwright/harness"
3+
- "@ngx-playwright/jest"
4+
- "@ngx-playwright/test"

integration/e2e/harnesses/app-component-harness.ts

+1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
*/
1010

1111
import {ComponentHarness, TestElement, TestKey} from '@angular/cdk/testing';
12+
1213
import {
1314
SubComponentHarness,
1415
SubComponentSpecialHarness,

integration/e2e/jest-specs/cross-environment-specs.ts

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
/* spell-checker: disable */
2+
/* eslint-disable */
23

34
/**
45
* @license

integration/e2e/jest-specs/functionality.e2e-spec.ts

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
/* spell-checker: disable */
22
import {parallel} from '@angular/cdk/testing';
3-
import {crossEnvironmentSpecs} from './cross-environment-specs';
3+
44
import {MainComponentHarness} from '../harnesses/app-component-harness';
55

6+
import {crossEnvironmentSpecs} from './cross-environment-specs';
7+
68
describe('PlaywrightHarnessEnvironment', () => {
79
async function getUrl(path: string) {
810
await page.goto(`${baseUrl}${path}`);

integration/e2e/test-specs/cross-environment.e2e-spec.ts

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
/* spell-checker: disable */
2+
23
/**
34
* @license
45
* Copyright Google LLC All Rights Reserved.

integration/e2e/test-specs/functionality.e2e-spec.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ test.describe('PlaywrightHarnessEnvironment', () => {
9696
expect(await asyncCounter.text()).toBe('8');
9797
});
9898

99-
const manualTest = test.extend<{}>({
99+
const manualTest = test.extend<unknown>({
100100
enableAutomaticStabilization: false,
101101
});
102102

package.json

+8
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
"test": "sn test"
1212
},
1313
"devDependencies": {
14+
"@nrwl/linter": "^12.8.0",
1415
"@snuggery/node": "0.2.1",
1516
"@snuggery/snuggery": "0.4.0",
1617
"@snuggery/yarn": "0.2.0",
@@ -36,5 +37,12 @@
3637
},
3738
"resolutions": {
3839
"@angular-devkit/architect": "0.1200.0"
40+
},
41+
"dependencies": {
42+
"@typescript-eslint/eslint-plugin": "^4.29.3",
43+
"@typescript-eslint/parser": "^4.29.3",
44+
"eslint": "^7.32.0",
45+
"eslint-import-resolver-node": "^0.3.6",
46+
"eslint-plugin-import": "^2.24.2"
3947
}
4048
}

packages/harness/src/browser.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -89,14 +89,14 @@ export function getStyleProperty(
8989
/**
9090
* Returns whether the angular app is bootstrapped
9191
*/
92-
export function isAngularBootstrapped() {
92+
export function isAngularBootstrapped(): boolean {
9393
return typeof frameworkStabilizers !== 'undefined';
9494
}
9595

9696
/**
9797
* Waits until the angular app is stable
9898
*/
99-
export async function waitUntilAngularStable() {
99+
export async function waitUntilAngularStable(): Promise<void> {
100100
if (typeof frameworkStabilizers !== 'undefined') {
101101
await Promise.all(frameworkStabilizers.map(fn => new Promise(fn)));
102102
}

packages/harness/src/change-detection.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import {
33
stopHandlingAutoChangeDetectionStatus,
44
} from '@angular/cdk/testing';
55
import type {Page} from 'playwright-core';
6+
67
import {waitUntilAngularStable} from './browser';
78

89
let isRegistered = false;
@@ -14,7 +15,7 @@ let disabledCount = 0;
1415
* This takes into account whether automatic stabilization is turned on (see
1516
* {@link isAutoStabilizing}) and whether batch-mode is currently enabled.
1617
*/
17-
export function shouldStabilizeAutomatically() {
18+
export function shouldStabilizeAutomatically(): boolean {
1819
return isRegistered && disabledCount === 0;
1920
}
2021

packages/harness/src/element.ts

+7-2
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ export class PlaywrightElement implements TestElement {
185185
relativeY: number,
186186
modifierKeys?: ModifierKeys,
187187
): Promise<void>;
188-
click(...args: ClickParameters) {
188+
click(...args: ClickParameters): Promise<void> {
189189
return this.#perform(async handle =>
190190
handle.click(await this.#toClickOptions(...args)),
191191
);
@@ -214,6 +214,8 @@ export class PlaywrightElement implements TestElement {
214214
// placed on the event directly rather than on the `details` property
215215

216216
return this.#perform(handle =>
217+
// Cast to `any` needed because of infinite type instantiation
218+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
217219
handle.evaluate(dispatchEvent, [name, data] as [string, any]),
218220
);
219221
}
@@ -268,10 +270,11 @@ export class PlaywrightElement implements TestElement {
268270
): Promise<void>;
269271
sendKeys(
270272
...keys: (string | TestKey)[] | [ModifierKeys, ...(string | TestKey)[]]
271-
) {
273+
): Promise<void> {
272274
let modifiers: string | undefined;
273275
if (hasModifiers(keys)) {
274276
let modifiersObject: ModifierKeys;
277+
// eslint-disable-next-line prefer-const
275278
[modifiersObject, ...keys] = keys;
276279

277280
modifiers = getModifiers(modifiersObject).join('+');
@@ -335,6 +338,8 @@ export class PlaywrightElement implements TestElement {
335338
return this.#query(handle => handle.evaluate(getBoundingClientRect));
336339
}
337340

341+
// Any required by interface
342+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
338343
async getProperty(name: string): Promise<any> {
339344
const property = await this.#query(handle => handle.getProperty(name));
340345

packages/harness/src/environment.ts

+7-5
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import {HarnessEnvironment, TestElement} from '@angular/cdk/testing';
22
import type {ElementHandle, Page} from 'playwright-core';
3+
34
import {isAngularBootstrapped, waitUntilAngularStable} from './browser';
45
import {shouldStabilizeAutomatically} from './change-detection';
5-
66
import {PlaywrightElement} from './element';
77
import {LazyRootHandle} from './lazy-handle';
88

@@ -87,7 +87,7 @@ export class PlaywrightHarnessEnvironmentImplementation extends PlaywrightHarnes
8787
return this.#opts.respectShadowBoundaries;
8888
}
8989

90-
async waitForAngularReady() {
90+
async waitForAngularReady(): Promise<void> {
9191
try {
9292
await this.#page.waitForFunction(isAngularBootstrapped);
9393
} catch {
@@ -99,15 +99,17 @@ export class PlaywrightHarnessEnvironmentImplementation extends PlaywrightHarnes
9999
await this.forceStabilize();
100100
}
101101

102-
async forceStabilize() {
102+
async forceStabilize(): Promise<void> {
103103
await this.#page.evaluate(waitUntilAngularStable);
104104
}
105105

106-
async waitForTasksOutsideAngular() {
106+
async waitForTasksOutsideAngular(): Promise<void> {
107107
// TODO: how?, see also: https://github.com/angular/components/issues/17412
108108
}
109109

110-
getPlaywrightHandle(element: TestElement) {
110+
getPlaywrightHandle(
111+
element: TestElement,
112+
): ElementHandle<HTMLElement | SVGElement> {
111113
const handle = elementHandles.get(element);
112114

113115
if (handle == null) {

packages/harness/src/lazy-handle.ts

+3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
/* eslint-disable @typescript-eslint/explicit-module-boundary-types */
2+
/* eslint-disable @typescript-eslint/no-explicit-any */
3+
14
import type {ElementHandle, Frame, JSHandle, Page} from 'playwright-core';
25
import type {
36
PageFunctionOn,

packages/jest/src/browsers/cache-key.ts

+4-1
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,9 @@ function toSortedObject(value: unknown): unknown {
4343
return Object.fromEntries(
4444
Object.keys(value)
4545
.sort()
46-
.map(key => [key, toSortedObject((value as any)[key])]),
46+
.map(key => [
47+
key,
48+
toSortedObject((value as {[key in typeof key]: unknown})[key]),
49+
]),
4750
);
4851
}

packages/jest/src/browsers/get-browser-type.ts

+3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
/* eslint-disable @typescript-eslint/no-var-requires */
2+
13
import {
24
BrowserType,
35
chromium,
@@ -7,6 +9,7 @@ import {
79
webkit,
810
WebKitBrowser,
911
} from 'playwright-core';
12+
1013
import type {BrowserSpec, RunnerBrowserSpec} from './types';
1114

1215
const getBrowserTypeByType = {

packages/jest/src/browsers/launcher/launch.ts

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import type {Browser, BrowserServer, BrowserType} from 'playwright-core';
2+
23
import {
34
BrowserLauncher,
45
BrowserSpec,
@@ -42,13 +43,13 @@ export class LaunchLauncher implements BrowserLauncher {
4243
};
4344
}
4445

45-
async setup() {
46+
async setup(): Promise<void> {
4647
if (this.#browser == null) {
4748
this.#browser = await this.#browserType.launchServer(this.#options);
4849
}
4950
}
5051

51-
async teardown() {
52+
async teardown(): Promise<void> {
5253
await this.#browser?.close();
5354
}
5455
}

0 commit comments

Comments
 (0)