Use new eslint-plugin-functional instead of tslint-immutable
This commit is contained in:
@ -1,11 +1,11 @@
|
||||
import { BaseXmlComponent, IContext } from "./base";
|
||||
import { IXmlableObject } from "./xmlable-object";
|
||||
|
||||
export type AttributeMap<T> = { [P in keyof T]: string };
|
||||
export type AttributeMap<T> = { readonly [P in keyof T]: string };
|
||||
|
||||
export abstract class XmlAttributeComponent<T> extends BaseXmlComponent {
|
||||
export abstract class XmlAttributeComponent<T extends object> extends BaseXmlComponent {
|
||||
// tslint:disable-next-line:readonly-keyword
|
||||
protected root: T;
|
||||
protected readonly root: T;
|
||||
protected readonly xmlKeys?: AttributeMap<T>;
|
||||
|
||||
public constructor(properties: T) {
|
||||
@ -19,6 +19,7 @@ export abstract class XmlAttributeComponent<T> extends BaseXmlComponent {
|
||||
const value = this.root[key];
|
||||
if (value !== undefined) {
|
||||
const newKey = (this.xmlKeys && this.xmlKeys[key]) || key;
|
||||
// eslint-disable-next-line functional/immutable-data
|
||||
attrs[newKey] = value;
|
||||
}
|
||||
});
|
||||
|
@ -1,4 +1,4 @@
|
||||
// tslint:disable:no-any
|
||||
// eslint-disable @typescript-eslint/no-explicit-any
|
||||
import { Element as XmlElement, xml2js } from "xml-js";
|
||||
|
||||
import { IXmlableObject, XmlAttributeComponent, XmlComponent } from "@file/xml-components";
|
||||
@ -7,6 +7,7 @@ import { IContext } from "./base";
|
||||
|
||||
/**
|
||||
* Converts the given xml element (in json format) into XmlComponent.
|
||||
*
|
||||
* @param element the xml element in json presentation
|
||||
*/
|
||||
|
||||
|
@ -4,7 +4,7 @@ import { IXmlableObject } from "./xmlable-object";
|
||||
export const EMPTY_OBJECT = Object.seal({});
|
||||
|
||||
export abstract class XmlComponent extends BaseXmlComponent {
|
||||
// tslint:disable-next-line:readonly-keyword no-any
|
||||
// eslint-disable-next-line functional/prefer-readonly-type, @typescript-eslint/no-explicit-any
|
||||
protected root: (BaseXmlComponent | string | any)[];
|
||||
|
||||
public constructor(rootKey: string) {
|
||||
@ -46,5 +46,7 @@ export abstract class IgnoreIfEmptyXmlComponent extends XmlComponent {
|
||||
if (result && (typeof result[this.rootKey] !== "object" || Object.keys(result[this.rootKey]).length)) {
|
||||
return result;
|
||||
}
|
||||
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user