chore: fix eslint issues (#9017)

This commit is contained in:
Martin Guillon
2020-11-11 17:46:36 +01:00
committed by GitHub
parent 05faa867d0
commit c1f231d88e
171 changed files with 1607 additions and 1550 deletions

View File

@@ -1,5 +1,5 @@
declare var __registerDomainDispatcher;
declare var __inspectorSendEvent;
declare let __registerDomainDispatcher;
declare let __inspectorSendEvent;
export function DomainDispatcher(domain: string): ClassDecorator {
return (klass) => __registerDomainDispatcher(domain, klass);
}

View File

@@ -6,11 +6,13 @@ import { getNodeById } from './dom-node';
import { mainThreadify } from '../utils';
// Use lazy requires for core modules
// eslint-disable-next-line @typescript-eslint/no-var-requires
const getAppRootView = () => require('../application').getRootView();
let unsetValue;
function unsetViewValue(view, name) {
if (!unsetValue) {
// eslint-disable-next-line @typescript-eslint/no-var-requires
unsetValue = require('../ui/core/properties').unsetValue;
}
@@ -55,7 +57,7 @@ export const removeNode = mainThreadify(function removeNode(nodeId) {
const view = getViewById(nodeId);
if (view) {
// Avoid importing layout and content view
let parent = <any>view.parent;
const parent = <any>view.parent;
if (parent.removeChild) {
parent.removeChild(view);
} else if (parent.content === view) {
@@ -70,14 +72,14 @@ export const setAttributeAsText = mainThreadify(function setAttributeAsText(node
const view = getViewById(nodeId);
if (view) {
// attribute is registered for the view instance
let hasOriginalAttribute = !!name.trim();
const hasOriginalAttribute = !!name.trim();
if (text) {
let textParts = text.split('=');
const textParts = text.split('=');
if (textParts.length === 2) {
let attrName = textParts[0];
let attrValue = textParts[1].replace(/['"]+/g, '');
const attrName = textParts[0];
const attrValue = textParts[1].replace(/['"]+/g, '');
// if attr name is being replaced with another
if (name !== attrName && hasOriginalAttribute) {

View File

@@ -14,8 +14,11 @@ function lazy<T>(action: () => T): () => T {
return () => _value || (_value = action());
}
// eslint-disable-next-line @typescript-eslint/no-var-requires
const percentLengthToStringLazy = lazy<(length) => string>(() => require('../ui/styling/style-properties').PercentLength.convertToString);
// eslint-disable-next-line @typescript-eslint/no-var-requires
const getSetPropertiesLazy = lazy<(view: ViewBase) => [string, any][]>(() => require('../ui/core/properties').getSetProperties);
// eslint-disable-next-line @typescript-eslint/no-var-requires
const getComputedCssValuesLazy = lazy<(view: ViewBase) => [string, any][]>(() => require('../ui/core/properties').getComputedCssValues);
export function registerInspectorEvents(inspector: InspectorEvents) {
@@ -128,7 +131,7 @@ export class DOMNode {
return true;
});
const index = !!previousChild ? previousChild._domId : 0;
const index = previousChild ? previousChild._domId : 0;
childView.ensureDomNode();
ins.childNodeInserted(this.nodeId, index, childView.domNode);

View File

@@ -208,7 +208,7 @@ export namespace NetworkAgent {
}
function mimeTypeToType(mimeType: string): string {
let type: string = 'Document';
let type = 'Document';
if (mimeType) {
if (mimeType.indexOf('image') === 0) {

View File

@@ -1,4 +1,5 @@
import * as inspectorCommandTypes from './InspectorBackendCommands.ios';
// eslint-disable-next-line @typescript-eslint/no-var-requires
const inspectorCommands: typeof inspectorCommandTypes = require('./InspectorBackendCommands');
import * as debuggerDomains from '.';

View File

@@ -1,4 +1,5 @@
import * as inspectorCommandTypes from './InspectorBackendCommands.ios';
// eslint-disable-next-line @typescript-eslint/no-var-requires
const inspectorCommands: typeof inspectorCommandTypes = require('./InspectorBackendCommands');
import * as debuggerDomains from '.';

View File

@@ -1,11 +1,12 @@
import * as inspectorCommandTypes from './InspectorBackendCommands.ios';
// eslint-disable-next-line @typescript-eslint/no-var-requires
const inspectorCommands: typeof inspectorCommandTypes = require('./InspectorBackendCommands');
import * as debuggerDomains from '.';
declare var __inspectorSendEvent;
declare let __inspectorSendEvent;
declare var __inspectorTimestamp;
declare let __inspectorTimestamp;
const frameId = 'NativeScriptMainFrameIdentifier';
const loaderId = 'Loader Identifier';
@@ -222,11 +223,11 @@ export class NetworkDomainDebugger implements inspectorCommandTypes.NetworkDomai
* Loads a resource in the context of a frame on the inspected page without cross origin checks.
*/
loadResource(params: inspectorCommandTypes.NetworkDomain.LoadResourceMethodArguments): { content: string; mimeType: string; status: number } {
let appPath = NSBundle.mainBundle.bundlePath;
let pathUrl = params.url.replace('file://', appPath);
let fileManager = NSFileManager.defaultManager;
let data = fileManager.fileExistsAtPath(pathUrl) ? fileManager.contentsAtPath(pathUrl) : undefined;
let content = data ? NSString.alloc().initWithDataEncoding(data, NSUTF8StringEncoding) : '';
const appPath = NSBundle.mainBundle.bundlePath;
const pathUrl = params.url.replace('file://', appPath);
const fileManager = NSFileManager.defaultManager;
const data = fileManager.fileExistsAtPath(pathUrl) ? fileManager.contentsAtPath(pathUrl) : undefined;
const content = data ? NSString.alloc().initWithDataEncoding(data, NSUTF8StringEncoding) : '';
return {
content: content.toString(), // Not sure why however we need to call toString() for NSString
@@ -235,10 +236,10 @@ export class NetworkDomainDebugger implements inspectorCommandTypes.NetworkDomai
};
}
public static idSequence: number = 0;
public static idSequence = 0;
create(): Request {
let id = (++NetworkDomainDebugger.idSequence).toString();
let resourceData = new Request(this, id);
const id = (++NetworkDomainDebugger.idSequence).toString();
const resourceData = new Request(this, id);
resources_datas[id] = resourceData;
return resourceData;