diff --git a/package.json b/package.json index ebfee8c979..fd6d092f87 100644 --- a/package.json +++ b/package.json @@ -80,7 +80,7 @@ "rimraf": "^2.5.2", "shelljs": "^0.7.7", "sinon": "^5.0.7", - "tslint": "^5.1.0", + "tslint": "^5.11.0", "typedoc": "^0.11.1", "typescript": "2.9.2", "webpack": "^3.10.0" diff --git a/src/export/packer/buffer-stream.ts b/src/export/packer/buffer-stream.ts index d1b9b0daa1..e0d2f8ed73 100644 --- a/src/export/packer/buffer-stream.ts +++ b/src/export/packer/buffer-stream.ts @@ -1,7 +1,7 @@ import { Writable } from "stream"; export class BufferStream extends Writable { - private data: Buffer[]; + private readonly data: Buffer[]; constructor() { super(); @@ -10,7 +10,7 @@ export class BufferStream extends Writable { } // tslint:disable-next-line:no-any - public _write(chunk: any, encoding: string, next: (err?: Error) => void): void { + public _write(chunk: any, _: string, next: (err?: Error) => void): void { this.data.push(Buffer.from(chunk)); next(); } diff --git a/src/export/packer/compiler.ts b/src/export/packer/compiler.ts index 5cfd8ca17c..a845833a34 100644 --- a/src/export/packer/compiler.ts +++ b/src/export/packer/compiler.ts @@ -8,9 +8,9 @@ import { Formatter } from "../formatter"; export class Compiler { protected archive: archiver.Archiver; - private formatter: Formatter; + private readonly formatter: Formatter; - constructor(private file: File) { + constructor(private readonly file: File) { this.formatter = new Formatter(); this.archive = archiver.create("zip", {}); diff --git a/src/file/document/body/body.ts b/src/file/document/body/body.ts index 5acc9f9c2b..4ec5156bfc 100644 --- a/src/file/document/body/body.ts +++ b/src/file/document/body/body.ts @@ -3,9 +3,9 @@ import { Paragraph, ParagraphProperties } from "../.."; import { SectionProperties, SectionPropertiesOptions } from "./section-properties"; export class Body extends XmlComponent { - private defaultSection: SectionProperties; + private readonly defaultSection: SectionProperties; - private sections: SectionProperties[] = []; + private readonly sections: SectionProperties[] = []; constructor(sectionPropertiesOptions?: SectionPropertiesOptions) { super("w:body"); diff --git a/src/file/document/body/section-properties/section-properties.ts b/src/file/document/body/section-properties/section-properties.ts index c1a666b8ed..4cb6d12b99 100644 --- a/src/file/document/body/section-properties/section-properties.ts +++ b/src/file/document/body/section-properties/section-properties.ts @@ -23,7 +23,8 @@ export type SectionPropertiesOptions = IPageSizeAttributes & IPageNumberTypeAttributes; export class SectionProperties extends XmlComponent { - private options: SectionPropertiesOptions; + private readonly options: SectionPropertiesOptions; + constructor(options?: SectionPropertiesOptions) { super("w:sectPr"); diff --git a/src/file/drawing/drawing.ts b/src/file/drawing/drawing.ts index 4c3db93b3a..d45a6ad3bb 100644 --- a/src/file/drawing/drawing.ts +++ b/src/file/drawing/drawing.ts @@ -28,7 +28,7 @@ const defaultDrawingOptions: IDrawingOptions = { }; export class Drawing extends XmlComponent { - private inline: Inline; + private readonly inline: Inline; constructor(imageData: IMediaData, drawingOptions?: IDrawingOptions) { super("w:drawing"); diff --git a/src/file/drawing/extent/extent.ts b/src/file/drawing/extent/extent.ts index 0e22348cf1..270a85a8a8 100644 --- a/src/file/drawing/extent/extent.ts +++ b/src/file/drawing/extent/extent.ts @@ -2,7 +2,7 @@ import { XmlComponent } from "file/xml-components"; import { ExtentAttributes } from "./extent-attributes"; export class Extent extends XmlComponent { - private attributes: ExtentAttributes; + private readonly attributes: ExtentAttributes; constructor(x: number, y: number) { super("wp:extent"); diff --git a/src/file/drawing/inline/graphic/graphic-data/graphic-data.ts b/src/file/drawing/inline/graphic/graphic-data/graphic-data.ts index ca3d4600be..78606fd399 100644 --- a/src/file/drawing/inline/graphic/graphic-data/graphic-data.ts +++ b/src/file/drawing/inline/graphic/graphic-data/graphic-data.ts @@ -3,7 +3,7 @@ import { GraphicDataAttributes } from "./graphic-data-attribute"; import { Pic } from "./pic"; export class GraphicData extends XmlComponent { - private pic: Pic; + private readonly pic: Pic; constructor(referenceId: number, x: number, y: number) { super("a:graphicData"); diff --git a/src/file/drawing/inline/graphic/graphic-data/pic/pic.ts b/src/file/drawing/inline/graphic/graphic-data/pic/pic.ts index f8b555af00..14ccf63f02 100644 --- a/src/file/drawing/inline/graphic/graphic-data/pic/pic.ts +++ b/src/file/drawing/inline/graphic/graphic-data/pic/pic.ts @@ -6,7 +6,7 @@ import { PicAttributes } from "./pic-attributes"; import { ShapeProperties } from "./shape-properties/shape-properties"; export class Pic extends XmlComponent { - private shapeProperties: ShapeProperties; + private readonly shapeProperties: ShapeProperties; constructor(referenceId: number, x: number, y: number) { super("pic:pic"); diff --git a/src/file/drawing/inline/graphic/graphic-data/pic/shape-properties/form/extents/extents.ts b/src/file/drawing/inline/graphic/graphic-data/pic/shape-properties/form/extents/extents.ts index 74aea18a48..55bf8bae0b 100644 --- a/src/file/drawing/inline/graphic/graphic-data/pic/shape-properties/form/extents/extents.ts +++ b/src/file/drawing/inline/graphic/graphic-data/pic/shape-properties/form/extents/extents.ts @@ -3,7 +3,7 @@ import { XmlComponent } from "file/xml-components"; import { ExtentsAttributes } from "./extents-attributes"; export class Extents extends XmlComponent { - private attributes: ExtentsAttributes; + private readonly attributes: ExtentsAttributes; constructor(x: number, y: number) { super("a:ext"); diff --git a/src/file/drawing/inline/graphic/graphic-data/pic/shape-properties/form/form.ts b/src/file/drawing/inline/graphic/graphic-data/pic/shape-properties/form/form.ts index 06523e0965..48c069f644 100644 --- a/src/file/drawing/inline/graphic/graphic-data/pic/shape-properties/form/form.ts +++ b/src/file/drawing/inline/graphic/graphic-data/pic/shape-properties/form/form.ts @@ -4,7 +4,7 @@ import { Extents } from "./extents/extents"; import { Offset } from "./offset/off"; export class Form extends XmlComponent { - private extents: Extents; + private readonly extents: Extents; constructor(x: number, y: number) { super("a:xfrm"); diff --git a/src/file/drawing/inline/graphic/graphic-data/pic/shape-properties/shape-properties.ts b/src/file/drawing/inline/graphic/graphic-data/pic/shape-properties/shape-properties.ts index 9c910f62e2..9dacae18d6 100644 --- a/src/file/drawing/inline/graphic/graphic-data/pic/shape-properties/shape-properties.ts +++ b/src/file/drawing/inline/graphic/graphic-data/pic/shape-properties/shape-properties.ts @@ -7,7 +7,7 @@ import { PresetGeometry } from "./preset-geometry/preset-geometry"; import { ShapePropertiesAttributes } from "./shape-properties-attributes"; export class ShapeProperties extends XmlComponent { - private form: Form; + private readonly form: Form; constructor(x: number, y: number) { super("pic:spPr"); diff --git a/src/file/drawing/inline/graphic/graphic.ts b/src/file/drawing/inline/graphic/graphic.ts index ce61893e05..dba653d2ca 100644 --- a/src/file/drawing/inline/graphic/graphic.ts +++ b/src/file/drawing/inline/graphic/graphic.ts @@ -12,7 +12,7 @@ class GraphicAttributes extends XmlAttributeComponent { } export class Graphic extends XmlComponent { - private data: GraphicData; + private readonly data: GraphicData; constructor(referenceId: number, x: number, y: number) { super("a:graphic"); diff --git a/src/file/drawing/inline/inline.ts b/src/file/drawing/inline/inline.ts index 6e5be2ba13..f36dd19cf3 100644 --- a/src/file/drawing/inline/inline.ts +++ b/src/file/drawing/inline/inline.ts @@ -9,10 +9,10 @@ import { Graphic } from "./../inline/graphic"; import { InlineAttributes } from "./inline-attributes"; export class Inline extends XmlComponent { - private extent: Extent; - private graphic: Graphic; + private readonly extent: Extent; + private readonly graphic: Graphic; - constructor(referenceId: number, private dimensions: IMediaDataDimensions) { + constructor(referenceId: number, private readonly dimensions: IMediaDataDimensions) { super("wp:inline"); this.root.push( diff --git a/src/file/footer/footer.ts b/src/file/footer/footer.ts index 745b71f0b5..532e662c25 100644 --- a/src/file/footer/footer.ts +++ b/src/file/footer/footer.ts @@ -5,7 +5,8 @@ import { Table } from "../table"; import { FooterAttributes } from "./footer-attributes"; export class Footer extends XmlComponent { - private refId: number; + private readonly refId: number; + constructor(referenceNumber: number) { super("w:ftr"); this.refId = referenceNumber; diff --git a/src/file/header/header.ts b/src/file/header/header.ts index 44ef386901..be1708658f 100644 --- a/src/file/header/header.ts +++ b/src/file/header/header.ts @@ -5,9 +5,11 @@ import { Table } from "../table"; import { HeaderAttributes } from "./header-attributes"; export class Header extends XmlComponent { - private refId: number; + private readonly refId: number; + constructor(referenceNumber: number) { super("w:hdr"); + this.refId = referenceNumber; this.root.push( new HeaderAttributes({ diff --git a/src/file/numbering/numbering.ts b/src/file/numbering/numbering.ts index 0a886e5598..a256500c45 100644 --- a/src/file/numbering/numbering.ts +++ b/src/file/numbering/numbering.ts @@ -7,8 +7,8 @@ import { Num } from "./num"; export class Numbering extends XmlComponent { private nextId: number; - private abstractNumbering: XmlComponent[] = []; - private concreteNumbering: XmlComponent[] = []; + private readonly abstractNumbering: XmlComponent[] = []; + private readonly concreteNumbering: XmlComponent[] = []; constructor() { super("w:numbering"); diff --git a/src/file/paragraph/paragraph.ts b/src/file/paragraph/paragraph.ts index 3695b70bd5..22e64fc643 100644 --- a/src/file/paragraph/paragraph.ts +++ b/src/file/paragraph/paragraph.ts @@ -19,7 +19,7 @@ import { ParagraphProperties } from "./properties"; import { PictureRun, Run, TextRun } from "./run"; export class Paragraph extends XmlComponent { - private properties: ParagraphProperties; + private readonly properties: ParagraphProperties; constructor(text?: string) { super("w:p"); diff --git a/src/file/paragraph/run/picture-run.ts b/src/file/paragraph/run/picture-run.ts index 6a07b3bd9e..d51d0fc8f9 100644 --- a/src/file/paragraph/run/picture-run.ts +++ b/src/file/paragraph/run/picture-run.ts @@ -4,7 +4,7 @@ import { IMediaData } from "../../media/data"; import { Run } from "../run"; export class PictureRun extends Run { - private drawing: Drawing; + private readonly drawing: Drawing; constructor(imageData: IMediaData, drawingOptions?: IDrawingOptions) { super(); diff --git a/src/file/table/table.ts b/src/file/table/table.ts index 01f00a4d65..d82da34ff2 100644 --- a/src/file/table/table.ts +++ b/src/file/table/table.ts @@ -144,7 +144,8 @@ export class TableCell extends XmlComponent { } export class TableCellProperties extends XmlComponent { - private cellBorder: TableCellBorders; + private readonly cellBorder: TableCellBorders; + constructor() { super("w:tcPr"); this.cellBorder = new TableCellBorders(); diff --git a/tsconfig.json b/tsconfig.json index 2d46f20143..cf7d8dd8be 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -10,6 +10,7 @@ "module": "commonjs", "declaration": true, "noUnusedLocals": true, + "noUnusedParameters": true, "baseUrl": "./src", "paths" : { "/*": [ diff --git a/tslint.json b/tslint.json index c61daf35dc..497035eccc 100644 --- a/tslint.json +++ b/tslint.json @@ -32,12 +32,10 @@ "max-classes-per-file": [ false ], - "no-unused-variable": [ - true - ], "no-implicit-dependencies": false, "no-submodule-imports": false, "no-null-keyword": true, - "return-undefined": true + "return-undefined": true, + "prefer-readonly": true } }