ts/styles linter warnings

This commit is contained in:
felipe
2017-03-09 09:45:01 +01:00
parent 2684f16579
commit f5144e6d72
12 changed files with 91 additions and 89 deletions

View File

@ -1,6 +1,6 @@
import {XmlComponent} from "../../docx/xml-components";
import {ParagraphPropertiesDefaults} from "./paragraph-properties";
import {RunPropertiesDefaults} from "./run-properties";
import { XmlComponent } from "../../docx/xml-components";
import { ParagraphPropertiesDefaults } from "./paragraph-properties";
import { RunPropertiesDefaults } from "./run-properties";
export class DocumentDefaults extends XmlComponent {
@ -15,7 +15,7 @@ export class DocumentDefaults extends XmlComponent {
this.root.push(this.paragraphPropertiesDefaults);
}
clearVariables(): void {
public clearVariables(): void {
this.runPropertiesDefaults.clearVariables();
this.paragraphPropertiesDefaults.clearVariables();
delete this.runPropertiesDefaults;

View File

@ -1,5 +1,5 @@
import {XmlComponent} from "../../docx/xml-components";
import {ParagraphProperties} from "../../docx/paragraph/properties";
import { ParagraphProperties } from "../../docx/paragraph/properties";
import { XmlComponent } from "../../docx/xml-components";
export class ParagraphPropertiesDefaults extends XmlComponent {

View File

@ -1,5 +1,5 @@
import {XmlComponent} from "../../docx/xml-components";
import {RunProperties} from "../../docx/run/properties";
import { RunProperties } from "../../docx/run/properties";
import { XmlComponent } from "../../docx/xml-components";
export class RunPropertiesDefaults extends XmlComponent {

View File

@ -1,52 +1,56 @@
import {Styles} from "./";
import {DocumentDefaults} from "./defaults";
import {ParagraphPropertiesDefaults} from "./defaults/paragraph-properties";
import {RunPropertiesDefaults} from "./defaults/run-properties";
import {Heading1Style, Heading2Style, TitleStyle, Heading3Style, Heading4Style, Heading5Style, Heading6Style, ListParagraph} from "./style";
// import {StyleAttributes} from "./style/attributes";
import {ParagraphProperties} from "../docx/paragraph/properties";
import {RunProperties} from "../docx/run/properties";
import {Color, Size, Italics} from "../docx/run/formatting";
import { ParagraphProperties } from "../docx/paragraph/properties";
import { Color, Italics, Size } from "../docx/run/formatting";
import { RunProperties } from "../docx/run/properties";
import { Styles } from "./";
import { DocumentDefaults } from "./defaults";
import { ParagraphPropertiesDefaults } from "./defaults/paragraph-properties";
import { RunPropertiesDefaults } from "./defaults/run-properties";
import {
Heading1Style, Heading2Style, Heading3Style, Heading4Style, Heading5Style, Heading6Style,
ListParagraph, TitleStyle,
} from "./style";
// import { StyleAttributes } from "./style/attributes";
export class DefaultStylesFactory {
newInstance(): Styles {
let styles = new Styles();
public newInstance(): Styles {
const styles = new Styles();
styles.push(new DocumentDefaults());
let titleStyle = new TitleStyle();
const titleStyle = new TitleStyle();
titleStyle.addRunProperty(new Size(56));
styles.push(titleStyle);
let heading1Style = new Heading1Style();
const heading1Style = new Heading1Style();
heading1Style.addRunProperty(new Color("2E74B5"));
heading1Style.addRunProperty(new Size(32));
styles.push(heading1Style);
let heading2Style = new Heading2Style();
const heading2Style = new Heading2Style();
heading2Style.addRunProperty(new Color("2E74B5"));
heading2Style.addRunProperty(new Size(26));
styles.push(heading2Style);
let heading3Style = new Heading3Style();
const heading3Style = new Heading3Style();
heading3Style.addRunProperty(new Color("1F4D78"));
heading3Style.addRunProperty(new Size(24));
styles.push(heading3Style);
let heading4Style = new Heading4Style();
const heading4Style = new Heading4Style();
heading4Style.addRunProperty(new Color("2E74B5"));
heading4Style.addRunProperty(new Italics());
styles.push(heading4Style);
let heading5Style = new Heading5Style();
const heading5Style = new Heading5Style();
heading5Style.addRunProperty(new Color("2E74B5"));
styles.push(heading5Style);
let heading6Style = new Heading6Style();
const heading6Style = new Heading6Style();
heading6Style.addRunProperty(new Color("1F4D78"));
styles.push(heading6Style);
let listParagraph = new ListParagraph();
const listParagraph = new ListParagraph();
// listParagraph.addParagraphProperty();
styles.push(listParagraph);

View File

@ -1,9 +1,9 @@
import {XmlComponent} from "../docx/xml-components";
import {DocumentAttributes} from "../docx/document/document-attributes";
import {DocumentDefaults} from "./defaults";
import {LatentStyles} from "./latent-styles";
import {LatentStyleException} from "./latent-styles/exceptions";
import {LatentStyleExceptionAttributes} from "./latent-styles/exceptions/attributes";
import { DocumentAttributes } from "../docx/document/document-attributes";
import { XmlComponent } from "../docx/xml-components";
import { DocumentDefaults } from "./defaults";
import { LatentStyles } from "./latent-styles";
import { LatentStyleException } from "./latent-styles/exceptions";
import { LatentStyleExceptionAttributes } from "./latent-styles/exceptions/attributes";
export class Styles extends XmlComponent {
@ -15,7 +15,7 @@ export class Styles extends XmlComponent {
w: "http://schemas.openxmlformats.org/wordprocessingml/2006/main",
w14: "http://schemas.microsoft.com/office/word/2010/wordml",
w15: "http://schemas.microsoft.com/office/word/2012/wordml",
Ignorable: "w14 w15"
Ignorable: "w14 w15",
}));
// let latentStyles = new LatentStyles();
// latentStyles.push(new LatentStyleException(new LatentStyleExceptionAttributes({
@ -24,12 +24,13 @@ export class Styles extends XmlComponent {
// this.root.push(latentStyles);
}
push(style: XmlComponent): void {
public push(style: XmlComponent): Styles {
this.root.push(style);
return this;
}
clearVariables() {
this.root.forEach(element => {
public clearVariables(): void {
this.root.forEach((element) => {
element.clearVariables();
});
}

View File

@ -1,6 +1,6 @@
import {XmlComponent} from "../../../docx/xml-components";
interface LatentStyleExceptionAttributesProperties {
interface ILatentStyleExceptionAttributesProperties {
name?: string;
uiPriority?: string;
qFormat?: string;
@ -9,23 +9,23 @@ interface LatentStyleExceptionAttributesProperties {
}
export class LatentStyleExceptionAttributes extends XmlComponent {
private _attr: Object;
private _attr: ILatentStyleExceptionAttributesProperties;
xmlKeys = {
private xmlKeys = {
name: "w:name",
uiPriority: "w:uiPriority",
qFormat: "w:qFormat",
semiHidden: "w:semiHidden",
unhideWhenUsed: "w:unhideWhenUsed"
unhideWhenUsed: "w:unhideWhenUsed",
};
constructor(properties?: LatentStyleExceptionAttributesProperties) {
constructor(properties?: ILatentStyleExceptionAttributesProperties) {
super("_attr");
this._attr = properties;
if (!properties) {
this._attr = {};
}
this._attr["xmlKeys"] = this.xmlKeys;
//this._attr.xmlKeys = this.xmlKeys;
}
}

View File

@ -1,5 +1,5 @@
import {XmlComponent} from "../../../docx/xml-components";
import {LatentStyleExceptionAttributes} from "./attributes";
import { XmlComponent } from "../../../docx/xml-components";
import { LatentStyleExceptionAttributes } from "./attributes";
export class LatentStyleException extends XmlComponent {

View File

@ -1,5 +1,5 @@
import {XmlComponent} from "../../docx/xml-components";
import {LatentStyleException} from "./exceptions";
import { XmlComponent } from "../../docx/xml-components";
import { LatentStyleException } from "./exceptions";
export class LatentStyles extends XmlComponent {
@ -7,7 +7,7 @@ export class LatentStyles extends XmlComponent {
super("w:latentStyles");
}
push(latentException: LatentStyleException): void {
public push(latentException: LatentStyleException): void {
this.root.push(latentException);
}
}

View File

@ -1,7 +1,6 @@
import {XmlComponent} from "../../docx/xml-components";
import {XmlAttributeComponent} from "../../docx/xml-components";
import { XmlAttributeComponent, XmlComponent } from "../../docx/xml-components";
interface StyleAttributesProperties {
interface IStyleAttributesProperties {
type?: string;
styleId?: string;
default?: string;
@ -10,15 +9,15 @@ interface StyleAttributesProperties {
}
export class StyleAttributes extends XmlAttributeComponent {
private _attr: Object;
private _attr: IStyleAttributesProperties;
constructor(properties: StyleAttributesProperties) {
constructor(properties: IStyleAttributesProperties) {
super({
type: "w:type",
styleId: "w:styleId",
default: "w:default",
customStyle: "w:customStyle",
val: "w:val"
val: "w:val",
}, properties);
}
}

View File

@ -1,12 +1,12 @@
import {XmlComponent} from "../../docx/xml-components";
import {StyleAttributes} from "./attributes";
import { XmlComponent } from "../../docx/xml-components";
import { StyleAttributes } from "./attributes";
export class Name extends XmlComponent {
constructor(value: string) {
super("w:name");
this.root.push(new StyleAttributes({
val: value
val: value,
}));
}
}
@ -16,7 +16,7 @@ export class BasedOn extends XmlComponent {
constructor(value: string) {
super("w:basedOn");
this.root.push(new StyleAttributes({
val: value
val: value,
}));
}
}
@ -27,7 +27,7 @@ export class Next extends XmlComponent {
super("w:next");
this.root.push(new StyleAttributes({
styleId: "1",
val: value
val: value,
}));
}
}
@ -37,7 +37,7 @@ export class Link extends XmlComponent {
constructor(value: string) {
super("w:link");
this.root.push(new StyleAttributes({
val: value
val: value,
}));
}
}
@ -47,7 +47,7 @@ export class UiPriority extends XmlComponent {
constructor(value: string) {
super("w:uiPriority");
this.root.push(new StyleAttributes({
val: value
val: value,
}));
}
}

View File

@ -1,8 +1,9 @@
import {XmlComponent} from "../../docx/xml-components";
import {StyleAttributes} from "./attributes";
import {ParagraphProperties} from "../../docx/paragraph/properties";
import {RunProperties} from "../../docx/run/properties";
import {Name, BasedOn, Next, QuickFormat} from "./components";
import { ParagraphProperties } from "../../docx/paragraph/properties";
import { RunProperties } from "../../docx/run/properties";
import { XmlComponent } from "../../docx/xml-components";
import { StyleAttributes } from "./attributes";
import { BasedOn, Name, Next, QuickFormat } from "./components";
export class Style extends XmlComponent {
@ -11,7 +12,7 @@ export class Style extends XmlComponent {
this.root.push(attributes);
}
push(styleSegment: XmlComponent): void {
public push(styleSegment: XmlComponent): void {
this.root.push(styleSegment);
}
}
@ -23,9 +24,9 @@ export class ParagraphStyle extends Style {
constructor(styleId: string) {
let attributes = new StyleAttributes({
const attributes = new StyleAttributes({
type: "paragraph",
styleId: styleId
styleId: styleId,
});
super(attributes);
this.paragraphProperties = new ParagraphProperties();
@ -34,18 +35,18 @@ export class ParagraphStyle extends Style {
this.root.push(this.runProperties);
}
clearVariables(): void {
public clearVariables(): void {
this.paragraphProperties.clearVariables();
this.runProperties.clearVariables();
delete this.paragraphProperties;
delete this.runProperties;
}
addParagraphProperty(property: XmlComponent): void {
public addParagraphProperty(property: XmlComponent): void {
this.paragraphProperties.push(property);
}
addRunProperty(property: XmlComponent): void {
public addRunProperty(property: XmlComponent): void {
this.runProperties.push(property);
}
}

View File

@ -1,5 +1,5 @@
import { Styles } from "../styles";
import { assert } from "chai";
import { Styles } from "../styles";
describe("Styles", () => {
let styles: Styles;
@ -11,10 +11,7 @@ describe("Styles", () => {
describe("#constructor()", () => {
it("should create styles with correct rootKey", () => {
let styles = new Styles();
let stringifiedJson = JSON.stringify(styles);
let newJson = JSON.parse(stringifiedJson);
const newJson = JSON.parse(JSON.stringify(styles));
assert.equal(newJson.rootKey, "w:styles");
});
});