mirror of
https://github.com/microsoft/playwright.git
synced 2024-11-24 06:49:04 +03:00
chore: strengthen linting (#29669)
This commit is contained in:
parent
01846b954d
commit
9d0430fa26
15
.eslintrc-with-ts-config.js
Normal file
15
.eslintrc-with-ts-config.js
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
module.exports = {
|
||||||
|
extends: "./.eslintrc.js",
|
||||||
|
parserOptions: {
|
||||||
|
ecmaVersion: 9,
|
||||||
|
sourceType: "module",
|
||||||
|
project: "./tsconfig.json",
|
||||||
|
},
|
||||||
|
rules: {
|
||||||
|
"@typescript-eslint/no-base-to-string": "error",
|
||||||
|
"@typescript-eslint/no-unnecessary-boolean-literal-compare": 2,
|
||||||
|
},
|
||||||
|
parserOptions: {
|
||||||
|
project: "./tsconfig.json"
|
||||||
|
},
|
||||||
|
};
|
@ -4,7 +4,6 @@ module.exports = {
|
|||||||
parserOptions: {
|
parserOptions: {
|
||||||
ecmaVersion: 9,
|
ecmaVersion: 9,
|
||||||
sourceType: "module",
|
sourceType: "module",
|
||||||
project: "./tsconfig.json",
|
|
||||||
},
|
},
|
||||||
extends: [
|
extends: [
|
||||||
"plugin:react-hooks/recommended"
|
"plugin:react-hooks/recommended"
|
||||||
@ -49,6 +48,7 @@ module.exports = {
|
|||||||
"arrow-parens": [2, "as-needed"],
|
"arrow-parens": [2, "as-needed"],
|
||||||
"prefer-const": 2,
|
"prefer-const": 2,
|
||||||
"quote-props": [2, "consistent"],
|
"quote-props": [2, "consistent"],
|
||||||
|
"nonblock-statement-body-position": [2, "below"],
|
||||||
|
|
||||||
// anti-patterns
|
// anti-patterns
|
||||||
"no-var": 2,
|
"no-var": 2,
|
||||||
|
@ -137,10 +137,12 @@ self.addEventListener('fetch', event => {
|
|||||||
(async () => {
|
(async () => {
|
||||||
// 1. Try to first serve directly from caches
|
// 1. Try to first serve directly from caches
|
||||||
const response = await caches.match(event.request);
|
const response = await caches.match(event.request);
|
||||||
if (response) return response;
|
if (response)
|
||||||
|
return response;
|
||||||
|
|
||||||
// 2. Re-write request for /foo to /bar
|
// 2. Re-write request for /foo to /bar
|
||||||
if (event.request.url.endsWith('foo')) return fetch('./bar');
|
if (event.request.url.endsWith('foo'))
|
||||||
|
return fetch('./bar');
|
||||||
|
|
||||||
// 3. Prevent tracker.js from being retrieved, and returns a placeholder response
|
// 3. Prevent tracker.js from being retrieved, and returns a placeholder response
|
||||||
if (event.request.url.endsWith('tracker.js')) {
|
if (event.request.url.endsWith('tracker.js')) {
|
||||||
|
@ -1,9 +0,0 @@
|
|||||||
module.exports = {
|
|
||||||
extends: ".eslintrc.js",
|
|
||||||
rules: {
|
|
||||||
"@typescript-eslint/no-base-to-string": "error",
|
|
||||||
},
|
|
||||||
parserOptions: {
|
|
||||||
project: "./tsconfig.json"
|
|
||||||
},
|
|
||||||
};
|
|
@ -1,3 +1,3 @@
|
|||||||
module.exports = {
|
module.exports = {
|
||||||
extends: "../.eslintrc-with-ts-config.js",
|
extends: "../../.eslintrc-with-ts-config.js",
|
||||||
};
|
};
|
||||||
|
@ -526,7 +526,7 @@ export async function prepareBrowserContextParams(options: BrowserContextOptions
|
|||||||
function toAcceptDownloadsProtocol(acceptDownloads?: boolean) {
|
function toAcceptDownloadsProtocol(acceptDownloads?: boolean) {
|
||||||
if (acceptDownloads === undefined)
|
if (acceptDownloads === undefined)
|
||||||
return undefined;
|
return undefined;
|
||||||
if (acceptDownloads === true)
|
if (acceptDownloads)
|
||||||
return 'accept';
|
return 'accept';
|
||||||
return 'deny';
|
return 'deny';
|
||||||
}
|
}
|
||||||
|
@ -594,7 +594,8 @@ export class CRBrowserContext extends BrowserContext {
|
|||||||
targetId = (page._delegate as CRPage)._targetId;
|
targetId = (page._delegate as CRPage)._targetId;
|
||||||
} else if (page instanceof Frame) {
|
} else if (page instanceof Frame) {
|
||||||
const session = (page._page._delegate as CRPage)._sessions.get(page._id);
|
const session = (page._page._delegate as CRPage)._sessions.get(page._id);
|
||||||
if (!session) throw new Error(`This frame does not have a separate CDP session, it is a part of the parent frame's session`);
|
if (!session)
|
||||||
|
throw new Error(`This frame does not have a separate CDP session, it is a part of the parent frame's session`);
|
||||||
targetId = session._targetId;
|
targetId = session._targetId;
|
||||||
} else {
|
} else {
|
||||||
throw new Error('page: expected Page or Frame');
|
throw new Error('page: expected Page or Frame');
|
||||||
|
@ -86,12 +86,18 @@ function buildComponentsTreeVue3(instance: VueVNode): ComponentNode {
|
|||||||
// @see https://github.com/vuejs/devtools/blob/e7132f3392b975e39e1d9a23cf30456c270099c2/packages/app-backend-vue3/src/components/util.ts#L29
|
// @see https://github.com/vuejs/devtools/blob/e7132f3392b975e39e1d9a23cf30456c270099c2/packages/app-backend-vue3/src/components/util.ts#L29
|
||||||
function getInstanceName(instance: VueVNode): string {
|
function getInstanceName(instance: VueVNode): string {
|
||||||
const name = getComponentTypeName(instance.type || {});
|
const name = getComponentTypeName(instance.type || {});
|
||||||
if (name) return name;
|
if (name)
|
||||||
if (instance.root === instance) return 'Root';
|
return name;
|
||||||
for (const key in instance.parent?.type?.components)
|
if (instance.root === instance)
|
||||||
if (instance.parent?.type.components[key] === instance.type) return saveComponentName(instance, key);
|
return 'Root';
|
||||||
for (const key in instance.appContext?.components)
|
for (const key in instance.parent?.type?.components) {
|
||||||
if (instance.appContext.components[key] === instance.type) return saveComponentName(instance, key);
|
if (instance.parent?.type.components[key] === instance.type)
|
||||||
|
return saveComponentName(instance, key);
|
||||||
|
}
|
||||||
|
for (const key in instance.appContext?.components) {
|
||||||
|
if (instance.appContext.components[key] === instance.type)
|
||||||
|
return saveComponentName(instance, key);
|
||||||
|
}
|
||||||
return 'Anonymous Component';
|
return 'Anonymous Component';
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -132,7 +138,8 @@ function buildComponentsTreeVue3(instance: VueVNode): ComponentNode {
|
|||||||
|
|
||||||
// @see https://github.com/vuejs/devtools/blob/e7132f3392b975e39e1d9a23cf30456c270099c2/packages/app-backend-vue3/src/components/el.ts#L15
|
// @see https://github.com/vuejs/devtools/blob/e7132f3392b975e39e1d9a23cf30456c270099c2/packages/app-backend-vue3/src/components/el.ts#L15
|
||||||
function getFragmentRootElements(vnode: any): Element[] {
|
function getFragmentRootElements(vnode: any): Element[] {
|
||||||
if (!vnode.children) return [];
|
if (!vnode.children)
|
||||||
|
return [];
|
||||||
|
|
||||||
const list = [];
|
const list = [];
|
||||||
|
|
||||||
|
@ -48,8 +48,10 @@ function preprocess(str: string): number[] {
|
|||||||
if (code === 0xd && str.charCodeAt(i + 1) === 0xa) {
|
if (code === 0xd && str.charCodeAt(i + 1) === 0xa) {
|
||||||
code = 0xa; i++;
|
code = 0xa; i++;
|
||||||
}
|
}
|
||||||
if (code === 0xd || code === 0xc) code = 0xa;
|
if (code === 0xd || code === 0xc)
|
||||||
if (code === 0x0) code = 0xfffd;
|
code = 0xa;
|
||||||
|
if (code === 0x0)
|
||||||
|
code = 0xfffd;
|
||||||
if (between(code, 0xd800, 0xdbff) && between(str.charCodeAt(i + 1), 0xdc00, 0xdfff)) {
|
if (between(code, 0xd800, 0xdbff) && between(str.charCodeAt(i + 1), 0xdc00, 0xdfff)) {
|
||||||
// Decode a surrogate pair into an astral codepoint.
|
// Decode a surrogate pair into an astral codepoint.
|
||||||
const lead = code - 0xd800;
|
const lead = code - 0xd800;
|
||||||
@ -63,7 +65,8 @@ function preprocess(str: string): number[] {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function stringFromCode(code: number) {
|
function stringFromCode(code: number) {
|
||||||
if (code <= 0xffff) return String.fromCharCode(code);
|
if (code <= 0xffff)
|
||||||
|
return String.fromCharCode(code);
|
||||||
// Otherwise, encode astral char as surrogate pair.
|
// Otherwise, encode astral char as surrogate pair.
|
||||||
code -= Math.pow(2, 16);
|
code -= Math.pow(2, 16);
|
||||||
const lead = Math.floor(code / Math.pow(2, 10)) + 0xd800;
|
const lead = Math.floor(code / Math.pow(2, 10)) + 0xd800;
|
||||||
@ -107,8 +110,10 @@ export function tokenize(str1: string): CSSTokenInterface[] {
|
|||||||
num = 1;
|
num = 1;
|
||||||
i += num;
|
i += num;
|
||||||
code = codepoint(i);
|
code = codepoint(i);
|
||||||
if (newline(code)) incrLineno();
|
if (newline(code))
|
||||||
else column += num;
|
incrLineno();
|
||||||
|
else
|
||||||
|
column += num;
|
||||||
// console.log('Consume '+i+' '+String.fromCharCode(code) + ' 0x' + code.toString(16));
|
// console.log('Consume '+i+' '+String.fromCharCode(code) + ' 0x' + code.toString(16));
|
||||||
return true;
|
return true;
|
||||||
};
|
};
|
||||||
@ -125,7 +130,8 @@ export function tokenize(str1: string): CSSTokenInterface[] {
|
|||||||
return true;
|
return true;
|
||||||
};
|
};
|
||||||
const eof = function(codepoint?: number): boolean {
|
const eof = function(codepoint?: number): boolean {
|
||||||
if (codepoint === undefined) codepoint = code;
|
if (codepoint === undefined)
|
||||||
|
codepoint = code;
|
||||||
return codepoint === -1;
|
return codepoint === -1;
|
||||||
};
|
};
|
||||||
const donothing = function() { };
|
const donothing = function() { };
|
||||||
@ -138,12 +144,14 @@ export function tokenize(str1: string): CSSTokenInterface[] {
|
|||||||
consumeComments();
|
consumeComments();
|
||||||
consume();
|
consume();
|
||||||
if (whitespace(code)) {
|
if (whitespace(code)) {
|
||||||
while (whitespace(next())) consume();
|
while (whitespace(next()))
|
||||||
|
consume();
|
||||||
return new WhitespaceToken();
|
return new WhitespaceToken();
|
||||||
} else if (code === 0x22) {return consumeAStringToken();} else if (code === 0x23) {
|
} else if (code === 0x22) {return consumeAStringToken();} else if (code === 0x23) {
|
||||||
if (namechar(next()) || areAValidEscape(next(1), next(2))) {
|
if (namechar(next()) || areAValidEscape(next(1), next(2))) {
|
||||||
const token = new HashToken('');
|
const token = new HashToken('');
|
||||||
if (wouldStartAnIdentifier(next(1), next(2), next(3))) token.type = 'id';
|
if (wouldStartAnIdentifier(next(1), next(2), next(3)))
|
||||||
|
token.type = 'id';
|
||||||
token.value = consumeAName();
|
token.value = consumeAName();
|
||||||
return token;
|
return token;
|
||||||
} else {
|
} else {
|
||||||
@ -288,7 +296,8 @@ export function tokenize(str1: string): CSSTokenInterface[] {
|
|||||||
const str = consumeAName();
|
const str = consumeAName();
|
||||||
if (str.toLowerCase() === 'url' && next() === 0x28) {
|
if (str.toLowerCase() === 'url' && next() === 0x28) {
|
||||||
consume();
|
consume();
|
||||||
while (whitespace(next(1)) && whitespace(next(2))) consume();
|
while (whitespace(next(1)) && whitespace(next(2)))
|
||||||
|
consume();
|
||||||
if (next() === 0x22 || next() === 0x27)
|
if (next() === 0x22 || next() === 0x27)
|
||||||
return new FunctionToken(str);
|
return new FunctionToken(str);
|
||||||
else if (whitespace(next()) && (next(2) === 0x22 || next(2) === 0x27))
|
else if (whitespace(next()) && (next(2) === 0x22 || next(2) === 0x27))
|
||||||
@ -305,7 +314,8 @@ export function tokenize(str1: string): CSSTokenInterface[] {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const consumeAStringToken = function(endingCodePoint?: number): CSSParserToken {
|
const consumeAStringToken = function(endingCodePoint?: number): CSSParserToken {
|
||||||
if (endingCodePoint === undefined) endingCodePoint = code;
|
if (endingCodePoint === undefined)
|
||||||
|
endingCodePoint = code;
|
||||||
let string = '';
|
let string = '';
|
||||||
while (consume()) {
|
while (consume()) {
|
||||||
if (code === endingCodePoint || eof()) {
|
if (code === endingCodePoint || eof()) {
|
||||||
@ -331,13 +341,16 @@ export function tokenize(str1: string): CSSTokenInterface[] {
|
|||||||
|
|
||||||
const consumeAURLToken = function(): CSSTokenInterface {
|
const consumeAURLToken = function(): CSSTokenInterface {
|
||||||
const token = new URLToken('');
|
const token = new URLToken('');
|
||||||
while (whitespace(next())) consume();
|
while (whitespace(next()))
|
||||||
if (eof(next())) return token;
|
consume();
|
||||||
|
if (eof(next()))
|
||||||
|
return token;
|
||||||
while (consume()) {
|
while (consume()) {
|
||||||
if (code === 0x29 || eof()) {
|
if (code === 0x29 || eof()) {
|
||||||
return token;
|
return token;
|
||||||
} else if (whitespace(code)) {
|
} else if (whitespace(code)) {
|
||||||
while (whitespace(next())) consume();
|
while (whitespace(next()))
|
||||||
|
consume();
|
||||||
if (next() === 0x29 || eof(next())) {
|
if (next() === 0x29 || eof(next())) {
|
||||||
consume();
|
consume();
|
||||||
return token;
|
return token;
|
||||||
@ -379,9 +392,11 @@ export function tokenize(str1: string): CSSTokenInterface[] {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (whitespace(next())) consume();
|
if (whitespace(next()))
|
||||||
|
consume();
|
||||||
let value = parseInt(digits.map(function(x) { return String.fromCharCode(x); }).join(''), 16);
|
let value = parseInt(digits.map(function(x) { return String.fromCharCode(x); }).join(''), 16);
|
||||||
if (value > maximumallowedcodepoint) value = 0xfffd;
|
if (value > maximumallowedcodepoint)
|
||||||
|
value = 0xfffd;
|
||||||
return value;
|
return value;
|
||||||
} else if (eof()) {
|
} else if (eof()) {
|
||||||
return 0xfffd;
|
return 0xfffd;
|
||||||
@ -391,8 +406,10 @@ export function tokenize(str1: string): CSSTokenInterface[] {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const areAValidEscape = function(c1: number, c2: number) {
|
const areAValidEscape = function(c1: number, c2: number) {
|
||||||
if (c1 !== 0x5c) return false;
|
if (c1 !== 0x5c)
|
||||||
if (newline(c2)) return false;
|
return false;
|
||||||
|
if (newline(c2))
|
||||||
|
return false;
|
||||||
return true;
|
return true;
|
||||||
};
|
};
|
||||||
const startsWithAValidEscape = function() {
|
const startsWithAValidEscape = function() {
|
||||||
@ -416,11 +433,14 @@ export function tokenize(str1: string): CSSTokenInterface[] {
|
|||||||
|
|
||||||
const wouldStartANumber = function(c1: number, c2: number, c3: number) {
|
const wouldStartANumber = function(c1: number, c2: number, c3: number) {
|
||||||
if (c1 === 0x2b || c1 === 0x2d) {
|
if (c1 === 0x2b || c1 === 0x2d) {
|
||||||
if (digit(c2)) return true;
|
if (digit(c2))
|
||||||
if (c2 === 0x2e && digit(c3)) return true;
|
return true;
|
||||||
|
if (c2 === 0x2e && digit(c3))
|
||||||
|
return true;
|
||||||
return false;
|
return false;
|
||||||
} else if (c1 === 0x2e) {
|
} else if (c1 === 0x2e) {
|
||||||
if (digit(c2)) return true;
|
if (digit(c2))
|
||||||
|
return true;
|
||||||
return false;
|
return false;
|
||||||
} else if (digit(c1)) {
|
} else if (digit(c1)) {
|
||||||
return true;
|
return true;
|
||||||
@ -519,7 +539,8 @@ export function tokenize(str1: string): CSSTokenInterface[] {
|
|||||||
while (!eof(next())) {
|
while (!eof(next())) {
|
||||||
tokens.push(consumeAToken());
|
tokens.push(consumeAToken());
|
||||||
iterationCount++;
|
iterationCount++;
|
||||||
if (iterationCount > str.length * 2) throw new Error("I'm infinite-looping!");
|
if (iterationCount > str.length * 2)
|
||||||
|
throw new Error("I'm infinite-looping!");
|
||||||
}
|
}
|
||||||
return tokens;
|
return tokens;
|
||||||
}
|
}
|
||||||
|
@ -1,3 +1,3 @@
|
|||||||
module.exports = {
|
module.exports = {
|
||||||
extends: "../.eslintrc-with-ts-config.js",
|
extends: "../../.eslintrc-with-ts-config.js",
|
||||||
};
|
};
|
||||||
|
@ -55,7 +55,8 @@ function __pwCreateSlots(slots) {
|
|||||||
__pwInsert(target, element, anchor);
|
__pwInsert(target, element, anchor);
|
||||||
},
|
},
|
||||||
d: function destroy(detaching) {
|
d: function destroy(detaching) {
|
||||||
if (detaching) __pwDetach(element);
|
if (detaching)
|
||||||
|
__pwDetach(element);
|
||||||
},
|
},
|
||||||
l: __pwNoop,
|
l: __pwNoop,
|
||||||
};
|
};
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
module.exports = {
|
module.exports = {
|
||||||
extends: '../.eslintrc.js',
|
extends: '../../.eslintrc-with-ts-config.js',
|
||||||
rules: {
|
rules: {
|
||||||
'@typescript-eslint/no-floating-promises': 'error',
|
'@typescript-eslint/no-floating-promises': 'error',
|
||||||
},
|
},
|
||||||
|
@ -25,7 +25,7 @@ export function matcherHint(state: ExpectMatcherContext, locator: Locator | unde
|
|||||||
if (timeout)
|
if (timeout)
|
||||||
header = colors.red(`Timed out ${timeout}ms waiting for `) + header;
|
header = colors.red(`Timed out ${timeout}ms waiting for `) + header;
|
||||||
if (locator)
|
if (locator)
|
||||||
header += `Locator: ${locator}\n`;
|
header += `Locator: ${String(locator)}\n`;
|
||||||
return header;
|
return header;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -40,7 +40,7 @@ export function toBeAttached(
|
|||||||
locator: LocatorEx,
|
locator: LocatorEx,
|
||||||
options?: { attached?: boolean, timeout?: number },
|
options?: { attached?: boolean, timeout?: number },
|
||||||
) {
|
) {
|
||||||
const attached = !options || options.attached === undefined || options.attached === true;
|
const attached = !options || options.attached === undefined || options.attached;
|
||||||
const expected = attached ? 'attached' : 'detached';
|
const expected = attached ? 'attached' : 'detached';
|
||||||
const unexpected = attached ? 'detached' : 'attached';
|
const unexpected = attached ? 'detached' : 'attached';
|
||||||
const arg = attached ? '' : '{ attached: false }';
|
const arg = attached ? '' : '{ attached: false }';
|
||||||
@ -54,7 +54,7 @@ export function toBeChecked(
|
|||||||
locator: LocatorEx,
|
locator: LocatorEx,
|
||||||
options?: { checked?: boolean, timeout?: number },
|
options?: { checked?: boolean, timeout?: number },
|
||||||
) {
|
) {
|
||||||
const checked = !options || options.checked === undefined || options.checked === true;
|
const checked = !options || options.checked === undefined || options.checked;
|
||||||
const expected = checked ? 'checked' : 'unchecked';
|
const expected = checked ? 'checked' : 'unchecked';
|
||||||
const unexpected = checked ? 'unchecked' : 'checked';
|
const unexpected = checked ? 'unchecked' : 'checked';
|
||||||
const arg = checked ? '' : '{ checked: false }';
|
const arg = checked ? '' : '{ checked: false }';
|
||||||
@ -78,7 +78,7 @@ export function toBeEditable(
|
|||||||
locator: LocatorEx,
|
locator: LocatorEx,
|
||||||
options?: { editable?: boolean, timeout?: number },
|
options?: { editable?: boolean, timeout?: number },
|
||||||
) {
|
) {
|
||||||
const editable = !options || options.editable === undefined || options.editable === true;
|
const editable = !options || options.editable === undefined || options.editable;
|
||||||
const expected = editable ? 'editable' : 'readOnly';
|
const expected = editable ? 'editable' : 'readOnly';
|
||||||
const unexpected = editable ? 'readOnly' : 'editable';
|
const unexpected = editable ? 'readOnly' : 'editable';
|
||||||
const arg = editable ? '' : '{ editable: false }';
|
const arg = editable ? '' : '{ editable: false }';
|
||||||
@ -102,7 +102,7 @@ export function toBeEnabled(
|
|||||||
locator: LocatorEx,
|
locator: LocatorEx,
|
||||||
options?: { enabled?: boolean, timeout?: number },
|
options?: { enabled?: boolean, timeout?: number },
|
||||||
) {
|
) {
|
||||||
const enabled = !options || options.enabled === undefined || options.enabled === true;
|
const enabled = !options || options.enabled === undefined || options.enabled;
|
||||||
const expected = enabled ? 'enabled' : 'disabled';
|
const expected = enabled ? 'enabled' : 'disabled';
|
||||||
const unexpected = enabled ? 'disabled' : 'enabled';
|
const unexpected = enabled ? 'disabled' : 'enabled';
|
||||||
const arg = enabled ? '' : '{ enabled: false }';
|
const arg = enabled ? '' : '{ enabled: false }';
|
||||||
@ -136,7 +136,7 @@ export function toBeVisible(
|
|||||||
locator: LocatorEx,
|
locator: LocatorEx,
|
||||||
options?: { visible?: boolean, timeout?: number },
|
options?: { visible?: boolean, timeout?: number },
|
||||||
) {
|
) {
|
||||||
const visible = !options || options.visible === undefined || options.visible === true;
|
const visible = !options || options.visible === undefined || options.visible;
|
||||||
const expected = visible ? 'visible' : 'hidden';
|
const expected = visible ? 'visible' : 'hidden';
|
||||||
const unexpected = visible ? 'hidden' : 'visible';
|
const unexpected = visible ? 'hidden' : 'visible';
|
||||||
const arg = visible ? '' : '{ visible: false }';
|
const arg = visible ? '' : '{ visible: false }';
|
||||||
|
@ -43,7 +43,7 @@ export async function runTestServer() {
|
|||||||
onConnection(request: http.IncomingMessage, url: URL, ws: WebSocket, id: string) {
|
onConnection(request: http.IncomingMessage, url: URL, ws: WebSocket, id: string) {
|
||||||
const dispatcher = new Dispatcher(ws);
|
const dispatcher = new Dispatcher(ws);
|
||||||
ws.on('message', async message => {
|
ws.on('message', async message => {
|
||||||
const { id, method, params } = JSON.parse(message.toString());
|
const { id, method, params } = JSON.parse(String(message));
|
||||||
try {
|
try {
|
||||||
const result = await (dispatcher as any)[method](params);
|
const result = await (dispatcher as any)[method](params);
|
||||||
ws.send(JSON.stringify({ id, result }));
|
ws.send(JSON.stringify({ id, result }));
|
||||||
|
@ -208,7 +208,8 @@ export function addSuffixToFilePath(filePath: string, suffix: string, customExte
|
|||||||
*/
|
*/
|
||||||
export function getContainedPath(parentPath: string, subPath: string = ''): string | null {
|
export function getContainedPath(parentPath: string, subPath: string = ''): string | null {
|
||||||
const resolvedPath = path.resolve(parentPath, subPath);
|
const resolvedPath = path.resolve(parentPath, subPath);
|
||||||
if (resolvedPath === parentPath || resolvedPath.startsWith(parentPath + path.sep)) return resolvedPath;
|
if (resolvedPath === parentPath || resolvedPath.startsWith(parentPath + path.sep))
|
||||||
|
return resolvedPath;
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -11,5 +11,6 @@ module.exports = {
|
|||||||
},
|
},
|
||||||
rules: {
|
rules: {
|
||||||
'@typescript-eslint/no-floating-promises': 'error',
|
'@typescript-eslint/no-floating-promises': 'error',
|
||||||
|
"@typescript-eslint/no-unnecessary-boolean-literal-compare": 2,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
@ -38,7 +38,10 @@ it('should work @smoke', async ({ page, browserName }) => {
|
|||||||
it('should emit same log twice', async ({ page }) => {
|
it('should emit same log twice', async ({ page }) => {
|
||||||
const messages = [];
|
const messages = [];
|
||||||
page.on('console', m => messages.push(m.text()));
|
page.on('console', m => messages.push(m.text()));
|
||||||
await page.evaluate(() => { for (let i = 0; i < 2; ++i) console.log('hello'); });
|
await page.evaluate(() => {
|
||||||
|
for (let i = 0; i < 2; ++i)
|
||||||
|
console.log('hello');
|
||||||
|
});
|
||||||
expect(messages).toEqual(['hello', 'hello']);
|
expect(messages).toEqual(['hello', 'hello']);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -723,7 +723,7 @@ it.describe('page screenshot animations', () => {
|
|||||||
el.addEventListener('transitionend', () => {
|
el.addEventListener('transitionend', () => {
|
||||||
const time = Date.now();
|
const time = Date.now();
|
||||||
// Block main thread for 200ms, emulating heavy layout.
|
// Block main thread for 200ms, emulating heavy layout.
|
||||||
while (Date.now() - time < 200) ;
|
while (Date.now() - time < 200) {}
|
||||||
const h1 = document.createElement('h1');
|
const h1 = document.createElement('h1');
|
||||||
h1.textContent = 'woof-woof';
|
h1.textContent = 'woof-woof';
|
||||||
document.body.append(h1);
|
document.body.append(h1);
|
||||||
|
@ -438,7 +438,8 @@ test(`should support self signed certificate`, async ({ runInlineTest, httpsServ
|
|||||||
test('should send Accept header', async ({ runInlineTest, server }) => {
|
test('should send Accept header', async ({ runInlineTest, server }) => {
|
||||||
let acceptHeader: string | undefined | null = null;
|
let acceptHeader: string | undefined | null = null;
|
||||||
server.setRoute('/hello', (req, res) => {
|
server.setRoute('/hello', (req, res) => {
|
||||||
if (acceptHeader === null) acceptHeader = req.headers.accept;
|
if (acceptHeader === null)
|
||||||
|
acceptHeader = req.headers.accept;
|
||||||
res.end('<html><body>hello</body></html>');
|
res.end('<html><body>hello</body></html>');
|
||||||
});
|
});
|
||||||
const result = await runInlineTest({
|
const result = await runInlineTest({
|
||||||
|
@ -180,7 +180,10 @@ class JSLintingService extends LintingService {
|
|||||||
* @returns {Promise<LintResult[]>}
|
* @returns {Promise<LintResult[]>}
|
||||||
*/
|
*/
|
||||||
async lint(snippets) {
|
async lint(snippets) {
|
||||||
return Promise.all(snippets.map(async snippet => this._lintSnippet(snippet)));
|
const result = [];
|
||||||
|
for (let i = 0; i < snippets.length; ++i)
|
||||||
|
result.push(await this._lintSnippet(snippets[i]));
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user