linting fixes

This commit is contained in:
Dolan
2017-03-08 21:49:41 +00:00
parent 279a5a93f1
commit 946a222d37
16 changed files with 67 additions and 66 deletions

View File

@ -8,4 +8,4 @@ export class DocumentGrid extends XmlComponent {
linePitch: "360", linePitch: "360",
})); }));
} }
} }

View File

@ -1,4 +1,4 @@
import {XmlComponent} from "../xml-components"; import { XmlComponent } from "../xml-components";
export class Strike extends XmlComponent { export class Strike extends XmlComponent {
@ -12,4 +12,4 @@ export class DoubleStrike extends XmlComponent {
constructor() { constructor() {
super("w:dstrike"); super("w:dstrike");
} }
} }

View File

@ -1,8 +1,8 @@
import {XmlComponent} from "../xml-components"; import { XmlComponent } from "../xml-components";
export class Tab extends XmlComponent { export class Tab extends XmlComponent {
constructor() { constructor() {
super("w:tab"); super("w:tab");
} }
} }

View File

@ -1,5 +1,5 @@
import {Text} from "./text"; import { Run } from "../run";
import {Run} from "../run"; import { Text } from "./text";
export class TextRun extends Run { export class TextRun extends Run {
@ -7,4 +7,4 @@ export class TextRun extends Run {
super(); super();
this.root.push(new Text(text)); this.root.push(new Text(text));
} }
} }

View File

@ -1,4 +1,4 @@
import {XmlUnitComponent} from "../xml-components" import { XmlUnitComponent } from "../xml-components";
export class Text extends XmlUnitComponent { export class Text extends XmlUnitComponent {
@ -6,4 +6,4 @@ export class Text extends XmlUnitComponent {
super("w:t"); super("w:t");
this.root = text; this.root = text;
} }
} }

View File

@ -6,7 +6,7 @@ abstract class BaseUnderline extends XmlComponent {
super("w:u"); super("w:u");
this.root.push(new Attributes({ this.root.push(new Attributes({
val: underlineType, val: underlineType,
color: color color: color,
})); }));
} }
} }
@ -88,7 +88,6 @@ export class DoubleUnderline extends BaseUnderline {
} }
} }
export class SingleUnderline extends BaseUnderline { export class SingleUnderline extends BaseUnderline {
constructor() { constructor() {
@ -129,4 +128,4 @@ export class WordsUnderline extends BaseUnderline {
constructor() { constructor() {
super("words"); super("words");
} }
} }

View File

@ -1,7 +1,7 @@
import {XmlAttributeComponent} from "./default-attributes"; import { XmlAttributeComponent } from "./default-attributes";
interface AttributesProperties { interface IAttributesProperties {
val?: any; val?: string | number | boolean;
color?: string; color?: string;
space?: string; space?: string;
sz?: string; sz?: string;
@ -24,7 +24,7 @@ interface AttributesProperties {
export class Attributes extends XmlAttributeComponent { export class Attributes extends XmlAttributeComponent {
constructor(properties?: AttributesProperties) { constructor(properties?: IAttributesProperties) {
super({ super({
val: "w:val", val: "w:val",
color: "w:color", color: "w:color",
@ -44,7 +44,7 @@ export class Attributes extends XmlAttributeComponent {
footer: "w:footer", footer: "w:footer",
gutter: "w:gutter", gutter: "w:gutter",
linePitch: "w:linePitch", linePitch: "w:linePitch",
pos: "w:pos" pos: "w:pos",
}, properties); }, properties);
} }
} }

View File

@ -5,7 +5,9 @@ export abstract class BaseXmlComponent {
this.rootKey = rootKey; this.rootKey = rootKey;
} }
abstract replaceKey(): void; public abstract replaceKey(): void;
clearVariables(): void {
public clearVariables(): void {
// Do Nothing
} }
} }

View File

@ -1,5 +1,5 @@
import {BaseXmlComponent} from "./base";
import * as _ from "lodash"; import * as _ from "lodash";
import { BaseXmlComponent } from "./base";
export abstract class XmlAttributeComponent extends BaseXmlComponent { export abstract class XmlAttributeComponent extends BaseXmlComponent {
protected root: Object; protected root: Object;
@ -16,10 +16,10 @@ export abstract class XmlAttributeComponent extends BaseXmlComponent {
} }
} }
replaceKey(): void { public replaceKey(): void {
if (this.root !== undefined) { if (this.root !== undefined) {
_.forOwn(this.root, (value, key) => { _.forOwn(this.root, (value, key) => {
let newKey = this.xmlKeys[key]; const newKey = this.xmlKeys[key];
this.root[newKey] = value; this.root[newKey] = value;
delete this.root[key]; delete this.root[key];
}); });
@ -27,4 +27,4 @@ export abstract class XmlAttributeComponent extends BaseXmlComponent {
delete this.root; delete this.root;
} }
} }
} }

View File

@ -1,19 +1,19 @@
import * as _ from "lodash"; import * as _ from "lodash";
import {BaseXmlComponent} from "./base"; import { BaseXmlComponent } from "./base";
export abstract class XmlComponent extends BaseXmlComponent { export abstract class XmlComponent extends BaseXmlComponent {
protected root: Array<BaseXmlComponent>; protected root: BaseXmlComponent[];
constructor(rootKey: string) { constructor(rootKey: string) {
super(rootKey); super(rootKey);
this.root = new Array<BaseXmlComponent>(); this.root = new Array<BaseXmlComponent>();
} }
replaceKey(): void { public replaceKey(): void {
// console.log(this.rootKey); // console.log(this.rootKey);
// console.log(this.root); // console.log(this.root);
if (this.root !== undefined) { if (this.root !== undefined) {
this.root.forEach(root => { this.root.forEach((root) => {
if (root && root instanceof BaseXmlComponent) { if (root && root instanceof BaseXmlComponent) {
root.replaceKey(); root.replaceKey();
} }
@ -27,4 +27,4 @@ export abstract class XmlComponent extends BaseXmlComponent {
export * from "./attributes" export * from "./attributes"
export * from "./default-attributes"; export * from "./default-attributes";
export * from "./unit"; export * from "./unit";
export * from "./property"; export * from "./property";

View File

@ -1,17 +1,17 @@
import {XmlComponent} from "./"; import { ParagraphProperties } from "../paragraph/properties";
import {ParagraphProperties} from "../paragraph/properties"; import { RunProperties } from "../run/properties";
import {RunProperties} from "../run/properties"; import { XmlComponent } from "./";
export class ParagraphPropertyXmlComponent extends XmlComponent { export class ParagraphPropertyXmlComponent extends XmlComponent {
private paragraphProperties: ParagraphProperties; private paragraphProperties: ParagraphProperties;
constructor(rootKey) { constructor(rootKey: string) {
super(rootKey); super(rootKey);
this.paragraphProperties = new ParagraphProperties(); this.paragraphProperties = new ParagraphProperties();
this.root.push(this.paragraphProperties); this.root.push(this.paragraphProperties);
} }
clearVariables(): void { public clearVariables(): void {
this.paragraphProperties.clearVariables(); this.paragraphProperties.clearVariables();
delete this.paragraphProperties; delete this.paragraphProperties;
@ -21,13 +21,13 @@ export class ParagraphPropertyXmlComponent extends XmlComponent {
export class RunPropertyXmlComponent extends XmlComponent { export class RunPropertyXmlComponent extends XmlComponent {
private runProperties: RunProperties; private runProperties: RunProperties;
constructor(rootKey) { constructor(rootKey: string) {
super(rootKey); super(rootKey);
this.runProperties = new RunProperties(); this.runProperties = new RunProperties();
this.root.push(this.runProperties); this.root.push(this.runProperties);
} }
clearVariables(): void { public clearVariables(): void {
this.runProperties.clearVariables(); this.runProperties.clearVariables();
delete this.runProperties; delete this.runProperties;
@ -38,7 +38,7 @@ export class MultiPropertyXmlComponent extends XmlComponent {
private runProperties: RunProperties; private runProperties: RunProperties;
private paragraphProperties: ParagraphProperties; private paragraphProperties: ParagraphProperties;
constructor(rootKey) { constructor(rootKey: string) {
super(rootKey); super(rootKey);
this.runProperties = new RunProperties(); this.runProperties = new RunProperties();
this.root.push(this.runProperties); this.root.push(this.runProperties);
@ -47,11 +47,11 @@ export class MultiPropertyXmlComponent extends XmlComponent {
this.root.push(this.paragraphProperties); this.root.push(this.paragraphProperties);
} }
clearVariables(): void { public clearVariables(): void {
this.runProperties.clearVariables(); this.runProperties.clearVariables();
this.paragraphProperties.clearVariables(); this.paragraphProperties.clearVariables();
delete this.runProperties; delete this.runProperties;
delete this.paragraphProperties; delete this.paragraphProperties;
} }
} }

View File

@ -7,10 +7,10 @@ export abstract class XmlUnitComponent extends BaseXmlComponent {
super(rootKey); super(rootKey);
} }
replaceKey(): void { public replaceKey(): void {
if (this.root !== undefined) { if (this.root !== undefined) {
this[this.rootKey] = this.root; this[this.rootKey] = this.root;
delete this.root; delete this.root;
} }
} }
} }

View File

@ -1,4 +1,4 @@
import {XmlAttributeComponent, XmlComponent} from "../docx/xml-components"; import { XmlAttributeComponent, XmlComponent } from "../docx/xml-components";
interface IndentAttributesProperties { interface IndentAttributesProperties {
left: number; left: number;

View File

@ -1,4 +1,4 @@
import {Attributes, XmlComponent} from "../docx/xml-components"; import { Attributes, XmlComponent } from "../docx/xml-components";
export class MultiLevelType extends XmlComponent { export class MultiLevelType extends XmlComponent {

View File

@ -1,6 +1,6 @@
import {XmlUnitComponent} from "../docx/xml-components"; import { DocumentAttributes } from "../docx/document/document-attributes";
import {XmlComponent} from "../docx/xml-components"; import { XmlUnitComponent } from "../docx/xml-components";
import {DocumentAttributes} from "../docx/document/document-attributes"; import { XmlComponent } from "../docx/xml-components";
export class Title extends XmlUnitComponent { export class Title extends XmlUnitComponent {
@ -54,20 +54,20 @@ export class Revision extends XmlUnitComponent {
constructor(value: string) { constructor(value: string) {
super("cp:revision"); super("cp:revision");
let revision = value; const revision = value;
this.root = value; this.root = value;
} }
} }
abstract class DateComponent extends XmlComponent { abstract class DateComponent extends XmlComponent {
protected getCurrentDate(): any { protected getCurrentDate(): any {
let date = new Date(), const date = new Date();
year = date.getFullYear(), const year = date.getFullYear();
month = ("0" + (date.getMonth() + 1)).slice(-2), const month = ("0" + (date.getMonth() + 1)).slice(-2);
day = ("0" + date.getDate()).slice(-2), const day = ("0" + date.getDate()).slice(-2);
hours = ("0" + date.getHours()).slice(-2), const hours = ("0" + date.getHours()).slice(-2);
minutes = ("0" + date.getMinutes()).slice(-2), const minutes = ("0" + date.getMinutes()).slice(-2);
seconds = ("0" + date.getSeconds()).slice(-2); const seconds = ("0" + date.getSeconds()).slice(-2);
return year + "-" + month + "-" + day + "T" + hours + ":" + minutes + ":" + seconds + "Z"; return year + "-" + month + "-" + day + "T" + hours + ":" + minutes + ":" + seconds + "Z";
} }
@ -78,7 +78,7 @@ export class Created extends DateComponent {
constructor() { constructor() {
super("dcterms:created"); super("dcterms:created");
this.root.push(new DocumentAttributes({ this.root.push(new DocumentAttributes({
type: "dcterms:W3CDTF" type: "dcterms:W3CDTF",
})); }));
this.root.push(this.getCurrentDate()); this.root.push(this.getCurrentDate());
} }
@ -89,8 +89,8 @@ export class Modified extends DateComponent {
constructor() { constructor() {
super("dcterms:modified"); super("dcterms:modified");
this.root.push(new DocumentAttributes({ this.root.push(new DocumentAttributes({
type: "dcterms:W3CDTF" type: "dcterms:W3CDTF",
})); }));
this.root.push(this.getCurrentDate()); this.root.push(this.getCurrentDate());
} }
} }

View File

@ -1,8 +1,8 @@
import {XmlComponent} from "../docx/xml-components"; import { DocumentAttributes } from "../docx/document/document-attributes";
import {DocumentAttributes} from "../docx/document/document-attributes"; import { XmlComponent } from "../docx/xml-components";
import {Title, Subject, Creator, Keywords, Description, LastModifiedBy, Revision, Created, Modified} from "./components"; import { Created, Creator, Description, Keywords, LastModifiedBy, Modified, Revision, Subject, Title } from "./components";
interface PropertiesOptions { interface IPropertiesOptions {
title?: string; title?: string;
subject?: string; subject?: string;
creator?: string; creator?: string;
@ -14,14 +14,14 @@ interface PropertiesOptions {
export class Properties extends XmlComponent { export class Properties extends XmlComponent {
constructor(options: PropertiesOptions) { constructor(options: IPropertiesOptions) {
super("cp:coreProperties"); super("cp:coreProperties");
this.root.push(new DocumentAttributes({ this.root.push(new DocumentAttributes({
cp: "http://schemas.openxmlformats.org/package/2006/metadata/core-properties", cp: "http://schemas.openxmlformats.org/package/2006/metadata/core-properties",
dc: "http://purl.org/dc/elements/1.1/", dc: "http://purl.org/dc/elements/1.1/",
dcterms: "http://purl.org/dc/terms/", dcterms: "http://purl.org/dc/terms/",
dcmitype: "http://purl.org/dc/dcmitype/", dcmitype: "http://purl.org/dc/dcmitype/",
xsi: "http://www.w3.org/2001/XMLSchema-instance" xsi: "http://www.w3.org/2001/XMLSchema-instance",
})); }));
this.root.push(new Title(options.title)); this.root.push(new Title(options.title));
this.root.push(new Subject(options.subject)); this.root.push(new Subject(options.subject));
@ -33,4 +33,4 @@ export class Properties extends XmlComponent {
this.root.push(new Created()); this.root.push(new Created());
this.root.push(new Modified()); this.root.push(new Modified());
} }
} }