diff --git a/.eslintrc.js b/.eslintrc.js index 5fee3a0e1f..f5fd89265a 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -106,6 +106,9 @@ module.exports = { FunctionExpression: { parameters: "first", }, + SwitchCase: 1, + flatTernaryExpressions: false, + ignoredNodes: [], }, ], "@typescript-eslint/naming-convention": [ @@ -113,9 +116,9 @@ module.exports = { { selector: ["objectLiteralProperty"], leadingUnderscore: "allow", - format: ["camelCase"], - custom: { - regex: "^w:.+", + format: ["camelCase", "PascalCase"], + filter: { + regex: "(^[a-z]+:.+)|_attr|[0-9]", match: false, }, }, @@ -204,7 +207,7 @@ module.exports = { "no-throw-literal": "error", "no-trailing-spaces": "error", "no-undef-init": "error", - "no-underscore-dangle": "error", + "no-underscore-dangle": ["error", { allow: ["_attr"] }], "no-unsafe-finally": "error", "no-unused-expressions": "off", "no-unused-labels": "error", @@ -252,13 +255,14 @@ module.exports = { }, }, ], + "@typescript-eslint/explicit-function-return-type": "off", }, overrides: [ { - // enable the rule specifically for TypeScript files files: ["*.spec.ts"], rules: { - "@typescript-eslint/explicit-function-return-type": "off", + "@typescript-eslint/no-unused-expressions": "off", + "@typescript-eslint/dot-notation": "off", }, }, ], diff --git a/.vscode/extensions.json b/.vscode/extensions.json index 8481f95630..e2bf1c49ff 100644 --- a/.vscode/extensions.json +++ b/.vscode/extensions.json @@ -1,5 +1,3 @@ { - "recommendations": [ - "streetsidesoftware.code-spell-checker" - ] + "recommendations": ["streetsidesoftware.code-spell-checker", "dbaeumer.vscode-eslint"] } diff --git a/package-lock.json b/package-lock.json index 9cb078bea5..fe80f66bca 100644 --- a/package-lock.json +++ b/package-lock.json @@ -57,8 +57,6 @@ "ts-node": "^10.2.1", "tsconfig-paths": "^4.0.0", "tsconfig-paths-webpack-plugin": "^4.0.0", - "tslint": "^6.1.3", - "tslint-immutable": "^6.0.1", "typedoc": "^0.23.2", "typescript": "4.7.4", "unzipper": "^0.10.11", @@ -2621,6 +2619,7 @@ "resolved": "https://registry.npmjs.org/builtin-modules/-/builtin-modules-1.1.1.tgz", "integrity": "sha1-Jw8HbFpywC9bZaR9+Uxf46J4iS8=", "dev": true, + "peer": true, "engines": { "node": ">=0.10.0" } @@ -3008,7 +3007,8 @@ "version": "2.15.1", "resolved": "https://registry.npmjs.org/commander/-/commander-2.15.1.tgz", "integrity": "sha512-VlfT9F3V0v+jr4yxPc5gg9s62/fIVWsd2Bk2iD435um1NlGMYdVCq+MjcXnhYq2icNOizHr1kK+5TI6H0Hy0ag==", - "dev": true + "dev": true, + "peer": true }, "node_modules/comment-json": { "version": "4.2.3", @@ -10340,11 +10340,11 @@ "dev": true }, "node_modules/tslint": { - "version": "6.1.3", - "resolved": "https://registry.npmjs.org/tslint/-/tslint-6.1.3.tgz", - "integrity": "sha512-IbR4nkT96EQOvKE2PW/djGz8iGNeJ4rF2mBfiYaR/nvUWYKJhLwimoJKgjIFEIDibBtOevj7BqCRL4oHeWWUCg==", - "deprecated": "TSLint has been deprecated in favor of ESLint. Please see https://github.com/palantir/tslint/issues/4534 for more information.", + "version": "5.20.1", + "resolved": "https://registry.npmjs.org/tslint/-/tslint-5.20.1.tgz", + "integrity": "sha512-EcMxhzCFt8k+/UP5r8waCf/lzmeSyVlqxqMEDQE7rWYiQky8KpIBz1JAoYXfROHrPZ1XXd43q8yQnULOLiBRQg==", "dev": true, + "peer": true, "dependencies": { "@babel/code-frame": "^7.0.0", "builtin-modules": "^1.1.1", @@ -10354,10 +10354,10 @@ "glob": "^7.1.1", "js-yaml": "^3.13.1", "minimatch": "^3.0.4", - "mkdirp": "^0.5.3", + "mkdirp": "^0.5.1", "resolve": "^1.3.2", "semver": "^5.3.0", - "tslib": "^1.13.0", + "tslib": "^1.8.0", "tsutils": "^2.29.0" }, "bin": { @@ -10367,20 +10367,7 @@ "node": ">=4.8.0" }, "peerDependencies": { - "typescript": ">=2.3.0-dev || >=2.4.0-dev || >=2.5.0-dev || >=2.6.0-dev || >=2.7.0-dev || >=2.8.0-dev || >=2.9.0-dev || >=3.0.0-dev || >= 3.1.0-dev || >= 3.2.0-dev || >= 4.0.0-dev" - } - }, - "node_modules/tslint-immutable": { - "version": "6.0.1", - "resolved": "https://registry.npmjs.org/tslint-immutable/-/tslint-immutable-6.0.1.tgz", - "integrity": "sha512-3GQ6HffN64gLmT/N1YzyVMqyf6uBjMvhNaevK8B0K01/QC0OU5AQZrH4TjMHo1IdG3JpqsZvuRy9IW1LA3zjwA==", - "dev": true, - "dependencies": { - "tsutils": "^2.28.0 || ^3.0.0" - }, - "peerDependencies": { - "tslint": "^5.8.0", - "typescript": "^2.8.0 || ^3.0.0" + "typescript": ">=2.3.0-dev || >=2.4.0-dev || >=2.5.0-dev || >=2.6.0-dev || >=2.7.0-dev || >=2.8.0-dev || >=2.9.0-dev || >=3.0.0-dev || >= 3.1.0-dev || >= 3.2.0-dev" } }, "node_modules/tslint/node_modules/diff": { @@ -10388,6 +10375,7 @@ "resolved": "https://registry.npmjs.org/diff/-/diff-4.0.2.tgz", "integrity": "sha512-58lmxKSA4BNyLz+HHMUzlOEpg09FV+ev6ZMe3vJihgdxzgcwZ8VoEEPmALCZG9LmqfVoNMMKpttIYTVG6uDY7A==", "dev": true, + "peer": true, "engines": { "node": ">=0.3.1" } @@ -10397,6 +10385,7 @@ "resolved": "https://registry.npmjs.org/glob/-/glob-7.2.0.tgz", "integrity": "sha512-lmLf6gtyrPq8tTjSmrO94wBeQbFR3HbLHbuyD69wuyQkImp2hWqMGB47OX65FBkPffO641IP9jWa1z4ivqG26Q==", "dev": true, + "peer": true, "dependencies": { "fs.realpath": "^1.0.0", "inflight": "^1.0.4", @@ -10412,23 +10401,12 @@ "url": "https://github.com/sponsors/isaacs" } }, - "node_modules/tslint/node_modules/mkdirp": { - "version": "0.5.5", - "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.5.tgz", - "integrity": "sha512-NKmAlESf6jMGym1++R0Ra7wvhV+wFW63FaSOFPwRahvea0gMUcGUhVeAg/0BC0wiv9ih5NYPB1Wn1UEI1/L+xQ==", - "dev": true, - "dependencies": { - "minimist": "^1.2.5" - }, - "bin": { - "mkdirp": "bin/cmd.js" - } - }, "node_modules/tsutils": { "version": "2.29.0", "resolved": "https://registry.npmjs.org/tsutils/-/tsutils-2.29.0.tgz", "integrity": "sha512-g5JVHCIJwzfISaXpXE1qvNalca5Jwob6FjI4AoPlqMusJ6ftFE7IkkFoMhVLRgK+4Kx3gkzb8UZK5t5yTTvEmA==", "dev": true, + "peer": true, "dependencies": { "tslib": "^1.8.1" }, @@ -13574,7 +13552,8 @@ "version": "1.1.1", "resolved": "https://registry.npmjs.org/builtin-modules/-/builtin-modules-1.1.1.tgz", "integrity": "sha1-Jw8HbFpywC9bZaR9+Uxf46J4iS8=", - "dev": true + "dev": true, + "peer": true }, "cacheable-request": { "version": "6.1.0", @@ -13869,7 +13848,8 @@ "version": "2.15.1", "resolved": "https://registry.npmjs.org/commander/-/commander-2.15.1.tgz", "integrity": "sha512-VlfT9F3V0v+jr4yxPc5gg9s62/fIVWsd2Bk2iD435um1NlGMYdVCq+MjcXnhYq2icNOizHr1kK+5TI6H0Hy0ag==", - "dev": true + "dev": true, + "peer": true }, "comment-json": { "version": "4.2.3", @@ -19413,10 +19393,11 @@ "dev": true }, "tslint": { - "version": "6.1.3", - "resolved": "https://registry.npmjs.org/tslint/-/tslint-6.1.3.tgz", - "integrity": "sha512-IbR4nkT96EQOvKE2PW/djGz8iGNeJ4rF2mBfiYaR/nvUWYKJhLwimoJKgjIFEIDibBtOevj7BqCRL4oHeWWUCg==", + "version": "5.20.1", + "resolved": "https://registry.npmjs.org/tslint/-/tslint-5.20.1.tgz", + "integrity": "sha512-EcMxhzCFt8k+/UP5r8waCf/lzmeSyVlqxqMEDQE7rWYiQky8KpIBz1JAoYXfROHrPZ1XXd43q8yQnULOLiBRQg==", "dev": true, + "peer": true, "requires": { "@babel/code-frame": "^7.0.0", "builtin-modules": "^1.1.1", @@ -19426,10 +19407,10 @@ "glob": "^7.1.1", "js-yaml": "^3.13.1", "minimatch": "^3.0.4", - "mkdirp": "^0.5.3", + "mkdirp": "^0.5.1", "resolve": "^1.3.2", "semver": "^5.3.0", - "tslib": "^1.13.0", + "tslib": "^1.8.0", "tsutils": "^2.29.0" }, "dependencies": { @@ -19437,13 +19418,15 @@ "version": "4.0.2", "resolved": "https://registry.npmjs.org/diff/-/diff-4.0.2.tgz", "integrity": "sha512-58lmxKSA4BNyLz+HHMUzlOEpg09FV+ev6ZMe3vJihgdxzgcwZ8VoEEPmALCZG9LmqfVoNMMKpttIYTVG6uDY7A==", - "dev": true + "dev": true, + "peer": true }, "glob": { "version": "7.2.0", "resolved": "https://registry.npmjs.org/glob/-/glob-7.2.0.tgz", "integrity": "sha512-lmLf6gtyrPq8tTjSmrO94wBeQbFR3HbLHbuyD69wuyQkImp2hWqMGB47OX65FBkPffO641IP9jWa1z4ivqG26Q==", "dev": true, + "peer": true, "requires": { "fs.realpath": "^1.0.0", "inflight": "^1.0.4", @@ -19452,32 +19435,15 @@ "once": "^1.3.0", "path-is-absolute": "^1.0.0" } - }, - "mkdirp": { - "version": "0.5.5", - "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.5.tgz", - "integrity": "sha512-NKmAlESf6jMGym1++R0Ra7wvhV+wFW63FaSOFPwRahvea0gMUcGUhVeAg/0BC0wiv9ih5NYPB1Wn1UEI1/L+xQ==", - "dev": true, - "requires": { - "minimist": "^1.2.5" - } } } }, - "tslint-immutable": { - "version": "6.0.1", - "resolved": "https://registry.npmjs.org/tslint-immutable/-/tslint-immutable-6.0.1.tgz", - "integrity": "sha512-3GQ6HffN64gLmT/N1YzyVMqyf6uBjMvhNaevK8B0K01/QC0OU5AQZrH4TjMHo1IdG3JpqsZvuRy9IW1LA3zjwA==", - "dev": true, - "requires": { - "tsutils": "^2.28.0 || ^3.0.0" - } - }, "tsutils": { "version": "2.29.0", "resolved": "https://registry.npmjs.org/tsutils/-/tsutils-2.29.0.tgz", "integrity": "sha512-g5JVHCIJwzfISaXpXE1qvNalca5Jwob6FjI4AoPlqMusJ6ftFE7IkkFoMhVLRgK+4Kx3gkzb8UZK5t5yTTvEmA==", "dev": true, + "peer": true, "requires": { "tslib": "^1.8.1" } diff --git a/package.json b/package.json index a4e785557e..93a82233ce 100644 --- a/package.json +++ b/package.json @@ -9,7 +9,7 @@ "test.coverage": "nyc npm test", "test.watch": "npm test -- --watch", "prepublishOnly": "npm run build --production", - "lint": "eslint -c .eslintrc.js --ext .ts .", + "lint": "eslint -c .eslintrc.js --ext .ts src", "build": "npm run webpack && npm run fix-types", "webpack": "rimraf ./build && webpack --config ./webpack.config.ts", "demo": "npm run build && npm run ts-node --skip-project ./demo", @@ -104,8 +104,6 @@ "ts-node": "^10.2.1", "tsconfig-paths": "^4.0.0", "tsconfig-paths-webpack-plugin": "^4.0.0", - "tslint": "^6.1.3", - "tslint-immutable": "^6.0.1", "typedoc": "^0.23.2", "typescript": "4.7.4", "unzipper": "^0.10.11", diff --git a/src/file/document-wrapper.spec.ts b/src/file/document-wrapper.spec.ts index 344fded379..7f54aad9c6 100644 --- a/src/file/document-wrapper.spec.ts +++ b/src/file/document-wrapper.spec.ts @@ -7,9 +7,7 @@ describe("DocumentWrapper", () => { it("should create", () => { const file = new DocumentWrapper({ background: {} }); - // tslint:disable-next-line: no-unused-expression expect(file.View).to.be.ok; - // tslint:disable-next-line: no-unused-expression expect(file.Relationships).to.be.ok; }); }); diff --git a/src/file/drawing/anchor/anchor.spec.ts b/src/file/drawing/anchor/anchor.spec.ts index d9d0be1015..358f70aa33 100644 --- a/src/file/drawing/anchor/anchor.spec.ts +++ b/src/file/drawing/anchor/anchor.spec.ts @@ -6,7 +6,7 @@ import { IDrawingOptions } from "../drawing"; import { TextWrappingType } from "../text-wrap"; import { Anchor } from "./anchor"; -function createAnchor(drawingOptions: IDrawingOptions): Anchor { +const createAnchor = (drawingOptions: IDrawingOptions): Anchor => { return new Anchor( { fileName: "test.png", @@ -34,7 +34,7 @@ function createAnchor(drawingOptions: IDrawingOptions): Anchor { }, drawingOptions, ); -} +}; describe("Anchor", () => { let anchor: Anchor; diff --git a/src/file/drawing/drawing.spec.ts b/src/file/drawing/drawing.spec.ts index b7b9c61acc..d495ef111e 100644 --- a/src/file/drawing/drawing.spec.ts +++ b/src/file/drawing/drawing.spec.ts @@ -6,7 +6,7 @@ import { Drawing, IDrawingOptions } from "./drawing"; const imageBase64Data = `iVBORw0KGgoAAAANSUhEUgAAAIAAAACACAMAAAD04JH5AAACzVBMVEUAAAAAAAAAAAAAAAA/AD8zMzMqKiokJCQfHx8cHBwZGRkuFxcqFSonJyckJCQiIiIfHx8eHh4cHBwoGhomGSYkJCQhISEfHx8eHh4nHR0lHBwkGyQjIyMiIiIgICAfHx8mHh4lHh4kHR0jHCMiGyIhISEgICAfHx8lHx8kHh4jHR0hHCEhISEgICAlHx8kHx8jHh4jHh4iHSIhHCEhISElICAkHx8jHx8jHh4iHh4iHSIhHSElICAkICAjHx8jHx8iHh4iHh4hHiEhHSEkICAjHx8iHx8iHx8hHh4hHiEkHSEjHSAjHx8iHx8iHx8hHh4kHiEkHiEjHSAiHx8hHx8hHh4kHiEjHiAjHSAiHx8iHx8hHx8kHh4jHiEjHiAjHiAiICAiHx8kHx8jHh4jHiEjHiAiHiAiHSAiHx8jHx8jHx8jHiAiHiAiHiAiHSAiHx8jHx8jHx8iHiAiHiAiHiAjHx8jHx8jHx8jHx8iHiAiHiAiHiAjHx8jHx8jHx8iHx8iHSAiHiAjHiAjHx8jHx8hHx8iHx8iHyAiHiAjHiAjHiAjHh4hHx8iHx8iHx8iHyAjHSAjHiAjHiAjHh4hHx8iHx8iHx8jHyAjHiAhHh4iHx8iHx8jHyAjHSAjHSAhHiAhHh4iHx8iHx8jHx8jHyAjHSAjHSAiHh4iHh4jHx8jHx8jHyAjHyAhHSAhHSAiHh4iHh4jHx8jHx8jHyAhHyAhHSAiHSAiHh4jHh4jHx8jHx8jHyAhHyAhHSAiHSAjHR4jHh4jHx8j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RRQj4IYlY/UpauqKBsPJAxQF8NM1TRQ/RudSPAD34rK3scOuR8/HGcspxsJfOVS8NZbiGXiUtPgINU3v3WFDmx8pEuG3EiqKKVbCC1vm2iZqap5LAtCtleQf8F9sFYWDohzeJczYyQ4V2bEZFGsQgJRGqqqhS2phHTWn9lDkIhBTqWqxQZ+IsRvtdHY9AvI2VX2hW68nfqGmuQsCEl3JdjfCF8OW1bPdtwhQ0gm2mQzfRE3a7KCYj0BNZJs8+Kxf/r6WtTEI2FIqlsMfFgRB5A6KUnSe/vUkX0AnuvUIt8SjM1m6wWQymUwmk8lkMgXRf5vi8rLQxtUhAAAAAElFTkSuQmCC`; -function createDrawing(drawingOptions?: IDrawingOptions): Drawing { +const createDrawing = (drawingOptions?: IDrawingOptions): Drawing => { return new Drawing( { fileName: "test.jpg", @@ -24,7 +24,7 @@ function createDrawing(drawingOptions?: IDrawingOptions): Drawing { }, drawingOptions, ); -} +}; describe("Drawing", () => { let currentBreak: Drawing; diff --git a/src/file/drawing/text-wrap/wrap-square.ts b/src/file/drawing/text-wrap/wrap-square.ts index 74bc46d90a..b805ae4d55 100644 --- a/src/file/drawing/text-wrap/wrap-square.ts +++ b/src/file/drawing/text-wrap/wrap-square.ts @@ -1,8 +1,9 @@ // http://officeopenxml.com/drwPicFloating-textWrap.php import { XmlAttributeComponent, XmlComponent } from "@file/xml-components"; -import { ITextWrapping, TextWrappingSide } from "."; + import { IDistance } from "../drawing"; import { IMargins } from "../floating"; +import { ITextWrapping, TextWrappingSide } from "./text-wrapping"; interface IWrapSquareAttributes extends IDistance { readonly wrapText?: TextWrappingSide; diff --git a/src/file/file.spec.ts b/src/file/file.spec.ts index 150d728d14..b0d9278b18 100644 --- a/src/file/file.spec.ts +++ b/src/file/file.spec.ts @@ -397,7 +397,6 @@ describe("File", () => { sections: [], }); - // tslint:disable-next-line: no-unused-expression expect(doc.Comments).to.not.be.undefined; }); }); @@ -409,7 +408,6 @@ describe("File", () => { sections: [], }); - // tslint:disable-next-line: no-unused-expression expect(doc.Numbering).to.not.be.undefined; }); }); diff --git a/src/file/file.ts b/src/file/file.ts index 481c8a857f..02eace30a6 100644 --- a/src/file/file.ts +++ b/src/file/file.ts @@ -63,13 +63,7 @@ export class File { lastModifiedBy: options.lastModifiedBy ?? "Un-named", }); - this.numbering = new Numbering( - options.numbering - ? options.numbering - : { - config: [], - }, - ); + this.numbering = new Numbering(options.numbering ? options.numbering : { config: [] }); this.comments = new Comments(options.comments ?? { children: [] }); this.fileRelationships = new Relationships(); diff --git a/src/file/footnotes-wrapper.spec.ts b/src/file/footnotes-wrapper.spec.ts index 6427de6ee6..4318ab0fdd 100644 --- a/src/file/footnotes-wrapper.spec.ts +++ b/src/file/footnotes-wrapper.spec.ts @@ -7,9 +7,7 @@ describe("FootnotesWrapper", () => { it("should create", () => { const file = new FootnotesWrapper(); - // tslint:disable-next-line: no-unused-expression expect(file.View).to.be.ok; - // tslint:disable-next-line: no-unused-expression expect(file.Relationships).to.be.ok; }); }); diff --git a/src/file/media/media.ts b/src/file/media/media.ts index 8c01c9062b..4daf8d60f1 100644 --- a/src/file/media/media.ts +++ b/src/file/media/media.ts @@ -68,7 +68,9 @@ export class Media { .map((c) => c.charCodeAt(0)), ); } else { + /* eslint @typescript-eslint/no-require-imports: 0 */ const b = require("buf" + "fer"); + /* eslint @typescript-eslint/no-require-imports: 2 */ return new b.Buffer(dataURI, "base64"); } } diff --git a/src/file/numbering/level.spec.ts b/src/file/numbering/level.spec.ts index 5748a9c610..e51480bb6a 100644 --- a/src/file/numbering/level.spec.ts +++ b/src/file/numbering/level.spec.ts @@ -1,9 +1,8 @@ import { expect } from "chai"; -import { LevelFormat, LevelSuffix } from "."; import { AlignmentType } from ".."; -import { Level } from "./level"; +import { Level, LevelFormat, LevelSuffix } from "./level"; describe("Level", () => { describe("#constructor", () => { diff --git a/src/file/numbering/level.ts b/src/file/numbering/level.ts index 0e11a845cb..c307fb4f35 100644 --- a/src/file/numbering/level.ts +++ b/src/file/numbering/level.ts @@ -180,9 +180,6 @@ export class LevelBase extends XmlComponent { export class Level extends LevelBase { // This is the level that sits under abstractNum. We make a // handful of properties required - public constructor(options: ILevelsOptions) { - super(options); - } } export class LevelForOverride extends LevelBase {} diff --git a/src/file/paragraph/paragraph.spec.ts b/src/file/paragraph/paragraph.spec.ts index f6440bf23b..327ebf381f 100644 --- a/src/file/paragraph/paragraph.spec.ts +++ b/src/file/paragraph/paragraph.spec.ts @@ -19,12 +19,8 @@ import { TextRun } from "./run"; describe("Paragraph", () => { before(() => { - stub(convenienceFunctions, "uniqueId").callsFake(() => { - return "test-unique-id"; - }); - stub(convenienceFunctions, "uniqueNumericId").callsFake(() => { - return -101; - }); + stub(convenienceFunctions, "uniqueId").callsFake(() => "test-unique-id"); + stub(convenienceFunctions, "uniqueNumericId").callsFake(() => -101); }); after(() => { diff --git a/src/file/paragraph/run/image-run.spec.ts b/src/file/paragraph/run/image-run.spec.ts index 64c2835b34..972080b49a 100644 --- a/src/file/paragraph/run/image-run.spec.ts +++ b/src/file/paragraph/run/image-run.spec.ts @@ -10,9 +10,7 @@ import { ImageRun } from "./image-run"; describe("ImageRun", () => { before(() => { - stub(convenienceFunctions, "uniqueId").callsFake(() => { - return "test-unique-id"; - }); + stub(convenienceFunctions, "uniqueId").callsFake(() => "test-unique-id"); }); after(() => { diff --git a/src/file/paragraph/run/run.spec.ts b/src/file/paragraph/run/run.spec.ts index 05f7b20ca4..2604d8ffca 100644 --- a/src/file/paragraph/run/run.spec.ts +++ b/src/file/paragraph/run/run.spec.ts @@ -2,13 +2,11 @@ import { expect } from "chai"; import { Formatter } from "@export/formatter"; import { BorderStyle } from "@file/border"; -// import { FootnoteReferenceRun } from "@file/footnotes/footnote/run/reference-run"; import { ShadingType } from "@file/shading"; import { SpaceType } from "@file/space-type"; -import { Run } from "./"; import { EmphasisMarkType } from "./emphasis-mark"; -import { PageNumber } from "./run"; +import { PageNumber, Run } from "./run"; import { UnderlineType } from "./underline"; describe("Run", () => { diff --git a/src/file/paragraph/run/symbol-run.spec.ts b/src/file/paragraph/run/symbol-run.spec.ts index f8393a3751..3aab0b1e83 100644 --- a/src/file/paragraph/run/symbol-run.spec.ts +++ b/src/file/paragraph/run/symbol-run.spec.ts @@ -1,11 +1,9 @@ import { expect } from "chai"; -import { EmphasisMarkType } from "./emphasis-mark"; - import { Formatter } from "@export/formatter"; +import { EmphasisMarkType } from "./emphasis-mark"; import { UnderlineType } from "./underline"; - import { SymbolRun } from "./symbol-run"; describe("SymbolRun", () => { diff --git a/src/file/styles/defaults/document-defaults.spec.ts b/src/file/styles/defaults/document-defaults.spec.ts index fd89930f4d..ccf4607941 100644 --- a/src/file/styles/defaults/document-defaults.spec.ts +++ b/src/file/styles/defaults/document-defaults.spec.ts @@ -1,9 +1,9 @@ import { expect } from "chai"; -import { DocumentDefaults } from "./document-defaults"; - import { Formatter } from "@export/formatter"; +import { DocumentDefaults } from "./document-defaults"; + describe("DocumentDefaults", () => { it("#constructor", () => { const defaults = new DocumentDefaults({ diff --git a/src/file/styles/sample/default-style.ts b/src/file/styles/sample/default-style.ts index 29e2dea3cb..7a3421c201 100644 --- a/src/file/styles/sample/default-style.ts +++ b/src/file/styles/sample/default-style.ts @@ -1,5 +1,4 @@ -/* tslint:disable */ -function createLsdException(name, uiPriority, qFormat?, semiHidden?, unhideWhenUsed?) { +const createLsdException = (name, uiPriority, qFormat?, semiHidden?, unhideWhenUsed?) => { "use strict"; return [ @@ -13,9 +12,9 @@ function createLsdException(name, uiPriority, qFormat?, semiHidden?, unhideWhenU }, }, ]; -} +}; -export function DefaultStyle() { +export const DefaultStyle = () => { var style = { "w:styles": [ { @@ -208,4 +207,4 @@ export function DefaultStyle() { }; return style; -} +}; diff --git a/src/file/styles/style/default-styles.spec.ts b/src/file/styles/style/default-styles.spec.ts index cca9bb74bb..28038ea9d6 100644 --- a/src/file/styles/style/default-styles.spec.ts +++ b/src/file/styles/style/default-styles.spec.ts @@ -1,10 +1,10 @@ import { expect } from "chai"; import { Formatter } from "@export/formatter"; +import { EMPTY_OBJECT } from "@file/xml-components"; import * as defaultStyles from "./default-styles"; -import { EMPTY_OBJECT } from "@file/xml-components"; describe("Default Styles", () => { it("HeadingStyle#constructor", () => { diff --git a/src/file/table/grid.spec.ts b/src/file/table/grid.spec.ts index 43b631c2aa..c846991878 100644 --- a/src/file/table/grid.spec.ts +++ b/src/file/table/grid.spec.ts @@ -1,10 +1,10 @@ import { expect } from "chai"; +import { EMPTY_OBJECT } from "@file/xml-components"; import { Formatter } from "@export/formatter"; import { GridCol, TableGrid } from "./grid"; -import { EMPTY_OBJECT } from "@file/xml-components"; describe("GridCol", () => { describe("#constructor", () => { diff --git a/src/file/table/table-cell/table-cell.ts b/src/file/table/table-cell/table-cell.ts index a57288c0bc..c030edb308 100644 --- a/src/file/table/table-cell/table-cell.ts +++ b/src/file/table/table-cell/table-cell.ts @@ -10,7 +10,7 @@ export interface ITableCellOptions extends ITableCellPropertiesOptions { } export class TableCell extends XmlComponent { - public constructor(readonly options: ITableCellOptions) { + public constructor(public readonly options: ITableCellOptions) { super("w:tc"); this.root.push(new TableCellProperties(options)); diff --git a/src/file/xml-components/imported-xml-component.spec.ts b/src/file/xml-components/imported-xml-component.spec.ts index 58c07d09ca..a031409a00 100644 --- a/src/file/xml-components/imported-xml-component.spec.ts +++ b/src/file/xml-components/imported-xml-component.spec.ts @@ -1,9 +1,10 @@ import { expect } from "chai"; import { Element, xml2js } from "xml-js"; -import { EMPTY_OBJECT, ImportedXmlComponent } from "./"; +import { EMPTY_OBJECT } from "@file/xml-components"; + +import { convertToXmlComponent, ImportedXmlComponent } from "./imported-xml-component"; import { IContext } from "./base"; -import { convertToXmlComponent } from "./imported-xml-component"; const xmlString = ` diff --git a/src/file/xml-components/imported-xml-component.ts b/src/file/xml-components/imported-xml-component.ts index 411ef0ac42..6eca0c261b 100644 --- a/src/file/xml-components/imported-xml-component.ts +++ b/src/file/xml-components/imported-xml-component.ts @@ -1,6 +1,8 @@ // tslint:disable:no-any import { Element as XmlElement, xml2js } from "xml-js"; -import { IXmlableObject, XmlAttributeComponent, XmlComponent } from "."; + +import { IXmlableObject, XmlAttributeComponent, XmlComponent } from "@file/xml-components"; + import { IContext } from "./base"; /** @@ -8,7 +10,7 @@ import { IContext } from "./base"; * @param element the xml element in json presentation */ -export function convertToXmlComponent(element: XmlElement): ImportedXmlComponent | string | undefined { +export const convertToXmlComponent = (element: XmlElement): ImportedXmlComponent | string | undefined => { switch (element.type) { case undefined: case "element": @@ -26,7 +28,7 @@ export function convertToXmlComponent(element: XmlElement): ImportedXmlComponent default: return undefined; } -} +}; class ImportedXmlComponentAttributes extends XmlAttributeComponent { // noop diff --git a/src/index.spec.ts b/src/index.spec.ts index dd687e7bf7..480dbf1dc1 100644 --- a/src/index.spec.ts +++ b/src/index.spec.ts @@ -5,7 +5,6 @@ import { Document } from "./index"; describe("Index", () => { describe("Document", () => { it("should instantiate the Document", () => { - // tslint:disable-next-line: no-unused-expression expect( new Document({ sections: [], diff --git a/src/util/convenience-functions.spec.ts b/src/util/convenience-functions.spec.ts index 79527d3854..8fa26f61a3 100644 --- a/src/util/convenience-functions.spec.ts +++ b/src/util/convenience-functions.spec.ts @@ -19,14 +19,12 @@ describe("Utility", () => { describe("#uniqueNumericId", () => { it("should generate a unique incrementing ID", () => { - // tslint:disable-next-line: no-unused-expression expect(uniqueNumericId()).to.not.be.undefined; }); }); describe("#uniqueId", () => { it("should generate a unique pseudorandom ID", () => { - // tslint:disable-next-line: no-unused-expression expect(uniqueId()).to.not.be.empty; }); }); diff --git a/src/util/convenience-functions.ts b/src/util/convenience-functions.ts index 4644775ccc..64f451e066 100644 --- a/src/util/convenience-functions.ts +++ b/src/util/convenience-functions.ts @@ -7,8 +7,6 @@ export const convertMillimetersToTwip = (millimeters: number): number => Math.fl export const convertInchesToTwip = (inches: number): number => Math.floor(inches * 72 * 20); -export const uniqueNumericId = (): number => { - return ++currentCount; -}; +export const uniqueNumericId = (): number => ++currentCount; export const uniqueId = (): string => nanoid().toLowerCase(); diff --git a/src/util/values.ts b/src/util/values.ts index aab6bc11ab..67e8031a43 100644 --- a/src/util/values.ts +++ b/src/util/values.ts @@ -7,63 +7,63 @@ // // // -export function decimalNumber(val: number): number { +export const decimalNumber = (val: number): number => { if (isNaN(val)) { throw new Error(`Invalid value '${val}' specified. Must be an integer.`); } return Math.floor(val); -} +}; // // // -export function unsignedDecimalNumber(val: number): number { +export const unsignedDecimalNumber = (val: number): number => { const value = decimalNumber(val); if (value < 0) { throw new Error(`Invalid value '${val}' specified. Must be a positive integer.`); } return value; -} +}; // The xsd:hexBinary type represents binary data as a sequence of binary octets. // It uses hexadecimal encoding, where each binary octet is a two-character hexadecimal number. // Lowercase and uppercase letters A through F are permitted. For example, 0FB8 and 0fb8 are two // equal xsd:hexBinary representations consisting of two octets. // http://www.datypic.com/sc/xsd/t-xsd_hexBinary.html -function hexBinary(val: string, length: number): string { +const hexBinary = (val: string, length: number): string => { const expectedLength = length * 2; if (val.length !== expectedLength || isNaN(Number("0x" + val))) { throw new Error(`Invalid hex value '${val}'. Expected ${expectedLength} digit hex value`); } return val; -} +}; // // // // // -export function longHexNumber(val: string): string { +export const longHexNumber = (val: string): string => { return hexBinary(val, 4); -} +}; // // // // // -export function shortHexNumber(val: string): string { +export const shortHexNumber = (val: string): string => { return hexBinary(val, 2); -} +}; // // // // // -export function uCharHexNumber(val: string): string { +export const uCharHexNumber = (val: string): string => { return hexBinary(val, 1); -} +}; // // @@ -76,7 +76,7 @@ export function uCharHexNumber(val: string): string { // // // -export function universalMeasureValue(val: string): string { +export const universalMeasureValue = (val: string): string => { const unit = val.slice(-2); if (!universalMeasureUnits.includes(unit)) { throw new Error(`Invalid unit '${unit}' specified. Valid units are ${universalMeasureUnits.join(", ")}`); @@ -86,7 +86,7 @@ export function universalMeasureValue(val: string): string { throw new Error(`Invalid value '${amount}' specified. Expected a valid number.`); } return `${Number(amount)}${unit}`; -} +}; const universalMeasureUnits = ["mm", "cm", "in", "pt", "pc", "pi"]; // @@ -94,13 +94,13 @@ const universalMeasureUnits = ["mm", "cm", "in", "pt", "pc", "pi"]; // // // -export function positiveUniversalMeasureValue(val: string): string { +export const positiveUniversalMeasureValue = (val: string): string => { const value = universalMeasureValue(val); if (parseFloat(value) < 0) { throw new Error(`Invalid value '${value}' specified. Expected a positive number.`); } return value; -} +}; // // @@ -116,7 +116,7 @@ export function positiveUniversalMeasureValue(val: string): string { // // // -export function hexColorValue(val: string): string { +export const hexColorValue = (val: string): string => { if (val === "auto") { return val; } @@ -124,42 +124,42 @@ export function hexColorValue(val: string): string { // Most clients work with it, but strip it off anyway for strict compliance. const color = val.charAt(0) === "#" ? val.substring(1) : val; return hexBinary(color, 3); -} +}; // // // -export function signedTwipsMeasureValue(val: string | number): string | number { +export const signedTwipsMeasureValue = (val: string | number): string | number => { return typeof val === "string" ? universalMeasureValue(val) : decimalNumber(val); -} +}; // // // -export function hpsMeasureValue(val: string | number): string | number { +export const hpsMeasureValue = (val: string | number): string | number => { return typeof val === "string" ? positiveUniversalMeasureValue(val) : unsignedDecimalNumber(val); -} +}; // // // -export function signedHpsMeasureValue(val: string | number): string | number { +export const signedHpsMeasureValue = (val: string | number): string | number => { return typeof val === "string" ? universalMeasureValue(val) : decimalNumber(val); -} +}; // // // -export function twipsMeasureValue(val: string | number): string | number { +export const twipsMeasureValue = (val: string | number): string | number => { return typeof val === "string" ? positiveUniversalMeasureValue(val) : unsignedDecimalNumber(val); -} +}; // // // // // -export function percentageValue(val: string): string { +export const percentageValue = (val: string): string => { if (val.slice(-1) !== "%") { throw new Error(`Invalid value '${val}'. Expected percentage value (eg '55%')`); } @@ -168,7 +168,7 @@ export function percentageValue(val: string): string { throw new Error(`Invalid value '${percent}' specified. Expected a valid number.`); } return `${Number(percent)}%`; -} +}; // // @@ -182,7 +182,7 @@ export function percentageValue(val: string): string { // // -export function measurementOrPercentValue(val: number | string): number | string { +export const measurementOrPercentValue = (val: number | string): number | string => { if (typeof val === "number") { return decimalNumber(val); } @@ -190,7 +190,7 @@ export function measurementOrPercentValue(val: number | string): number | string return percentageValue(val); } return universalMeasureValue(val); -} +}; // // @@ -222,6 +222,6 @@ export const pointMeasureValue = unsignedDecimalNumber; // // Luckily, js has this format built in already. See: // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toISOString -export function dateTimeValue(val: Date): string { +export const dateTimeValue = (val: Date): string => { return val.toISOString(); -} +}; diff --git a/tslint.json b/tslint.json deleted file mode 100644 index 3da57d1a2f..0000000000 --- a/tslint.json +++ /dev/null @@ -1,37 +0,0 @@ -{ - "extends": ["tslint:latest", "tslint-immutable"], - "rules": { - "curly": true, - "one-variable-per-declaration": [true], - "no-any": true, - "no-consecutive-blank-lines": [true], - "no-require-imports": true, - "member-access": [true, "check-accessor"], - "indent": [true, "spaces"], - "object-literal-sort-keys": false, - "object-literal-shorthand": false, - "typedef": [true, "call-signature", "parameter", "property-declaration"], - "max-line-length": [false], - "max-classes-per-file": [false], - "no-implicit-dependencies": false, - "no-submodule-imports": false, - "no-null-keyword": true, - "return-undefined": true, - "prefer-readonly": true, - "no-duplicate-imports": true, - "unnecessary-constructor": true, - "file-name-casing": [true, "kebab-case"], - "interface-name": [true, "always-prefix"], - "ordered-imports": true, - "no-default-export": true, - "arrow-return-shorthand": true, - "variable-name": [true, "ban-keywords", "check-format"], - // Functional Programming Rules - "no-parameter-reassignment": true, - "readonly-keyword": true, - "no-delete": true, - "no-method-signature": true, - "no-mixed-interface": true - // "no-expression-statement": [true, { "ignore-prefix": ["console.", "describe", "it", "super", "expect"] }] - } -}