Fix ESLinting errors and remove TSLint

This commit is contained in:
Dolan Miu
2022-08-31 08:59:27 +01:00
parent 1bdf9a4987
commit ebcb37cbed
30 changed files with 104 additions and 201 deletions

View File

@ -106,6 +106,9 @@ module.exports = {
FunctionExpression: { FunctionExpression: {
parameters: "first", parameters: "first",
}, },
SwitchCase: 1,
flatTernaryExpressions: false,
ignoredNodes: [],
}, },
], ],
"@typescript-eslint/naming-convention": [ "@typescript-eslint/naming-convention": [
@ -113,9 +116,9 @@ module.exports = {
{ {
selector: ["objectLiteralProperty"], selector: ["objectLiteralProperty"],
leadingUnderscore: "allow", leadingUnderscore: "allow",
format: ["camelCase"], format: ["camelCase", "PascalCase"],
custom: { filter: {
regex: "^w:.+", regex: "(^[a-z]+:.+)|_attr|[0-9]",
match: false, match: false,
}, },
}, },
@ -204,7 +207,7 @@ module.exports = {
"no-throw-literal": "error", "no-throw-literal": "error",
"no-trailing-spaces": "error", "no-trailing-spaces": "error",
"no-undef-init": "error", "no-undef-init": "error",
"no-underscore-dangle": "error", "no-underscore-dangle": ["error", { allow: ["_attr"] }],
"no-unsafe-finally": "error", "no-unsafe-finally": "error",
"no-unused-expressions": "off", "no-unused-expressions": "off",
"no-unused-labels": "error", "no-unused-labels": "error",
@ -252,13 +255,14 @@ module.exports = {
}, },
}, },
], ],
"@typescript-eslint/explicit-function-return-type": "off",
}, },
overrides: [ overrides: [
{ {
// enable the rule specifically for TypeScript files
files: ["*.spec.ts"], files: ["*.spec.ts"],
rules: { rules: {
"@typescript-eslint/explicit-function-return-type": "off", "@typescript-eslint/no-unused-expressions": "off",
"@typescript-eslint/dot-notation": "off",
}, },
}, },
], ],

View File

@ -1,5 +1,3 @@
{ {
"recommendations": [ "recommendations": ["streetsidesoftware.code-spell-checker", "dbaeumer.vscode-eslint"]
"streetsidesoftware.code-spell-checker"
]
} }

88
package-lock.json generated
View File

@ -57,8 +57,6 @@
"ts-node": "^10.2.1", "ts-node": "^10.2.1",
"tsconfig-paths": "^4.0.0", "tsconfig-paths": "^4.0.0",
"tsconfig-paths-webpack-plugin": "^4.0.0", "tsconfig-paths-webpack-plugin": "^4.0.0",
"tslint": "^6.1.3",
"tslint-immutable": "^6.0.1",
"typedoc": "^0.23.2", "typedoc": "^0.23.2",
"typescript": "4.7.4", "typescript": "4.7.4",
"unzipper": "^0.10.11", "unzipper": "^0.10.11",
@ -2621,6 +2619,7 @@
"resolved": "https://registry.npmjs.org/builtin-modules/-/builtin-modules-1.1.1.tgz", "resolved": "https://registry.npmjs.org/builtin-modules/-/builtin-modules-1.1.1.tgz",
"integrity": "sha1-Jw8HbFpywC9bZaR9+Uxf46J4iS8=", "integrity": "sha1-Jw8HbFpywC9bZaR9+Uxf46J4iS8=",
"dev": true, "dev": true,
"peer": true,
"engines": { "engines": {
"node": ">=0.10.0" "node": ">=0.10.0"
} }
@ -3008,7 +3007,8 @@
"version": "2.15.1", "version": "2.15.1",
"resolved": "https://registry.npmjs.org/commander/-/commander-2.15.1.tgz", "resolved": "https://registry.npmjs.org/commander/-/commander-2.15.1.tgz",
"integrity": "sha512-VlfT9F3V0v+jr4yxPc5gg9s62/fIVWsd2Bk2iD435um1NlGMYdVCq+MjcXnhYq2icNOizHr1kK+5TI6H0Hy0ag==", "integrity": "sha512-VlfT9F3V0v+jr4yxPc5gg9s62/fIVWsd2Bk2iD435um1NlGMYdVCq+MjcXnhYq2icNOizHr1kK+5TI6H0Hy0ag==",
"dev": true "dev": true,
"peer": true
}, },
"node_modules/comment-json": { "node_modules/comment-json": {
"version": "4.2.3", "version": "4.2.3",
@ -10340,11 +10340,11 @@
"dev": true "dev": true
}, },
"node_modules/tslint": { "node_modules/tslint": {
"version": "6.1.3", "version": "5.20.1",
"resolved": "https://registry.npmjs.org/tslint/-/tslint-6.1.3.tgz", "resolved": "https://registry.npmjs.org/tslint/-/tslint-5.20.1.tgz",
"integrity": "sha512-IbR4nkT96EQOvKE2PW/djGz8iGNeJ4rF2mBfiYaR/nvUWYKJhLwimoJKgjIFEIDibBtOevj7BqCRL4oHeWWUCg==", "integrity": "sha512-EcMxhzCFt8k+/UP5r8waCf/lzmeSyVlqxqMEDQE7rWYiQky8KpIBz1JAoYXfROHrPZ1XXd43q8yQnULOLiBRQg==",
"deprecated": "TSLint has been deprecated in favor of ESLint. Please see https://github.com/palantir/tslint/issues/4534 for more information.",
"dev": true, "dev": true,
"peer": true,
"dependencies": { "dependencies": {
"@babel/code-frame": "^7.0.0", "@babel/code-frame": "^7.0.0",
"builtin-modules": "^1.1.1", "builtin-modules": "^1.1.1",
@ -10354,10 +10354,10 @@
"glob": "^7.1.1", "glob": "^7.1.1",
"js-yaml": "^3.13.1", "js-yaml": "^3.13.1",
"minimatch": "^3.0.4", "minimatch": "^3.0.4",
"mkdirp": "^0.5.3", "mkdirp": "^0.5.1",
"resolve": "^1.3.2", "resolve": "^1.3.2",
"semver": "^5.3.0", "semver": "^5.3.0",
"tslib": "^1.13.0", "tslib": "^1.8.0",
"tsutils": "^2.29.0" "tsutils": "^2.29.0"
}, },
"bin": { "bin": {
@ -10367,20 +10367,7 @@
"node": ">=4.8.0" "node": ">=4.8.0"
}, },
"peerDependencies": { "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" "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-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"
} }
}, },
"node_modules/tslint/node_modules/diff": { "node_modules/tslint/node_modules/diff": {
@ -10388,6 +10375,7 @@
"resolved": "https://registry.npmjs.org/diff/-/diff-4.0.2.tgz", "resolved": "https://registry.npmjs.org/diff/-/diff-4.0.2.tgz",
"integrity": "sha512-58lmxKSA4BNyLz+HHMUzlOEpg09FV+ev6ZMe3vJihgdxzgcwZ8VoEEPmALCZG9LmqfVoNMMKpttIYTVG6uDY7A==", "integrity": "sha512-58lmxKSA4BNyLz+HHMUzlOEpg09FV+ev6ZMe3vJihgdxzgcwZ8VoEEPmALCZG9LmqfVoNMMKpttIYTVG6uDY7A==",
"dev": true, "dev": true,
"peer": true,
"engines": { "engines": {
"node": ">=0.3.1" "node": ">=0.3.1"
} }
@ -10397,6 +10385,7 @@
"resolved": "https://registry.npmjs.org/glob/-/glob-7.2.0.tgz", "resolved": "https://registry.npmjs.org/glob/-/glob-7.2.0.tgz",
"integrity": "sha512-lmLf6gtyrPq8tTjSmrO94wBeQbFR3HbLHbuyD69wuyQkImp2hWqMGB47OX65FBkPffO641IP9jWa1z4ivqG26Q==", "integrity": "sha512-lmLf6gtyrPq8tTjSmrO94wBeQbFR3HbLHbuyD69wuyQkImp2hWqMGB47OX65FBkPffO641IP9jWa1z4ivqG26Q==",
"dev": true, "dev": true,
"peer": true,
"dependencies": { "dependencies": {
"fs.realpath": "^1.0.0", "fs.realpath": "^1.0.0",
"inflight": "^1.0.4", "inflight": "^1.0.4",
@ -10412,23 +10401,12 @@
"url": "https://github.com/sponsors/isaacs" "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": { "node_modules/tsutils": {
"version": "2.29.0", "version": "2.29.0",
"resolved": "https://registry.npmjs.org/tsutils/-/tsutils-2.29.0.tgz", "resolved": "https://registry.npmjs.org/tsutils/-/tsutils-2.29.0.tgz",
"integrity": "sha512-g5JVHCIJwzfISaXpXE1qvNalca5Jwob6FjI4AoPlqMusJ6ftFE7IkkFoMhVLRgK+4Kx3gkzb8UZK5t5yTTvEmA==", "integrity": "sha512-g5JVHCIJwzfISaXpXE1qvNalca5Jwob6FjI4AoPlqMusJ6ftFE7IkkFoMhVLRgK+4Kx3gkzb8UZK5t5yTTvEmA==",
"dev": true, "dev": true,
"peer": true,
"dependencies": { "dependencies": {
"tslib": "^1.8.1" "tslib": "^1.8.1"
}, },
@ -13574,7 +13552,8 @@
"version": "1.1.1", "version": "1.1.1",
"resolved": "https://registry.npmjs.org/builtin-modules/-/builtin-modules-1.1.1.tgz", "resolved": "https://registry.npmjs.org/builtin-modules/-/builtin-modules-1.1.1.tgz",
"integrity": "sha1-Jw8HbFpywC9bZaR9+Uxf46J4iS8=", "integrity": "sha1-Jw8HbFpywC9bZaR9+Uxf46J4iS8=",
"dev": true "dev": true,
"peer": true
}, },
"cacheable-request": { "cacheable-request": {
"version": "6.1.0", "version": "6.1.0",
@ -13869,7 +13848,8 @@
"version": "2.15.1", "version": "2.15.1",
"resolved": "https://registry.npmjs.org/commander/-/commander-2.15.1.tgz", "resolved": "https://registry.npmjs.org/commander/-/commander-2.15.1.tgz",
"integrity": "sha512-VlfT9F3V0v+jr4yxPc5gg9s62/fIVWsd2Bk2iD435um1NlGMYdVCq+MjcXnhYq2icNOizHr1kK+5TI6H0Hy0ag==", "integrity": "sha512-VlfT9F3V0v+jr4yxPc5gg9s62/fIVWsd2Bk2iD435um1NlGMYdVCq+MjcXnhYq2icNOizHr1kK+5TI6H0Hy0ag==",
"dev": true "dev": true,
"peer": true
}, },
"comment-json": { "comment-json": {
"version": "4.2.3", "version": "4.2.3",
@ -19413,10 +19393,11 @@
"dev": true "dev": true
}, },
"tslint": { "tslint": {
"version": "6.1.3", "version": "5.20.1",
"resolved": "https://registry.npmjs.org/tslint/-/tslint-6.1.3.tgz", "resolved": "https://registry.npmjs.org/tslint/-/tslint-5.20.1.tgz",
"integrity": "sha512-IbR4nkT96EQOvKE2PW/djGz8iGNeJ4rF2mBfiYaR/nvUWYKJhLwimoJKgjIFEIDibBtOevj7BqCRL4oHeWWUCg==", "integrity": "sha512-EcMxhzCFt8k+/UP5r8waCf/lzmeSyVlqxqMEDQE7rWYiQky8KpIBz1JAoYXfROHrPZ1XXd43q8yQnULOLiBRQg==",
"dev": true, "dev": true,
"peer": true,
"requires": { "requires": {
"@babel/code-frame": "^7.0.0", "@babel/code-frame": "^7.0.0",
"builtin-modules": "^1.1.1", "builtin-modules": "^1.1.1",
@ -19426,10 +19407,10 @@
"glob": "^7.1.1", "glob": "^7.1.1",
"js-yaml": "^3.13.1", "js-yaml": "^3.13.1",
"minimatch": "^3.0.4", "minimatch": "^3.0.4",
"mkdirp": "^0.5.3", "mkdirp": "^0.5.1",
"resolve": "^1.3.2", "resolve": "^1.3.2",
"semver": "^5.3.0", "semver": "^5.3.0",
"tslib": "^1.13.0", "tslib": "^1.8.0",
"tsutils": "^2.29.0" "tsutils": "^2.29.0"
}, },
"dependencies": { "dependencies": {
@ -19437,13 +19418,15 @@
"version": "4.0.2", "version": "4.0.2",
"resolved": "https://registry.npmjs.org/diff/-/diff-4.0.2.tgz", "resolved": "https://registry.npmjs.org/diff/-/diff-4.0.2.tgz",
"integrity": "sha512-58lmxKSA4BNyLz+HHMUzlOEpg09FV+ev6ZMe3vJihgdxzgcwZ8VoEEPmALCZG9LmqfVoNMMKpttIYTVG6uDY7A==", "integrity": "sha512-58lmxKSA4BNyLz+HHMUzlOEpg09FV+ev6ZMe3vJihgdxzgcwZ8VoEEPmALCZG9LmqfVoNMMKpttIYTVG6uDY7A==",
"dev": true "dev": true,
"peer": true
}, },
"glob": { "glob": {
"version": "7.2.0", "version": "7.2.0",
"resolved": "https://registry.npmjs.org/glob/-/glob-7.2.0.tgz", "resolved": "https://registry.npmjs.org/glob/-/glob-7.2.0.tgz",
"integrity": "sha512-lmLf6gtyrPq8tTjSmrO94wBeQbFR3HbLHbuyD69wuyQkImp2hWqMGB47OX65FBkPffO641IP9jWa1z4ivqG26Q==", "integrity": "sha512-lmLf6gtyrPq8tTjSmrO94wBeQbFR3HbLHbuyD69wuyQkImp2hWqMGB47OX65FBkPffO641IP9jWa1z4ivqG26Q==",
"dev": true, "dev": true,
"peer": true,
"requires": { "requires": {
"fs.realpath": "^1.0.0", "fs.realpath": "^1.0.0",
"inflight": "^1.0.4", "inflight": "^1.0.4",
@ -19452,32 +19435,15 @@
"once": "^1.3.0", "once": "^1.3.0",
"path-is-absolute": "^1.0.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": { "tsutils": {
"version": "2.29.0", "version": "2.29.0",
"resolved": "https://registry.npmjs.org/tsutils/-/tsutils-2.29.0.tgz", "resolved": "https://registry.npmjs.org/tsutils/-/tsutils-2.29.0.tgz",
"integrity": "sha512-g5JVHCIJwzfISaXpXE1qvNalca5Jwob6FjI4AoPlqMusJ6ftFE7IkkFoMhVLRgK+4Kx3gkzb8UZK5t5yTTvEmA==", "integrity": "sha512-g5JVHCIJwzfISaXpXE1qvNalca5Jwob6FjI4AoPlqMusJ6ftFE7IkkFoMhVLRgK+4Kx3gkzb8UZK5t5yTTvEmA==",
"dev": true, "dev": true,
"peer": true,
"requires": { "requires": {
"tslib": "^1.8.1" "tslib": "^1.8.1"
} }

View File

@ -9,7 +9,7 @@
"test.coverage": "nyc npm test", "test.coverage": "nyc npm test",
"test.watch": "npm test -- --watch", "test.watch": "npm test -- --watch",
"prepublishOnly": "npm run build --production", "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", "build": "npm run webpack && npm run fix-types",
"webpack": "rimraf ./build && webpack --config ./webpack.config.ts", "webpack": "rimraf ./build && webpack --config ./webpack.config.ts",
"demo": "npm run build && npm run ts-node --skip-project ./demo", "demo": "npm run build && npm run ts-node --skip-project ./demo",
@ -104,8 +104,6 @@
"ts-node": "^10.2.1", "ts-node": "^10.2.1",
"tsconfig-paths": "^4.0.0", "tsconfig-paths": "^4.0.0",
"tsconfig-paths-webpack-plugin": "^4.0.0", "tsconfig-paths-webpack-plugin": "^4.0.0",
"tslint": "^6.1.3",
"tslint-immutable": "^6.0.1",
"typedoc": "^0.23.2", "typedoc": "^0.23.2",
"typescript": "4.7.4", "typescript": "4.7.4",
"unzipper": "^0.10.11", "unzipper": "^0.10.11",

View File

@ -7,9 +7,7 @@ describe("DocumentWrapper", () => {
it("should create", () => { it("should create", () => {
const file = new DocumentWrapper({ background: {} }); const file = new DocumentWrapper({ background: {} });
// tslint:disable-next-line: no-unused-expression
expect(file.View).to.be.ok; expect(file.View).to.be.ok;
// tslint:disable-next-line: no-unused-expression
expect(file.Relationships).to.be.ok; expect(file.Relationships).to.be.ok;
}); });
}); });

View File

@ -6,7 +6,7 @@ import { IDrawingOptions } from "../drawing";
import { TextWrappingType } from "../text-wrap"; import { TextWrappingType } from "../text-wrap";
import { Anchor } from "./anchor"; import { Anchor } from "./anchor";
function createAnchor(drawingOptions: IDrawingOptions): Anchor { const createAnchor = (drawingOptions: IDrawingOptions): Anchor => {
return new Anchor( return new Anchor(
{ {
fileName: "test.png", fileName: "test.png",
@ -34,7 +34,7 @@ function createAnchor(drawingOptions: IDrawingOptions): Anchor {
}, },
drawingOptions, drawingOptions,
); );
} };
describe("Anchor", () => { describe("Anchor", () => {
let anchor: Anchor; let anchor: Anchor;

View File

@ -6,7 +6,7 @@ import { Drawing, IDrawingOptions } from "./drawing";
const imageBase64Data = `iVBORw0KGgoAAAANSUhEUgAAAIAAAACACAMAAAD04JH5AAACzVBMVEUAAAAAAAAAAAAAAAA/AD8zMzMqKiokJCQfHx8cHBwZGRkuFxcqFSonJyckJCQiIiIfHx8eHh4cHBwoGhomGSYkJCQhISEfHx8eHh4nHR0lHBwkGyQjIyMiIiIgICAfHx8mHh4lHh4kHR0jHCMiGyIhISEgICAfHx8lHx8kHh4jHR0hHCEhISEgICAlHx8kHx8jHh4jHh4iHSIhHCEhISElICAkHx8jHx8jHh4iHh4iHSIhHSElICAkICAjHx8jHx8iHh4iHh4hHiEhHSEkICAjHx8iHx8iHx8hHh4hHiEkHSEjHSAjHx8iHx8iHx8hHh4kHiEkHiEjHSAiHx8hHx8hHh4kHiEjHiAjHSAiHx8iHx8hHx8kHh4jHiEjHiAjHiAiICAiHx8kHx8jHh4jHiEjHiAiHiAiHSAiHx8jHx8jHx8jHiAiHiAiHiAiHSAiHx8jHx8jHx8iHiAiHiAiHiAjHx8jHx8jHx8jHx8iHiAiHiAiHiAjHx8jHx8jHx8iHx8iHSAiHiAjHiAjHx8jHx8hHx8iHx8iHyAiHiAjHiAjHiAjHh4hHx8iHx8iHx8iHy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0C/sJMnjFvhiERXPQvUNRe9p29lhR04CdBpC8Sl8YiuncIxEuzUUg4Dkgj+paVozygY9plPMh28SaymO9kabAopREGF3vt9MzeFFl8G7lRSZ8FFGK8XX4VA8QjEd7XrM3M0OXz8YCy+qKBLgq3wqnofiTorF0Ax56Rg1J1elW+BBAsVe+My6iYq7IK6keBdOIseV2qn5Pb8f3MqkWAXf9ThM8c8lAOIotuFsF875lRrH5klRcG0+xcPwQ1oLxfeRAP4heQTnGL78X2rqlw2DK59SXAV/zKaiGMAuko5InCt68mcOan5+ohf+z1pP8lQY/GHZQMV4YD3FpXDp4qerqbF/lBWBswyi+AL+ia+maLgcRRQj4IYlY/UpauqKBsPJAxQF8NM1TRQ/RudSPAD34rK3scOuR8/HGcspxsJfOVS8NZbiGXiUtPgINU3v3WFDmx8pEuG3EiqKKVbCC1vm2iZqap5LAtCtleQf8F9sFYWDohzeJczYyQ4V2bEZFGsQgJRGqqqhS2phHTWn9lDkIhBTqWqxQZ+IsRvtdHY9AvI2VX2hW68nfqGmuQsCEl3JdjfCF8OW1bPdtwhQ0gm2mQzfRE3a7KCYj0BNZJs8+Kxf/r6WtTEI2FIqlsMfFgRB5A6KUnSe/vUkX0AnuvUIt8SjM1m6wWQymUwmk8lkMgXRf5vi8rLQxtUhAAAAAElFTkSuQmCC`;
function createDrawing(drawingOptions?: IDrawingOptions): Drawing { const createDrawing = (drawingOptions?: IDrawingOptions): Drawing => {
return new Drawing( return new Drawing(
{ {
fileName: "test.jpg", fileName: "test.jpg",
@ -24,7 +24,7 @@ function createDrawing(drawingOptions?: IDrawingOptions): Drawing {
}, },
drawingOptions, drawingOptions,
); );
} };
describe("Drawing", () => { describe("Drawing", () => {
let currentBreak: Drawing; let currentBreak: Drawing;

View File

@ -1,8 +1,9 @@
// http://officeopenxml.com/drwPicFloating-textWrap.php // http://officeopenxml.com/drwPicFloating-textWrap.php
import { XmlAttributeComponent, XmlComponent } from "@file/xml-components"; import { XmlAttributeComponent, XmlComponent } from "@file/xml-components";
import { ITextWrapping, TextWrappingSide } from ".";
import { IDistance } from "../drawing"; import { IDistance } from "../drawing";
import { IMargins } from "../floating"; import { IMargins } from "../floating";
import { ITextWrapping, TextWrappingSide } from "./text-wrapping";
interface IWrapSquareAttributes extends IDistance { interface IWrapSquareAttributes extends IDistance {
readonly wrapText?: TextWrappingSide; readonly wrapText?: TextWrappingSide;

View File

@ -397,7 +397,6 @@ describe("File", () => {
sections: [], sections: [],
}); });
// tslint:disable-next-line: no-unused-expression
expect(doc.Comments).to.not.be.undefined; expect(doc.Comments).to.not.be.undefined;
}); });
}); });
@ -409,7 +408,6 @@ describe("File", () => {
sections: [], sections: [],
}); });
// tslint:disable-next-line: no-unused-expression
expect(doc.Numbering).to.not.be.undefined; expect(doc.Numbering).to.not.be.undefined;
}); });
}); });

View File

@ -63,13 +63,7 @@ export class File {
lastModifiedBy: options.lastModifiedBy ?? "Un-named", lastModifiedBy: options.lastModifiedBy ?? "Un-named",
}); });
this.numbering = new Numbering( this.numbering = new Numbering(options.numbering ? options.numbering : { config: [] });
options.numbering
? options.numbering
: {
config: [],
},
);
this.comments = new Comments(options.comments ?? { children: [] }); this.comments = new Comments(options.comments ?? { children: [] });
this.fileRelationships = new Relationships(); this.fileRelationships = new Relationships();

View File

@ -7,9 +7,7 @@ describe("FootnotesWrapper", () => {
it("should create", () => { it("should create", () => {
const file = new FootnotesWrapper(); const file = new FootnotesWrapper();
// tslint:disable-next-line: no-unused-expression
expect(file.View).to.be.ok; expect(file.View).to.be.ok;
// tslint:disable-next-line: no-unused-expression
expect(file.Relationships).to.be.ok; expect(file.Relationships).to.be.ok;
}); });
}); });

View File

@ -68,7 +68,9 @@ export class Media {
.map((c) => c.charCodeAt(0)), .map((c) => c.charCodeAt(0)),
); );
} else { } else {
/* eslint @typescript-eslint/no-require-imports: 0 */
const b = require("buf" + "fer"); const b = require("buf" + "fer");
/* eslint @typescript-eslint/no-require-imports: 2 */
return new b.Buffer(dataURI, "base64"); return new b.Buffer(dataURI, "base64");
} }
} }

View File

@ -1,9 +1,8 @@
import { expect } from "chai"; import { expect } from "chai";
import { LevelFormat, LevelSuffix } from ".";
import { AlignmentType } from ".."; import { AlignmentType } from "..";
import { Level } from "./level"; import { Level, LevelFormat, LevelSuffix } from "./level";
describe("Level", () => { describe("Level", () => {
describe("#constructor", () => { describe("#constructor", () => {

View File

@ -180,9 +180,6 @@ export class LevelBase extends XmlComponent {
export class Level extends LevelBase { export class Level extends LevelBase {
// This is the level that sits under abstractNum. We make a // This is the level that sits under abstractNum. We make a
// handful of properties required // handful of properties required
public constructor(options: ILevelsOptions) {
super(options);
}
} }
export class LevelForOverride extends LevelBase {} export class LevelForOverride extends LevelBase {}

View File

@ -19,12 +19,8 @@ import { TextRun } from "./run";
describe("Paragraph", () => { describe("Paragraph", () => {
before(() => { before(() => {
stub(convenienceFunctions, "uniqueId").callsFake(() => { stub(convenienceFunctions, "uniqueId").callsFake(() => "test-unique-id");
return "test-unique-id"; stub(convenienceFunctions, "uniqueNumericId").callsFake(() => -101);
});
stub(convenienceFunctions, "uniqueNumericId").callsFake(() => {
return -101;
});
}); });
after(() => { after(() => {

View File

@ -10,9 +10,7 @@ import { ImageRun } from "./image-run";
describe("ImageRun", () => { describe("ImageRun", () => {
before(() => { before(() => {
stub(convenienceFunctions, "uniqueId").callsFake(() => { stub(convenienceFunctions, "uniqueId").callsFake(() => "test-unique-id");
return "test-unique-id";
});
}); });
after(() => { after(() => {

View File

@ -2,13 +2,11 @@ import { expect } from "chai";
import { Formatter } from "@export/formatter"; import { Formatter } from "@export/formatter";
import { BorderStyle } from "@file/border"; import { BorderStyle } from "@file/border";
// import { FootnoteReferenceRun } from "@file/footnotes/footnote/run/reference-run";
import { ShadingType } from "@file/shading"; import { ShadingType } from "@file/shading";
import { SpaceType } from "@file/space-type"; import { SpaceType } from "@file/space-type";
import { Run } from "./";
import { EmphasisMarkType } from "./emphasis-mark"; import { EmphasisMarkType } from "./emphasis-mark";
import { PageNumber } from "./run"; import { PageNumber, Run } from "./run";
import { UnderlineType } from "./underline"; import { UnderlineType } from "./underline";
describe("Run", () => { describe("Run", () => {

View File

@ -1,11 +1,9 @@
import { expect } from "chai"; import { expect } from "chai";
import { EmphasisMarkType } from "./emphasis-mark";
import { Formatter } from "@export/formatter"; import { Formatter } from "@export/formatter";
import { EmphasisMarkType } from "./emphasis-mark";
import { UnderlineType } from "./underline"; import { UnderlineType } from "./underline";
import { SymbolRun } from "./symbol-run"; import { SymbolRun } from "./symbol-run";
describe("SymbolRun", () => { describe("SymbolRun", () => {

View File

@ -1,9 +1,9 @@
import { expect } from "chai"; import { expect } from "chai";
import { DocumentDefaults } from "./document-defaults";
import { Formatter } from "@export/formatter"; import { Formatter } from "@export/formatter";
import { DocumentDefaults } from "./document-defaults";
describe("DocumentDefaults", () => { describe("DocumentDefaults", () => {
it("#constructor", () => { it("#constructor", () => {
const defaults = new DocumentDefaults({ const defaults = new DocumentDefaults({

View File

@ -1,5 +1,4 @@
/* tslint:disable */ const createLsdException = (name, uiPriority, qFormat?, semiHidden?, unhideWhenUsed?) => {
function createLsdException(name, uiPriority, qFormat?, semiHidden?, unhideWhenUsed?) {
"use strict"; "use strict";
return [ return [
@ -13,9 +12,9 @@ function createLsdException(name, uiPriority, qFormat?, semiHidden?, unhideWhenU
}, },
}, },
]; ];
} };
export function DefaultStyle() { export const DefaultStyle = () => {
var style = { var style = {
"w:styles": [ "w:styles": [
{ {
@ -208,4 +207,4 @@ export function DefaultStyle() {
}; };
return style; return style;
} };

View File

@ -1,10 +1,10 @@
import { expect } from "chai"; import { expect } from "chai";
import { Formatter } from "@export/formatter"; import { Formatter } from "@export/formatter";
import { EMPTY_OBJECT } from "@file/xml-components";
import * as defaultStyles from "./default-styles"; import * as defaultStyles from "./default-styles";
import { EMPTY_OBJECT } from "@file/xml-components";
describe("Default Styles", () => { describe("Default Styles", () => {
it("HeadingStyle#constructor", () => { it("HeadingStyle#constructor", () => {

View File

@ -1,10 +1,10 @@
import { expect } from "chai"; import { expect } from "chai";
import { EMPTY_OBJECT } from "@file/xml-components";
import { Formatter } from "@export/formatter"; import { Formatter } from "@export/formatter";
import { GridCol, TableGrid } from "./grid"; import { GridCol, TableGrid } from "./grid";
import { EMPTY_OBJECT } from "@file/xml-components";
describe("GridCol", () => { describe("GridCol", () => {
describe("#constructor", () => { describe("#constructor", () => {

View File

@ -10,7 +10,7 @@ export interface ITableCellOptions extends ITableCellPropertiesOptions {
} }
export class TableCell extends XmlComponent { export class TableCell extends XmlComponent {
public constructor(readonly options: ITableCellOptions) { public constructor(public readonly options: ITableCellOptions) {
super("w:tc"); super("w:tc");
this.root.push(new TableCellProperties(options)); this.root.push(new TableCellProperties(options));

View File

@ -1,9 +1,10 @@
import { expect } from "chai"; import { expect } from "chai";
import { Element, xml2js } from "xml-js"; 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 { IContext } from "./base";
import { convertToXmlComponent } from "./imported-xml-component";
const xmlString = ` const xmlString = `
<w:p w:one="value 1" w:two="value 2"> <w:p w:one="value 1" w:two="value 2">

View File

@ -1,6 +1,8 @@
// tslint:disable:no-any // tslint:disable:no-any
import { Element as XmlElement, xml2js } from "xml-js"; 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"; import { IContext } from "./base";
/** /**
@ -8,7 +10,7 @@ import { IContext } from "./base";
* @param element the xml element in json presentation * @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) { switch (element.type) {
case undefined: case undefined:
case "element": case "element":
@ -26,7 +28,7 @@ export function convertToXmlComponent(element: XmlElement): ImportedXmlComponent
default: default:
return undefined; return undefined;
} }
} };
class ImportedXmlComponentAttributes extends XmlAttributeComponent<any> { class ImportedXmlComponentAttributes extends XmlAttributeComponent<any> {
// noop // noop

View File

@ -5,7 +5,6 @@ import { Document } from "./index";
describe("Index", () => { describe("Index", () => {
describe("Document", () => { describe("Document", () => {
it("should instantiate the Document", () => { it("should instantiate the Document", () => {
// tslint:disable-next-line: no-unused-expression
expect( expect(
new Document({ new Document({
sections: [], sections: [],

View File

@ -19,14 +19,12 @@ describe("Utility", () => {
describe("#uniqueNumericId", () => { describe("#uniqueNumericId", () => {
it("should generate a unique incrementing ID", () => { it("should generate a unique incrementing ID", () => {
// tslint:disable-next-line: no-unused-expression
expect(uniqueNumericId()).to.not.be.undefined; expect(uniqueNumericId()).to.not.be.undefined;
}); });
}); });
describe("#uniqueId", () => { describe("#uniqueId", () => {
it("should generate a unique pseudorandom ID", () => { it("should generate a unique pseudorandom ID", () => {
// tslint:disable-next-line: no-unused-expression
expect(uniqueId()).to.not.be.empty; expect(uniqueId()).to.not.be.empty;
}); });
}); });

View File

@ -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 convertInchesToTwip = (inches: number): number => Math.floor(inches * 72 * 20);
export const uniqueNumericId = (): number => { export const uniqueNumericId = (): number => ++currentCount;
return ++currentCount;
};
export const uniqueId = (): string => nanoid().toLowerCase(); export const uniqueId = (): string => nanoid().toLowerCase();

View File

@ -7,63 +7,63 @@
// <xsd:simpleType name="ST_DecimalNumber"> // <xsd:simpleType name="ST_DecimalNumber">
// <xsd:restriction base="xsd:integer"/> // <xsd:restriction base="xsd:integer"/>
// </xsd:simpleType> // </xsd:simpleType>
export function decimalNumber(val: number): number { export const decimalNumber = (val: number): number => {
if (isNaN(val)) { if (isNaN(val)) {
throw new Error(`Invalid value '${val}' specified. Must be an integer.`); throw new Error(`Invalid value '${val}' specified. Must be an integer.`);
} }
return Math.floor(val); return Math.floor(val);
} };
// <xsd:simpleType name="ST_UnsignedDecimalNumber"> // <xsd:simpleType name="ST_UnsignedDecimalNumber">
// <xsd:restriction base="xsd:unsignedLong"/> // <xsd:restriction base="xsd:unsignedLong"/>
// </xsd:simpleType> // </xsd:simpleType>
export function unsignedDecimalNumber(val: number): number { export const unsignedDecimalNumber = (val: number): number => {
const value = decimalNumber(val); const value = decimalNumber(val);
if (value < 0) { if (value < 0) {
throw new Error(`Invalid value '${val}' specified. Must be a positive integer.`); throw new Error(`Invalid value '${val}' specified. Must be a positive integer.`);
} }
return value; return value;
} };
// The xsd:hexBinary type represents binary data as a sequence of binary octets. // 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. // 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 // Lowercase and uppercase letters A through F are permitted. For example, 0FB8 and 0fb8 are two
// equal xsd:hexBinary representations consisting of two octets. // equal xsd:hexBinary representations consisting of two octets.
// http://www.datypic.com/sc/xsd/t-xsd_hexBinary.html // 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; const expectedLength = length * 2;
if (val.length !== expectedLength || isNaN(Number("0x" + val))) { if (val.length !== expectedLength || isNaN(Number("0x" + val))) {
throw new Error(`Invalid hex value '${val}'. Expected ${expectedLength} digit hex value`); throw new Error(`Invalid hex value '${val}'. Expected ${expectedLength} digit hex value`);
} }
return val; return val;
} };
// <xsd:simpleType name="ST_LongHexNumber"> // <xsd:simpleType name="ST_LongHexNumber">
// <xsd:restriction base="xsd:hexBinary"> // <xsd:restriction base="xsd:hexBinary">
// <xsd:length value="4"/> // <xsd:length value="4"/>
// </xsd:restriction> // </xsd:restriction>
// </xsd:simpleType> // </xsd:simpleType>
export function longHexNumber(val: string): string { export const longHexNumber = (val: string): string => {
return hexBinary(val, 4); return hexBinary(val, 4);
} };
// <xsd:simpleType name="ST_ShortHexNumber"> // <xsd:simpleType name="ST_ShortHexNumber">
// <xsd:restriction base="xsd:hexBinary"> // <xsd:restriction base="xsd:hexBinary">
// <xsd:length value="2"/> // <xsd:length value="2"/>
// </xsd:restriction> // </xsd:restriction>
// </xsd:simpleType> // </xsd:simpleType>
export function shortHexNumber(val: string): string { export const shortHexNumber = (val: string): string => {
return hexBinary(val, 2); return hexBinary(val, 2);
} };
// <xsd:simpleType name="ST_UcharHexNumber"> // <xsd:simpleType name="ST_UcharHexNumber">
// <xsd:restriction base="xsd:hexBinary"> // <xsd:restriction base="xsd:hexBinary">
// <xsd:length value="1"/> // <xsd:length value="1"/>
// </xsd:restriction> // </xsd:restriction>
// </xsd:simpleType> // </xsd:simpleType>
export function uCharHexNumber(val: string): string { export const uCharHexNumber = (val: string): string => {
return hexBinary(val, 1); return hexBinary(val, 1);
} };
// <xsd:simpleType name="ST_LongHexNumber"> // <xsd:simpleType name="ST_LongHexNumber">
// <xsd:restriction base="xsd:hexBinary"> // <xsd:restriction base="xsd:hexBinary">
@ -76,7 +76,7 @@ export function uCharHexNumber(val: string): string {
// <xsd:pattern value="-?[0-9]+(\.[0-9]+)?(mm|cm|in|pt|pc|pi)"/> // <xsd:pattern value="-?[0-9]+(\.[0-9]+)?(mm|cm|in|pt|pc|pi)"/>
// </xsd:restriction> // </xsd:restriction>
// </xsd:simpleType> // </xsd:simpleType>
export function universalMeasureValue(val: string): string { export const universalMeasureValue = (val: string): string => {
const unit = val.slice(-2); const unit = val.slice(-2);
if (!universalMeasureUnits.includes(unit)) { if (!universalMeasureUnits.includes(unit)) {
throw new Error(`Invalid unit '${unit}' specified. Valid units are ${universalMeasureUnits.join(", ")}`); 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.`); throw new Error(`Invalid value '${amount}' specified. Expected a valid number.`);
} }
return `${Number(amount)}${unit}`; return `${Number(amount)}${unit}`;
} };
const universalMeasureUnits = ["mm", "cm", "in", "pt", "pc", "pi"]; const universalMeasureUnits = ["mm", "cm", "in", "pt", "pc", "pi"];
// <xsd:simpleType name="ST_PositiveUniversalMeasure"> // <xsd:simpleType name="ST_PositiveUniversalMeasure">
@ -94,13 +94,13 @@ const universalMeasureUnits = ["mm", "cm", "in", "pt", "pc", "pi"];
// <xsd:pattern value="[0-9]+(\.[0-9]+)?(mm|cm|in|pt|pc|pi)"/> // <xsd:pattern value="[0-9]+(\.[0-9]+)?(mm|cm|in|pt|pc|pi)"/>
// </xsd:restriction> // </xsd:restriction>
// </xsd:simpleType> // </xsd:simpleType>
export function positiveUniversalMeasureValue(val: string): string { export const positiveUniversalMeasureValue = (val: string): string => {
const value = universalMeasureValue(val); const value = universalMeasureValue(val);
if (parseFloat(value) < 0) { if (parseFloat(value) < 0) {
throw new Error(`Invalid value '${value}' specified. Expected a positive number.`); throw new Error(`Invalid value '${value}' specified. Expected a positive number.`);
} }
return value; return value;
} };
// <xsd:simpleType name="ST_HexColor"> // <xsd:simpleType name="ST_HexColor">
// <xsd:union memberTypes="ST_HexColorAuto s:ST_HexColorRGB"/> // <xsd:union memberTypes="ST_HexColorAuto s:ST_HexColorRGB"/>
@ -116,7 +116,7 @@ export function positiveUniversalMeasureValue(val: string): string {
// <xsd:length value="3" fixed="true"/> // <xsd:length value="3" fixed="true"/>
// </xsd:restriction> // </xsd:restriction>
// </xsd:simpleType> // </xsd:simpleType>
export function hexColorValue(val: string): string { export const hexColorValue = (val: string): string => {
if (val === "auto") { if (val === "auto") {
return val; 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. // Most clients work with it, but strip it off anyway for strict compliance.
const color = val.charAt(0) === "#" ? val.substring(1) : val; const color = val.charAt(0) === "#" ? val.substring(1) : val;
return hexBinary(color, 3); return hexBinary(color, 3);
} };
// <xsd:simpleType name="ST_SignedTwipsMeasure"> // <xsd:simpleType name="ST_SignedTwipsMeasure">
// <xsd:union memberTypes="xsd:integer s:ST_UniversalMeasure"/> // <xsd:union memberTypes="xsd:integer s:ST_UniversalMeasure"/>
// </xsd:simpleType> // </xsd:simpleType>
export function signedTwipsMeasureValue(val: string | number): string | number { export const signedTwipsMeasureValue = (val: string | number): string | number => {
return typeof val === "string" ? universalMeasureValue(val) : decimalNumber(val); return typeof val === "string" ? universalMeasureValue(val) : decimalNumber(val);
} };
// <xsd:simpleType name="ST_HpsMeasure"> // <xsd:simpleType name="ST_HpsMeasure">
// <xsd:union memberTypes="s:ST_UnsignedDecimalNumber s:ST_PositiveUniversalMeasure"/> // <xsd:union memberTypes="s:ST_UnsignedDecimalNumber s:ST_PositiveUniversalMeasure"/>
// </xsd:simpleType> // </xsd:simpleType>
export function hpsMeasureValue(val: string | number): string | number { export const hpsMeasureValue = (val: string | number): string | number => {
return typeof val === "string" ? positiveUniversalMeasureValue(val) : unsignedDecimalNumber(val); return typeof val === "string" ? positiveUniversalMeasureValue(val) : unsignedDecimalNumber(val);
} };
// <xsd:simpleType name="ST_SignedHpsMeasure"> // <xsd:simpleType name="ST_SignedHpsMeasure">
// <xsd:union memberTypes="xsd:integer s:ST_UniversalMeasure"/> // <xsd:union memberTypes="xsd:integer s:ST_UniversalMeasure"/>
// </xsd:simpleType> // </xsd:simpleType>
export function signedHpsMeasureValue(val: string | number): string | number { export const signedHpsMeasureValue = (val: string | number): string | number => {
return typeof val === "string" ? universalMeasureValue(val) : decimalNumber(val); return typeof val === "string" ? universalMeasureValue(val) : decimalNumber(val);
} };
// <xsd:simpleType name="ST_TwipsMeasure"> // <xsd:simpleType name="ST_TwipsMeasure">
// <xsd:union memberTypes="ST_UnsignedDecimalNumber ST_PositiveUniversalMeasure"/> // <xsd:union memberTypes="ST_UnsignedDecimalNumber ST_PositiveUniversalMeasure"/>
// </xsd:simpleType> // </xsd:simpleType>
export function twipsMeasureValue(val: string | number): string | number { export const twipsMeasureValue = (val: string | number): string | number => {
return typeof val === "string" ? positiveUniversalMeasureValue(val) : unsignedDecimalNumber(val); return typeof val === "string" ? positiveUniversalMeasureValue(val) : unsignedDecimalNumber(val);
} };
// <xsd:simpleType name="ST_Percentage"> // <xsd:simpleType name="ST_Percentage">
// <xsd:restriction base="xsd:string"> // <xsd:restriction base="xsd:string">
// <xsd:pattern value="-?[0-9]+(\.[0-9]+)?%"/> // <xsd:pattern value="-?[0-9]+(\.[0-9]+)?%"/>
// </xsd:restriction> // </xsd:restriction>
// </xsd:simpleType> // </xsd:simpleType>
export function percentageValue(val: string): string { export const percentageValue = (val: string): string => {
if (val.slice(-1) !== "%") { if (val.slice(-1) !== "%") {
throw new Error(`Invalid value '${val}'. Expected percentage value (eg '55%')`); 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.`); throw new Error(`Invalid value '${percent}' specified. Expected a valid number.`);
} }
return `${Number(percent)}%`; return `${Number(percent)}%`;
} };
// <xsd:simpleType name="ST_MeasurementOrPercent"> // <xsd:simpleType name="ST_MeasurementOrPercent">
// <xsd:union memberTypes="ST_DecimalNumberOrPercent s:ST_UniversalMeasure"/> // <xsd:union memberTypes="ST_DecimalNumberOrPercent s:ST_UniversalMeasure"/>
@ -182,7 +182,7 @@ export function percentageValue(val: string): string {
// <xsd:restriction base="xsd:integer"/> // <xsd:restriction base="xsd:integer"/>
// </xsd:simpleType> // </xsd:simpleType>
export function measurementOrPercentValue(val: number | string): number | string { export const measurementOrPercentValue = (val: number | string): number | string => {
if (typeof val === "number") { if (typeof val === "number") {
return decimalNumber(val); return decimalNumber(val);
} }
@ -190,7 +190,7 @@ export function measurementOrPercentValue(val: number | string): number | string
return percentageValue(val); return percentageValue(val);
} }
return universalMeasureValue(val); return universalMeasureValue(val);
} };
// <xsd:simpleType name="ST_EighthPointMeasure"> // <xsd:simpleType name="ST_EighthPointMeasure">
// <xsd:restriction base="s:ST_UnsignedDecimalNumber"/> // <xsd:restriction base="s:ST_UnsignedDecimalNumber"/>
@ -222,6 +222,6 @@ export const pointMeasureValue = unsignedDecimalNumber;
// //
// Luckily, js has this format built in already. See: // Luckily, js has this format built in already. See:
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toISOString // 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(); return val.toISOString();
} };

View File

@ -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"] }]
}
}