refactor: replace tslint with @typescript-eslint/eslint-plugin as tslint will be deprecated in 2020
Some code refactoring and slight rule changes are done in this commit.
This commit is contained in:
parent
8c27962011
commit
a8b9ccf832
103
.eslintrc.json
103
.eslintrc.json
|
@ -1,23 +1,114 @@
|
|||
{
|
||||
"root": true,
|
||||
"extends": ["eslint:recommended", "prettier"],
|
||||
"plugins": ["import"],
|
||||
"parserOptions": {
|
||||
"ecmaVersion": 2019
|
||||
},
|
||||
"env": {
|
||||
"es6": true,
|
||||
"browser": true,
|
||||
"node": true
|
||||
},
|
||||
"parserOptions": {
|
||||
"ecmaVersion": 2018
|
||||
},
|
||||
"rules": {
|
||||
"no-shadow": "error",
|
||||
"no-magic-numbers": ["error", { "ignore": [0, 1, -1, 10, 100] }],
|
||||
"no-magic-numbers": ["error", { "ignore": [-1, 0, 1, 10, 100] }],
|
||||
"no-param-reassign": "error",
|
||||
"prefer-template": "error",
|
||||
"prefer-arrow-callback": "error",
|
||||
"arrow-body-style": ["error", "as-needed"]
|
||||
"arrow-body-style": ["error", "as-needed"],
|
||||
"no-unused-expressions": "error",
|
||||
"prefer-const": "error",
|
||||
"max-classes-per-file": "error",
|
||||
"object-shorthand": ["error", "methods"],
|
||||
"no-useless-rename": "error",
|
||||
|
||||
"import/no-extraneous-dependencies": [
|
||||
"error",
|
||||
{
|
||||
"devDependencies": [
|
||||
"tests/**/*",
|
||||
"mocks/**/*",
|
||||
"src/renderer/**/*",
|
||||
"templates/**/*",
|
||||
"buildfile.js",
|
||||
"forge.config.js"
|
||||
]
|
||||
}
|
||||
],
|
||||
"import/no-default-export": "error"
|
||||
},
|
||||
"overrides": [
|
||||
{
|
||||
"files": ["**/*.ts"],
|
||||
"extends": [
|
||||
"plugin:@typescript-eslint/eslint-recommended",
|
||||
"plugin:@typescript-eslint/recommended",
|
||||
"plugin:@typescript-eslint/recommended-requiring-type-checking",
|
||||
"prettier/@typescript-eslint"
|
||||
],
|
||||
"parser": "@typescript-eslint/parser",
|
||||
"parserOptions": {
|
||||
"project": "./tsconfig.json"
|
||||
},
|
||||
"rules": {
|
||||
"no-console": "error",
|
||||
"no-magic-numbers": "off",
|
||||
|
||||
"@typescript-eslint/no-unused-vars": "off",
|
||||
"@typescript-eslint/no-explicit-any": "off",
|
||||
"@typescript-eslint/typedef": [
|
||||
"error",
|
||||
{
|
||||
"arrowParameter": true,
|
||||
"memberVariableDeclaration": true,
|
||||
"parameter": true,
|
||||
"propertyDeclaration": true
|
||||
}
|
||||
],
|
||||
"@typescript-eslint/explicit-function-return-type": "error",
|
||||
"@typescript-eslint/no-floating-promises": "error",
|
||||
"@typescript-eslint/no-magic-numbers": [
|
||||
"error",
|
||||
{
|
||||
"ignore": [-1, 0, 1],
|
||||
"ignoreNumericLiteralTypes": true,
|
||||
"ignoreReadonlyClassProperties": true,
|
||||
"ignoreEnums": true
|
||||
}
|
||||
],
|
||||
"@typescript-eslint/no-inferrable-types": [
|
||||
"error",
|
||||
{
|
||||
"ignoreParameters": true,
|
||||
"ignoreProperties": true
|
||||
}
|
||||
],
|
||||
"@typescript-eslint/prefer-for-of": "error",
|
||||
"@typescript-eslint/no-empty-function": "off",
|
||||
"@typescript-eslint/interface-name-prefix": [
|
||||
"error",
|
||||
{
|
||||
"prefixWithI": "always"
|
||||
}
|
||||
],
|
||||
"@typescript-eslint/explicit-member-accessibility": "error",
|
||||
"@typescript-eslint/unbound-method": "off",
|
||||
"@typescript-eslint/ban-ts-ignore": "off",
|
||||
"@typescript-eslint/no-use-before-define": "off",
|
||||
"@typescript-eslint/no-misused-promises": [
|
||||
"error",
|
||||
{
|
||||
"checksVoidReturn": false
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"files": ["**/*.d.ts"],
|
||||
"rules": {
|
||||
"import/no-default-export": "off"
|
||||
}
|
||||
},
|
||||
{
|
||||
"files": ["src/renderer/**/*.*"],
|
||||
"parserOptions": {
|
||||
|
|
|
@ -120,7 +120,7 @@ This is also pre-defined in the npm script `typeorm:migrate`.
|
|||
|
||||
### Formatting and Linters
|
||||
|
||||
This project uses [Prettier](https://prettier.io/) for code formatting (and an [.editorconfig](.editorconfig) which you should respect). [ESLint](https://eslint.org/) and [TSLint](https://palantir.github.io/tslint/) ([soon to be integrated into ESLint](https://typescript-eslint.io)) are used for linting.\
|
||||
This project uses [Prettier](https://prettier.io/) for code formatting (and an [.editorconfig](.editorconfig) which you should respect). [ESLint](https://eslint.org/) is used for linting.\
|
||||
The point of these libraries is to make uniform code possible over various editors. If you are not happy with the rules, do not ignore the warnings! Understand why the rule is there (googling helps) and if you decide the rule should not be active, deactivate it. Also think about if the rule should be deactivated everywhere or not, then configure accordingly. Explain your reasoning in the commit body.
|
||||
|
||||
### Testing
|
||||
|
|
|
@ -26,12 +26,11 @@ const ignoreList = [
|
|||
/^\/forge\.config\.js/,
|
||||
/^\/package-lock\.json/,
|
||||
/^\/tsconfig\.json/,
|
||||
/^\/tslint\.json/,
|
||||
/^\/webpack\.config\.js/,
|
||||
|
||||
/^\/node_modules\/\.cache($|\/)/,
|
||||
/^\/src\/.*\.(ts|js\.map)/,
|
||||
/^\/src\/.*tslint\.json/,
|
||||
/^\/src\/.*\.eslintrc\.json/,
|
||||
];
|
||||
|
||||
const name = packageJson.productName;
|
||||
|
|
|
@ -770,6 +770,12 @@
|
|||
"electron-osx-sign": "^0.4.11"
|
||||
}
|
||||
},
|
||||
"@types/eslint-visitor-keys": {
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmjs.org/@types/eslint-visitor-keys/-/eslint-visitor-keys-1.0.0.tgz",
|
||||
"integrity": "sha512-OCutwjDZ4aFS6PB1UZ988C4YgwlBHJd6wCeQqaLdmadZ/7e+w79+hbMUFC1QXDNCmdyoRfAFdm0RypzwR+Qpag==",
|
||||
"dev": true
|
||||
},
|
||||
"@types/fs-extra": {
|
||||
"version": "8.0.1",
|
||||
"resolved": "https://registry.npmjs.org/@types/fs-extra/-/fs-extra-8.0.1.tgz",
|
||||
|
@ -798,6 +804,12 @@
|
|||
}
|
||||
}
|
||||
},
|
||||
"@types/json-schema": {
|
||||
"version": "7.0.3",
|
||||
"resolved": "https://registry.npmjs.org/@types/json-schema/-/json-schema-7.0.3.tgz",
|
||||
"integrity": "sha512-Il2DtDVRGDcqjDtE+rF8iqg1CArehSK84HZJCT7AMITlyXRBpuPhqGLDQMowraqqu1coEaimg4ZOqggt6L6L+A==",
|
||||
"dev": true
|
||||
},
|
||||
"@types/minimist": {
|
||||
"version": "1.2.0",
|
||||
"resolved": "https://registry.npmjs.org/@types/minimist/-/minimist-1.2.0.tgz",
|
||||
|
@ -898,6 +910,114 @@
|
|||
"source-map": "^0.6.1"
|
||||
}
|
||||
},
|
||||
"@typescript-eslint/eslint-plugin": {
|
||||
"version": "2.11.0",
|
||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-2.11.0.tgz",
|
||||
"integrity": "sha512-G2HHA1vpMN0EEbUuWubiCCfd0R3a30BB+UdvnFkxwZIxYEGOrWEXDv8tBFO9f44CWc47Xv9lLM3VSn4ORLI2bA==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"@typescript-eslint/experimental-utils": "2.11.0",
|
||||
"eslint-utils": "^1.4.3",
|
||||
"functional-red-black-tree": "^1.0.1",
|
||||
"regexpp": "^3.0.0",
|
||||
"tsutils": "^3.17.1"
|
||||
},
|
||||
"dependencies": {
|
||||
"regexpp": {
|
||||
"version": "3.0.0",
|
||||
"resolved": "https://registry.npmjs.org/regexpp/-/regexpp-3.0.0.tgz",
|
||||
"integrity": "sha512-Z+hNr7RAVWxznLPuA7DIh8UNX1j9CDrUQxskw9IrBE1Dxue2lyXT+shqEIeLUjrokxIP8CMy1WkjgG3rTsd5/g==",
|
||||
"dev": true
|
||||
},
|
||||
"tsutils": {
|
||||
"version": "3.17.1",
|
||||
"resolved": "https://registry.npmjs.org/tsutils/-/tsutils-3.17.1.tgz",
|
||||
"integrity": "sha512-kzeQ5B8H3w60nFY2g8cJIuH7JDpsALXySGtwGJ0p2LSjLgay3NdIpqq5SoOBe46bKDW2iq25irHCr8wjomUS2g==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"tslib": "^1.8.1"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"@typescript-eslint/experimental-utils": {
|
||||
"version": "2.11.0",
|
||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/experimental-utils/-/experimental-utils-2.11.0.tgz",
|
||||
"integrity": "sha512-YxcA/y0ZJaCc/fB/MClhcDxHI0nOBB7v2/WxBju2cOTanX7jO9ttQq6Fy4yW9UaY5bPd9xL3cun3lDVqk67sPQ==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"@types/json-schema": "^7.0.3",
|
||||
"@typescript-eslint/typescript-estree": "2.11.0",
|
||||
"eslint-scope": "^5.0.0"
|
||||
}
|
||||
},
|
||||
"@typescript-eslint/parser": {
|
||||
"version": "2.11.0",
|
||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-2.11.0.tgz",
|
||||
"integrity": "sha512-DyGXeqhb3moMioEFZIHIp7oXBBh7dEfPTzGrlyP0Mi9ScCra4SWEGs3kPd18mG7Sy9Wy8z88zmrw5tSGL6r/6A==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"@types/eslint-visitor-keys": "^1.0.0",
|
||||
"@typescript-eslint/experimental-utils": "2.11.0",
|
||||
"@typescript-eslint/typescript-estree": "2.11.0",
|
||||
"eslint-visitor-keys": "^1.1.0"
|
||||
}
|
||||
},
|
||||
"@typescript-eslint/typescript-estree": {
|
||||
"version": "2.11.0",
|
||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-2.11.0.tgz",
|
||||
"integrity": "sha512-HGY4+d4MagO6cKMcKfIKaTMxcAv7dEVnji2Zi+vi5VV8uWAM631KjAB5GxFcexMYrwKT0EekRiiGK1/Sd7VFGA==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"debug": "^4.1.1",
|
||||
"eslint-visitor-keys": "^1.1.0",
|
||||
"glob": "^7.1.6",
|
||||
"is-glob": "^4.0.1",
|
||||
"lodash.unescape": "4.0.1",
|
||||
"semver": "^6.3.0",
|
||||
"tsutils": "^3.17.1"
|
||||
},
|
||||
"dependencies": {
|
||||
"debug": {
|
||||
"version": "4.1.1",
|
||||
"resolved": "https://registry.npmjs.org/debug/-/debug-4.1.1.tgz",
|
||||
"integrity": "sha512-pYAIzeRo8J6KPEaJ0VWOh5Pzkbw/RetuzehGM7QRRX5he4fPHx2rdKMB256ehJCkX+XRQm16eZLqLNS8RSZXZw==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"ms": "^2.1.1"
|
||||
}
|
||||
},
|
||||
"glob": {
|
||||
"version": "7.1.6",
|
||||
"resolved": "https://registry.npmjs.org/glob/-/glob-7.1.6.tgz",
|
||||
"integrity": "sha512-LwaxwyZ72Lk7vZINtNNrywX0ZuLyStrdDtabefZKAY5ZGJhVtgdznluResxNmPitE0SAO+O26sWTHeKSI2wMBA==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"fs.realpath": "^1.0.0",
|
||||
"inflight": "^1.0.4",
|
||||
"inherits": "2",
|
||||
"minimatch": "^3.0.4",
|
||||
"once": "^1.3.0",
|
||||
"path-is-absolute": "^1.0.0"
|
||||
}
|
||||
},
|
||||
"semver": {
|
||||
"version": "6.3.0",
|
||||
"resolved": "https://registry.npmjs.org/semver/-/semver-6.3.0.tgz",
|
||||
"integrity": "sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw==",
|
||||
"dev": true
|
||||
},
|
||||
"tsutils": {
|
||||
"version": "3.17.1",
|
||||
"resolved": "https://registry.npmjs.org/tsutils/-/tsutils-3.17.1.tgz",
|
||||
"integrity": "sha512-kzeQ5B8H3w60nFY2g8cJIuH7JDpsALXySGtwGJ0p2LSjLgay3NdIpqq5SoOBe46bKDW2iq25irHCr8wjomUS2g==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"tslib": "^1.8.1"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"@webassemblyjs/ast": {
|
||||
"version": "1.8.5",
|
||||
"resolved": "https://registry.npmjs.org/@webassemblyjs/ast/-/ast-1.8.5.tgz",
|
||||
|
@ -1295,12 +1415,98 @@
|
|||
"integrity": "sha1-z+nYwmYoudxa7MYqn12PHzUsEZU=",
|
||||
"dev": true
|
||||
},
|
||||
"array-includes": {
|
||||
"version": "3.1.0",
|
||||
"resolved": "https://registry.npmjs.org/array-includes/-/array-includes-3.1.0.tgz",
|
||||
"integrity": "sha512-ONOEQoKrvXPKk7Su92Co0YMqYO32FfqJTzkKU9u2UpIXyYZIzLSvpdg4AwvSw4mSUW0czu6inK+zby6Oj6gDjQ==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"define-properties": "^1.1.3",
|
||||
"es-abstract": "^1.17.0-next.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"es-abstract": {
|
||||
"version": "1.17.0-next.1",
|
||||
"resolved": "https://registry.npmjs.org/es-abstract/-/es-abstract-1.17.0-next.1.tgz",
|
||||
"integrity": "sha512-7MmGr03N7Rnuid6+wyhD9sHNE2n4tFSwExnU2lQl3lIo2ShXWGePY80zYaoMOmILWv57H0amMjZGHNzzGG70Rw==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"es-to-primitive": "^1.2.1",
|
||||
"function-bind": "^1.1.1",
|
||||
"has": "^1.0.3",
|
||||
"has-symbols": "^1.0.1",
|
||||
"is-callable": "^1.1.4",
|
||||
"is-regex": "^1.0.4",
|
||||
"object-inspect": "^1.7.0",
|
||||
"object-keys": "^1.1.1",
|
||||
"object.assign": "^4.1.0",
|
||||
"string.prototype.trimleft": "^2.1.0",
|
||||
"string.prototype.trimright": "^2.1.0"
|
||||
}
|
||||
},
|
||||
"has-symbols": {
|
||||
"version": "1.0.1",
|
||||
"resolved": "https://registry.npmjs.org/has-symbols/-/has-symbols-1.0.1.tgz",
|
||||
"integrity": "sha512-PLcsoqu++dmEIZB+6totNFKq/7Do+Z0u4oT0zKOJNl3lYK6vGwwu2hjHs+68OEZbTjiUE9bgOABXbP/GvrS0Kg==",
|
||||
"dev": true
|
||||
},
|
||||
"object-keys": {
|
||||
"version": "1.1.1",
|
||||
"resolved": "https://registry.npmjs.org/object-keys/-/object-keys-1.1.1.tgz",
|
||||
"integrity": "sha512-NuAESUOUMrlIXOfHKzD6bpPu3tYt3xvjNdRIQ+FeT0lNb4K8WR70CaDxhuNguS2XG+GjkyMwOzsN5ZktImfhLA==",
|
||||
"dev": true
|
||||
}
|
||||
}
|
||||
},
|
||||
"array-unique": {
|
||||
"version": "0.3.2",
|
||||
"resolved": "https://registry.npmjs.org/array-unique/-/array-unique-0.3.2.tgz",
|
||||
"integrity": "sha1-qJS3XUvE9s1nnvMkSp/Y9Gri1Cg=",
|
||||
"dev": true
|
||||
},
|
||||
"array.prototype.flat": {
|
||||
"version": "1.2.3",
|
||||
"resolved": "https://registry.npmjs.org/array.prototype.flat/-/array.prototype.flat-1.2.3.tgz",
|
||||
"integrity": "sha512-gBlRZV0VSmfPIeWfuuy56XZMvbVfbEUnOXUvt3F/eUUUSyzlgLxhEX4YAEpxNAogRGehPSnfXyPtYyKAhkzQhQ==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"define-properties": "^1.1.3",
|
||||
"es-abstract": "^1.17.0-next.1"
|
||||
},
|
||||
"dependencies": {
|
||||
"es-abstract": {
|
||||
"version": "1.17.0-next.1",
|
||||
"resolved": "https://registry.npmjs.org/es-abstract/-/es-abstract-1.17.0-next.1.tgz",
|
||||
"integrity": "sha512-7MmGr03N7Rnuid6+wyhD9sHNE2n4tFSwExnU2lQl3lIo2ShXWGePY80zYaoMOmILWv57H0amMjZGHNzzGG70Rw==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"es-to-primitive": "^1.2.1",
|
||||
"function-bind": "^1.1.1",
|
||||
"has": "^1.0.3",
|
||||
"has-symbols": "^1.0.1",
|
||||
"is-callable": "^1.1.4",
|
||||
"is-regex": "^1.0.4",
|
||||
"object-inspect": "^1.7.0",
|
||||
"object-keys": "^1.1.1",
|
||||
"object.assign": "^4.1.0",
|
||||
"string.prototype.trimleft": "^2.1.0",
|
||||
"string.prototype.trimright": "^2.1.0"
|
||||
}
|
||||
},
|
||||
"has-symbols": {
|
||||
"version": "1.0.1",
|
||||
"resolved": "https://registry.npmjs.org/has-symbols/-/has-symbols-1.0.1.tgz",
|
||||
"integrity": "sha512-PLcsoqu++dmEIZB+6totNFKq/7Do+Z0u4oT0zKOJNl3lYK6vGwwu2hjHs+68OEZbTjiUE9bgOABXbP/GvrS0Kg==",
|
||||
"dev": true
|
||||
},
|
||||
"object-keys": {
|
||||
"version": "1.1.1",
|
||||
"resolved": "https://registry.npmjs.org/object-keys/-/object-keys-1.1.1.tgz",
|
||||
"integrity": "sha512-NuAESUOUMrlIXOfHKzD6bpPu3tYt3xvjNdRIQ+FeT0lNb4K8WR70CaDxhuNguS2XG+GjkyMwOzsN5ZktImfhLA==",
|
||||
"dev": true
|
||||
}
|
||||
}
|
||||
},
|
||||
"asar": {
|
||||
"version": "2.0.1",
|
||||
"resolved": "https://registry.npmjs.org/asar/-/asar-2.0.1.tgz",
|
||||
|
@ -1739,12 +1945,6 @@
|
|||
"integrity": "sha1-JuYe0UIvtw3ULm42cp7VHYVf6Nk=",
|
||||
"dev": true
|
||||
},
|
||||
"builtin-modules": {
|
||||
"version": "1.1.1",
|
||||
"resolved": "https://registry.npmjs.org/builtin-modules/-/builtin-modules-1.1.1.tgz",
|
||||
"integrity": "sha1-Jw8HbFpywC9bZaR9+Uxf46J4iS8=",
|
||||
"dev": true
|
||||
},
|
||||
"builtin-status-codes": {
|
||||
"version": "3.0.0",
|
||||
"resolved": "https://registry.npmjs.org/builtin-status-codes/-/builtin-status-codes-3.0.0.tgz",
|
||||
|
@ -2490,6 +2690,12 @@
|
|||
"integrity": "sha1-wguW2MYXdIqvHBYCF2DNJ/y4y3U=",
|
||||
"dev": true
|
||||
},
|
||||
"contains-path": {
|
||||
"version": "0.1.0",
|
||||
"resolved": "https://registry.npmjs.org/contains-path/-/contains-path-0.1.0.tgz",
|
||||
"integrity": "sha1-/ozxhP9mcLa67wGp1IYaXL7EEgo=",
|
||||
"dev": true
|
||||
},
|
||||
"convert-source-map": {
|
||||
"version": "1.6.0",
|
||||
"resolved": "https://registry.npmjs.org/convert-source-map/-/convert-source-map-1.6.0.tgz",
|
||||
|
@ -3634,6 +3840,168 @@
|
|||
}
|
||||
}
|
||||
},
|
||||
"eslint-import-resolver-node": {
|
||||
"version": "0.3.2",
|
||||
"resolved": "https://registry.npmjs.org/eslint-import-resolver-node/-/eslint-import-resolver-node-0.3.2.tgz",
|
||||
"integrity": "sha512-sfmTqJfPSizWu4aymbPr4Iidp5yKm8yDkHp+Ir3YiTHiiDfxh69mOUsmiqW6RZ9zRXFaF64GtYmN7e+8GHBv6Q==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"debug": "^2.6.9",
|
||||
"resolve": "^1.5.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"debug": {
|
||||
"version": "2.6.9",
|
||||
"resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz",
|
||||
"integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"ms": "2.0.0"
|
||||
}
|
||||
},
|
||||
"ms": {
|
||||
"version": "2.0.0",
|
||||
"resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz",
|
||||
"integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=",
|
||||
"dev": true
|
||||
}
|
||||
}
|
||||
},
|
||||
"eslint-module-utils": {
|
||||
"version": "2.5.0",
|
||||
"resolved": "https://registry.npmjs.org/eslint-module-utils/-/eslint-module-utils-2.5.0.tgz",
|
||||
"integrity": "sha512-kCo8pZaNz2dsAW7nCUjuVoI11EBXXpIzfNxmaoLhXoRDOnqXLC4iSGVRdZPhOitfbdEfMEfKOiENaK6wDPZEGw==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"debug": "^2.6.9",
|
||||
"pkg-dir": "^2.0.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"debug": {
|
||||
"version": "2.6.9",
|
||||
"resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz",
|
||||
"integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"ms": "2.0.0"
|
||||
}
|
||||
},
|
||||
"find-up": {
|
||||
"version": "2.1.0",
|
||||
"resolved": "https://registry.npmjs.org/find-up/-/find-up-2.1.0.tgz",
|
||||
"integrity": "sha1-RdG35QbHF93UgndaK3eSCjwMV6c=",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"locate-path": "^2.0.0"
|
||||
}
|
||||
},
|
||||
"locate-path": {
|
||||
"version": "2.0.0",
|
||||
"resolved": "https://registry.npmjs.org/locate-path/-/locate-path-2.0.0.tgz",
|
||||
"integrity": "sha1-K1aLJl7slExtnA3pw9u7ygNUzY4=",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"p-locate": "^2.0.0",
|
||||
"path-exists": "^3.0.0"
|
||||
}
|
||||
},
|
||||
"ms": {
|
||||
"version": "2.0.0",
|
||||
"resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz",
|
||||
"integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=",
|
||||
"dev": true
|
||||
},
|
||||
"p-limit": {
|
||||
"version": "1.3.0",
|
||||
"resolved": "https://registry.npmjs.org/p-limit/-/p-limit-1.3.0.tgz",
|
||||
"integrity": "sha512-vvcXsLAJ9Dr5rQOPk7toZQZJApBl2K4J6dANSsEuh6QI41JYcsS/qhTGa9ErIUUgK3WNQoJYvylxvjqmiqEA9Q==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"p-try": "^1.0.0"
|
||||
}
|
||||
},
|
||||
"p-locate": {
|
||||
"version": "2.0.0",
|
||||
"resolved": "https://registry.npmjs.org/p-locate/-/p-locate-2.0.0.tgz",
|
||||
"integrity": "sha1-IKAQOyIqcMj9OcwuWAaA893l7EM=",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"p-limit": "^1.1.0"
|
||||
}
|
||||
},
|
||||
"p-try": {
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmjs.org/p-try/-/p-try-1.0.0.tgz",
|
||||
"integrity": "sha1-y8ec26+P1CKOE/Yh8rGiN8GyB7M=",
|
||||
"dev": true
|
||||
},
|
||||
"pkg-dir": {
|
||||
"version": "2.0.0",
|
||||
"resolved": "https://registry.npmjs.org/pkg-dir/-/pkg-dir-2.0.0.tgz",
|
||||
"integrity": "sha1-9tXREJ4Z1j7fQo4L1X4Sd3YVM0s=",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"find-up": "^2.1.0"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"eslint-plugin-import": {
|
||||
"version": "2.19.1",
|
||||
"resolved": "https://registry.npmjs.org/eslint-plugin-import/-/eslint-plugin-import-2.19.1.tgz",
|
||||
"integrity": "sha512-x68131aKoCZlCae7rDXKSAQmbT5DQuManyXo2sK6fJJ0aK5CWAkv6A6HJZGgqC8IhjQxYPgo6/IY4Oz8AFsbBw==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"array-includes": "^3.0.3",
|
||||
"array.prototype.flat": "^1.2.1",
|
||||
"contains-path": "^0.1.0",
|
||||
"debug": "^2.6.9",
|
||||
"doctrine": "1.5.0",
|
||||
"eslint-import-resolver-node": "^0.3.2",
|
||||
"eslint-module-utils": "^2.4.1",
|
||||
"has": "^1.0.3",
|
||||
"minimatch": "^3.0.4",
|
||||
"object.values": "^1.1.0",
|
||||
"read-pkg-up": "^2.0.0",
|
||||
"resolve": "^1.12.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"debug": {
|
||||
"version": "2.6.9",
|
||||
"resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz",
|
||||
"integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"ms": "2.0.0"
|
||||
}
|
||||
},
|
||||
"doctrine": {
|
||||
"version": "1.5.0",
|
||||
"resolved": "https://registry.npmjs.org/doctrine/-/doctrine-1.5.0.tgz",
|
||||
"integrity": "sha1-N53Ocw9hZvds76TmcHoVmwLFpvo=",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"esutils": "^2.0.2",
|
||||
"isarray": "^1.0.0"
|
||||
}
|
||||
},
|
||||
"ms": {
|
||||
"version": "2.0.0",
|
||||
"resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz",
|
||||
"integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=",
|
||||
"dev": true
|
||||
},
|
||||
"resolve": {
|
||||
"version": "1.13.1",
|
||||
"resolved": "https://registry.npmjs.org/resolve/-/resolve-1.13.1.tgz",
|
||||
"integrity": "sha512-CxqObCX8K8YtAhOBRg+lrcdn+LK+WYOS8tSjqSFbjtrI5PnS63QPhZl4+yKfrU9tdsbMu9Anr/amegT87M9Z6w==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"path-parse": "^1.0.6"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"eslint-scope": {
|
||||
"version": "5.0.0",
|
||||
"resolved": "https://registry.npmjs.org/eslint-scope/-/eslint-scope-5.0.0.tgz",
|
||||
|
@ -5756,6 +6124,12 @@
|
|||
"lodash._reinterpolate": "^3.0.0"
|
||||
}
|
||||
},
|
||||
"lodash.unescape": {
|
||||
"version": "4.0.1",
|
||||
"resolved": "https://registry.npmjs.org/lodash.unescape/-/lodash.unescape-4.0.1.tgz",
|
||||
"integrity": "sha1-vyJJiGzlFM2hEvrpIYzcBlIR/Jw=",
|
||||
"dev": true
|
||||
},
|
||||
"log-symbols": {
|
||||
"version": "3.0.0",
|
||||
"resolved": "https://registry.npmjs.org/log-symbols/-/log-symbols-3.0.0.tgz",
|
||||
|
@ -6805,6 +7179,18 @@
|
|||
"isobject": "^3.0.1"
|
||||
}
|
||||
},
|
||||
"object.values": {
|
||||
"version": "1.1.0",
|
||||
"resolved": "https://registry.npmjs.org/object.values/-/object.values-1.1.0.tgz",
|
||||
"integrity": "sha512-8mf0nKLAoFX6VlNVdhGj31SVYpaNFtUnuoOXWyFEstsWRgU837AK+JYM0iAxwkSzGRbwn8cbFmgbyxj1j4VbXg==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"define-properties": "^1.1.3",
|
||||
"es-abstract": "^1.12.0",
|
||||
"function-bind": "^1.1.1",
|
||||
"has": "^1.0.3"
|
||||
}
|
||||
},
|
||||
"once": {
|
||||
"version": "1.4.0",
|
||||
"resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz",
|
||||
|
@ -9184,56 +9570,6 @@
|
|||
"resolved": "https://registry.npmjs.org/tslib/-/tslib-1.10.0.tgz",
|
||||
"integrity": "sha512-qOebF53frne81cf0S9B41ByenJ3/IuH8yJKngAX35CmiZySA0khhkovshKK+jGCaMnVomla7gVlIcc3EvKPbTQ=="
|
||||
},
|
||||
"tslint": {
|
||||
"version": "5.20.1",
|
||||
"resolved": "https://registry.npmjs.org/tslint/-/tslint-5.20.1.tgz",
|
||||
"integrity": "sha512-EcMxhzCFt8k+/UP5r8waCf/lzmeSyVlqxqMEDQE7rWYiQky8KpIBz1JAoYXfROHrPZ1XXd43q8yQnULOLiBRQg==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"@babel/code-frame": "^7.0.0",
|
||||
"builtin-modules": "^1.1.1",
|
||||
"chalk": "^2.3.0",
|
||||
"commander": "^2.12.1",
|
||||
"diff": "^4.0.1",
|
||||
"glob": "^7.1.1",
|
||||
"js-yaml": "^3.13.1",
|
||||
"minimatch": "^3.0.4",
|
||||
"mkdirp": "^0.5.1",
|
||||
"resolve": "^1.3.2",
|
||||
"semver": "^5.3.0",
|
||||
"tslib": "^1.8.0",
|
||||
"tsutils": "^2.29.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"commander": {
|
||||
"version": "2.20.3",
|
||||
"resolved": "https://registry.npmjs.org/commander/-/commander-2.20.3.tgz",
|
||||
"integrity": "sha512-GpVkmM8vF2vQUkj2LvZmD35JxeJOLCwJ9cUkugyk2nuhbv3+mJvpLYYt+0+USMxE+oj+ey/lJEnhZw75x/OMcQ==",
|
||||
"dev": true
|
||||
},
|
||||
"diff": {
|
||||
"version": "4.0.1",
|
||||
"resolved": "https://registry.npmjs.org/diff/-/diff-4.0.1.tgz",
|
||||
"integrity": "sha512-s2+XdvhPCOF01LRQBC8hf4vhbVmI2CGS5aZnxLJlT5FtdhPCDFq80q++zK2KlrVorVDdL5BOGZ/VfLrVtYNF+Q==",
|
||||
"dev": true
|
||||
}
|
||||
}
|
||||
},
|
||||
"tslint-config-prettier": {
|
||||
"version": "1.18.0",
|
||||
"resolved": "https://registry.npmjs.org/tslint-config-prettier/-/tslint-config-prettier-1.18.0.tgz",
|
||||
"integrity": "sha512-xPw9PgNPLG3iKRxmK7DWr+Ea/SzrvfHtjFt5LBl61gk2UBG/DB9kCXRjv+xyIU1rUtnayLeMUVJBcMX8Z17nDg==",
|
||||
"dev": true
|
||||
},
|
||||
"tsutils": {
|
||||
"version": "2.29.0",
|
||||
"resolved": "https://registry.npmjs.org/tsutils/-/tsutils-2.29.0.tgz",
|
||||
"integrity": "sha512-g5JVHCIJwzfISaXpXE1qvNalca5Jwob6FjI4AoPlqMusJ6ftFE7IkkFoMhVLRgK+4Kx3gkzb8UZK5t5yTTvEmA==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"tslib": "^1.8.1"
|
||||
}
|
||||
},
|
||||
"tty-browserify": {
|
||||
"version": "0.0.0",
|
||||
"resolved": "https://registry.npmjs.org/tty-browserify/-/tty-browserify-0.0.0.tgz",
|
||||
|
|
17
package.json
17
package.json
|
@ -30,15 +30,9 @@
|
|||
"test": "npm run test:before && mocha && npm run test:after",
|
||||
"coverage:fast": "nyc npm run test:fast",
|
||||
"coverage": "nyc npm run test",
|
||||
"lint:check": "npm run eslint:check && npm run tslint:check",
|
||||
"lint": "npm run eslint && npm run tslint",
|
||||
"lint:fix": "npm run eslint:fix && npm run tslint:fix",
|
||||
"eslint:check": "eslint --print-config forge.config.js | eslint-config-prettier-check",
|
||||
"eslint": "eslint .",
|
||||
"eslint:fix": "eslint . --fix",
|
||||
"tslint:check": "tslint-config-prettier-check ./tslint.json",
|
||||
"tslint": "tslint -p tsconfig.json -t stylish",
|
||||
"tslint:fix": "tslint -p tsconfig.json --fix",
|
||||
"lint:check": "eslint --print-config forge.config.js | eslint-config-prettier-check",
|
||||
"lint": "eslint ./**/*.{js,ts} --max-warnings 1",
|
||||
"lint:fix": "eslint . --fix",
|
||||
"prettier": "prettier --ignore-path .gitignore -c **/*.{html,handlebars,json,{c,sc,sa,le}ss,yml,svelte,md,ts,js}",
|
||||
"prettier:fix": "prettier --ignore-path .gitignore --write **/*.{html,handlebars,json,{c,sc,sa,le}ss,yml,svelte,md,ts,js}",
|
||||
"fix": "npm run lint:check && npm run lint:fix && npm run prettier:fix",
|
||||
|
@ -69,6 +63,8 @@
|
|||
"@types/sinon": "^7.5.1",
|
||||
"@types/webdriverio": "^4.13.3",
|
||||
"@types/webpack": "^4.41.0",
|
||||
"@typescript-eslint/eslint-plugin": "^2.11.0",
|
||||
"@typescript-eslint/parser": "^2.11.0",
|
||||
"chai": "^4.2.0",
|
||||
"chokidar": "^3.3.0",
|
||||
"concurrently": "^5.0.1",
|
||||
|
@ -76,6 +72,7 @@
|
|||
"electron-rebuild": "^1.8.8",
|
||||
"eslint": "^6.7.2",
|
||||
"eslint-config-prettier": "^6.7.0",
|
||||
"eslint-plugin-import": "^2.19.1",
|
||||
"fast-check": "^1.20.1",
|
||||
"handlebars": "^4.5.3",
|
||||
"husky": "^3.1.0",
|
||||
|
@ -90,8 +87,6 @@
|
|||
"svelte": "^3.16.4",
|
||||
"svelte-loader": "^2.13.6",
|
||||
"ts-loader": "^6.2.1",
|
||||
"tslint": "^5.20.1",
|
||||
"tslint-config-prettier": "latest",
|
||||
"typescript": "^3.7.3",
|
||||
"webpack": "^4.41.2",
|
||||
"webpack-cli": "^3.3.10"
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
// eslint-disable-next-line import/no-extraneous-dependencies
|
||||
import { app, BrowserWindow } from 'electron';
|
||||
import BrowserWindowConstructorOptions = Electron.BrowserWindowConstructorOptions;
|
||||
import os from 'os';
|
||||
|
@ -9,7 +10,7 @@ import * as session from './main/services/session';
|
|||
|
||||
export let mainWindow: Electron.BrowserWindow;
|
||||
|
||||
export let appPath = path.resolve(app.getPath('userData'), `${packageJson.version}${isDev() ? '-dev' : ''}`);
|
||||
export const appPath = path.resolve(app.getPath('userData'), `${packageJson.version}${isDev() ? '-dev' : ''}`);
|
||||
|
||||
async function createWindow(): Promise<void> {
|
||||
session.setHeaders();
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
// eslint-disable-next-line import/no-extraneous-dependencies
|
||||
import { ipcMain } from 'electron';
|
||||
import IpcMainEvent = Electron.IpcMainEvent;
|
||||
import { mainWindow } from '../../main';
|
||||
|
@ -30,10 +31,6 @@ export const ipcServer: IIpcServer = {
|
|||
},
|
||||
};
|
||||
|
||||
ipcServer.answer(IpcChannels.LOGIN, (credentials: ICredentials) => {
|
||||
return login(credentials.name, credentials.password);
|
||||
});
|
||||
ipcServer.answer(IpcChannels.LOGIN, (credentials: ICredentials) => login(credentials.name, credentials.password));
|
||||
|
||||
ipcServer.answer(IpcChannels.LOGGED_IN, () => {
|
||||
return isLoggedIn();
|
||||
});
|
||||
ipcServer.answer(IpcChannels.LOGGED_IN, isLoggedIn);
|
||||
|
|
|
@ -0,0 +1,6 @@
|
|||
{
|
||||
"extends": ["../../../.eslintrc.json"],
|
||||
"rules": {
|
||||
"max-classes-per-file": "off"
|
||||
}
|
||||
}
|
|
@ -1,6 +0,0 @@
|
|||
{
|
||||
"extends": ["../../../tslint.json"],
|
||||
"rules": {
|
||||
"max-classes-per-file": false
|
||||
}
|
||||
}
|
|
@ -0,0 +1,8 @@
|
|||
{
|
||||
"extends": ["../../../.eslintrc.json"],
|
||||
"rules": {
|
||||
"@typescript-eslint/class-name-casing": "off",
|
||||
"@typescript-eslint/typedef": "off",
|
||||
"@typescript-eslint/explicit-member-accessibility": "off"
|
||||
}
|
||||
}
|
|
@ -1,8 +0,0 @@
|
|||
{
|
||||
"extends": ["../../../../tslint.json"],
|
||||
"rules": {
|
||||
"class-name": false,
|
||||
"member-access": false,
|
||||
"typedef": false
|
||||
}
|
||||
}
|
|
@ -1,5 +1,4 @@
|
|||
import path from 'path';
|
||||
import 'reflect-metadata';
|
||||
import { Connection, createConnection as ormCreateConnection } from 'typeorm';
|
||||
import { SqliteConnectionOptions } from 'typeorm/driver/sqlite/SqliteConnectionOptions';
|
||||
import { appPath } from '../../main';
|
||||
|
@ -37,17 +36,12 @@ function createConnection(database: Databases): Promise<Connection> {
|
|||
connections[database] = connection;
|
||||
return connection.runMigrations();
|
||||
})
|
||||
.then(() => {
|
||||
return connections[database];
|
||||
});
|
||||
.then(() => connections[database]);
|
||||
}
|
||||
|
||||
export function getConnection(database: Databases): Promise<Connection> {
|
||||
if (connections[database] === undefined) {
|
||||
return createConnection(database).then((connection: Connection) => {
|
||||
return connection;
|
||||
});
|
||||
} else {
|
||||
return Promise.resolve(connections[database]);
|
||||
return createConnection(database);
|
||||
}
|
||||
return Promise.resolve(connections[database]);
|
||||
}
|
||||
|
|
|
@ -28,9 +28,7 @@ interface ILoginParams extends ILoginMeta, ILoginAuth {}
|
|||
|
||||
function getNHentai(path: string): Promise<Document> {
|
||||
return fetch(`${url}${path}`)
|
||||
.then((res: Response) => {
|
||||
return res.text();
|
||||
})
|
||||
.then((res: Response) => res.text())
|
||||
.then((text: string) => {
|
||||
const { document } = new JSDOM(text).window;
|
||||
return document;
|
||||
|
@ -56,12 +54,12 @@ function postNHentai(path: string, requestInit: RequestInit = {}): Promise<Respo
|
|||
|
||||
function getLoginMeta(): Promise<ILoginMeta> {
|
||||
return getNHentai(paths.login).then((document: Document) => {
|
||||
// tslint:disable-next-line: prefer-for-of
|
||||
// eslint-disable-next-line @typescript-eslint/prefer-for-of
|
||||
for (let i = 0; i < document.forms.length; i++) {
|
||||
const form: HTMLFormElement = document.forms[i];
|
||||
const valueStore: ILoginMeta = {};
|
||||
let isLoginForm = false;
|
||||
// tslint:disable-next-line: prefer-for-of
|
||||
// eslint-disable-next-line @typescript-eslint/prefer-for-of
|
||||
for (let j = 0; j < form.elements.length; j++) {
|
||||
const input = form.elements[j];
|
||||
const name = input.getAttribute('name');
|
||||
|
@ -81,9 +79,7 @@ function getLoginMeta(): Promise<ILoginMeta> {
|
|||
}
|
||||
|
||||
export function isLoggedIn(): Promise<boolean> {
|
||||
return fetch(`${url}${paths.favorites}`, { redirect: 'manual' }).then((res: Response) => {
|
||||
return res.status === HttpCode.OK;
|
||||
});
|
||||
return fetch(`${url}${paths.favorites}`, { redirect: 'manual' }).then((res: Response) => res.status === HttpCode.OK);
|
||||
}
|
||||
|
||||
export function login(name: string, password: string): Promise<void> {
|
||||
|
@ -92,8 +88,8 @@ export function login(name: string, password: string): Promise<void> {
|
|||
const loginParams: ILoginParams = {
|
||||
...meta,
|
||||
...{
|
||||
username_or_email: name,
|
||||
password,
|
||||
[usernameInput]: name,
|
||||
[passwordInput]: password,
|
||||
},
|
||||
};
|
||||
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
// eslint-disable-next-line import/no-extraneous-dependencies
|
||||
import { session } from 'electron';
|
||||
import OnHeadersReceivedDetails = Electron.OnHeadersReceivedDetails;
|
||||
|
||||
|
|
|
@ -36,34 +36,27 @@ function writeUnsave(): Promise<void> {
|
|||
}
|
||||
|
||||
function read(): Promise<void> {
|
||||
return initDir().then(() => {
|
||||
return fs.readFile(options.path).then((buf: Buffer) => {
|
||||
return initDir().then(() =>
|
||||
fs.readFile(options.path).then((buf: Buffer) => {
|
||||
store = JSON.parse(buf.toString());
|
||||
synced = true;
|
||||
});
|
||||
});
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
function write(): Promise<void> {
|
||||
return initDir().then(() => {
|
||||
return writeUnsave().then(() => {
|
||||
return initDir().then(() =>
|
||||
writeUnsave().then(() => {
|
||||
synced = false;
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function get(key: StoreKeys): any {
|
||||
return store[key];
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
export function load(key: StoreKeys): Promise<any> {
|
||||
if (synced) {
|
||||
return Promise.resolve(get(key));
|
||||
} else {
|
||||
return read().then(() => {
|
||||
return Promise.resolve(get(key));
|
||||
});
|
||||
return Promise.resolve(store[key]);
|
||||
}
|
||||
return read().then(() => Promise.resolve(store[key]));
|
||||
}
|
||||
|
||||
export function save(key: StoreKeys, data: any): Promise<void> {
|
||||
|
|
|
@ -35,7 +35,9 @@ export function fetch(url: string, requestInit: RequestInit = {}): Promise<Respo
|
|||
},
|
||||
};
|
||||
return nodeFetch(url, cookiedInit).then((res: Response) => {
|
||||
setCookies(res.headers.raw()['set-cookie'], url).catch();
|
||||
setCookies(res.headers.raw()['set-cookie'], url).catch((reason: any) => {
|
||||
throwError(new RenaiError(Errors.ECOOKIESAVEFAIL, reason));
|
||||
});
|
||||
return res;
|
||||
});
|
||||
});
|
||||
|
|
|
@ -11,8 +11,6 @@ export const loggedIn = {
|
|||
});
|
||||
},
|
||||
fetchLogin(credentials: ICredentials): Promise<void> {
|
||||
return api.login(credentials).then(() => {
|
||||
return this.fetchIsLoggedIn();
|
||||
});
|
||||
return api.login(credentials).then(this.fetchIsLoggedIn);
|
||||
},
|
||||
};
|
||||
|
|
|
@ -13,7 +13,7 @@ const messages = {
|
|||
};
|
||||
|
||||
export class RenaiError extends Error {
|
||||
constructor(eno: Errors, msg: string = '') {
|
||||
public constructor(eno: Errors, msg: string = '') {
|
||||
super(`${messages[eno]}.${msg ? ` ${msg}` : ''}`);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,11 @@
|
|||
{
|
||||
"extends": ["../.eslintrc.json"],
|
||||
"rules": {
|
||||
"no-unused-expressions": "off",
|
||||
|
||||
"@typescript-eslint/no-magic-numbers": "off",
|
||||
"@typescript-eslint/typedef": "off",
|
||||
"@typescript-eslint/no-var-requires": "off",
|
||||
"@typescript-eslint/explicit-function-return-type": "off"
|
||||
}
|
||||
}
|
|
@ -14,7 +14,7 @@ describe('Development Mode Service', () => {
|
|||
rewiremock.disable();
|
||||
});
|
||||
|
||||
it('correctly identifies the development process argument', async () => {
|
||||
it('correctly identifies the development process argument', () => {
|
||||
process.argv.push('--dev');
|
||||
expect(isDev()).to.be.true;
|
||||
process.argv = process.argv.filter((value) => value !== '--dev');
|
||||
|
|
|
@ -26,11 +26,10 @@ describe('Store Service', function() {
|
|||
}
|
||||
});
|
||||
|
||||
it('creates a store directory', () => {
|
||||
return save(StoreKeys.COOKIES, { some: 'data' }).then(() => {
|
||||
it('creates a store directory', () =>
|
||||
save(StoreKeys.COOKIES, { some: 'data' }).then(() => {
|
||||
expect(fs.existsSync(storeDirectory)).to.be.true;
|
||||
});
|
||||
});
|
||||
}));
|
||||
|
||||
it('loads saved data', () => {
|
||||
const testData: any = {
|
||||
|
@ -49,9 +48,7 @@ describe('Store Service', function() {
|
|||
};
|
||||
const expectedJson = JSON.stringify(testData);
|
||||
return save(StoreKeys.COOKIES, testData)
|
||||
.then(() => {
|
||||
return load(StoreKeys.COOKIES);
|
||||
})
|
||||
.then(() => load(StoreKeys.COOKIES))
|
||||
.then((data) => {
|
||||
expect(JSON.stringify(data)).to.equal(expectedJson, 'store does not save and load data correctly');
|
||||
return load(StoreKeys.COOKIES);
|
||||
|
|
|
@ -16,13 +16,9 @@ describe('Web Crawler', function() {
|
|||
before(() => {
|
||||
rewiremock.enable();
|
||||
|
||||
storeMock.mock.load(() => {
|
||||
return Promise.resolve(new CookieJar().serializeSync());
|
||||
});
|
||||
storeMock.mock.load(() => Promise.resolve(new CookieJar().serializeSync()));
|
||||
|
||||
storeMock.mock.save(() => {
|
||||
return Promise.resolve();
|
||||
});
|
||||
storeMock.mock.save(() => Promise.resolve());
|
||||
});
|
||||
|
||||
beforeEach(() => {
|
||||
|
|
|
@ -20,7 +20,7 @@ describe('Frontend Utils', function() {
|
|||
|
||||
this.className = fc
|
||||
.stringOf(fc.oneof(alpha, alphaNumeric, fc.constantFrom('-', '_')))
|
||||
.filter((name: string) => !!name.charAt(0).match(/[a-zA-Z]/));
|
||||
.filter((name: string) => /[a-zA-Z]/.test(name.charAt(0)));
|
||||
this.anything = fc
|
||||
.anything({
|
||||
maxDepth: 1,
|
||||
|
@ -70,10 +70,12 @@ describe('Frontend Utils', function() {
|
|||
it('compiles an object into an html style property', () => {
|
||||
const styleObjectArbitrary = fc.object({
|
||||
maxDepth: 0,
|
||||
key: fc.string(1, 10).filter((str) => !str.match(/\s/)),
|
||||
key: fc.string(1, 10).filter((str) => !/\s/.test(str)),
|
||||
values: [fc.string(), fc.integer(), fc.boolean()],
|
||||
});
|
||||
|
||||
/\s/g.exec('');
|
||||
|
||||
fc.assert(
|
||||
fc.property(styleObjectArbitrary, (styleObject: any) => {
|
||||
const expectedString = Object.keys(styleObject)
|
||||
|
@ -84,9 +86,7 @@ describe('Frontend Utils', function() {
|
|||
}
|
||||
return typeof value === 'number';
|
||||
})
|
||||
.map((key) => {
|
||||
return `${key}:${styleObject[key]}`;
|
||||
})
|
||||
.map((key) => `${key}:${styleObject[key]}`)
|
||||
.join(';');
|
||||
|
||||
expect(s(styleObject)).to.equal(expectedString);
|
||||
|
|
|
@ -1,9 +0,0 @@
|
|||
{
|
||||
"extends": ["../tslint.json"],
|
||||
"rules": {
|
||||
"no-magic-numbers": false,
|
||||
"typedef": false,
|
||||
"no-unused-expression": false,
|
||||
"no-var-requires": false
|
||||
}
|
||||
}
|
32
tslint.json
32
tslint.json
|
@ -1,32 +0,0 @@
|
|||
{
|
||||
"extends": ["tslint:latest", "tslint-config-prettier"],
|
||||
"defaultSeverity": "error",
|
||||
"rules": {
|
||||
"typedef": [
|
||||
true,
|
||||
"arrow-call-signature",
|
||||
"arrow-parameter",
|
||||
"call-signature",
|
||||
"member-variable-declaration",
|
||||
"parameter",
|
||||
"property-declaration"
|
||||
],
|
||||
"no-console": true,
|
||||
"object-literal-sort-keys": false,
|
||||
"no-implicit-dependencies": false,
|
||||
"no-submodule-imports": false,
|
||||
"no-floating-promises": true,
|
||||
"no-unused-expression": true,
|
||||
"await-promise": true,
|
||||
"no-inferrable-types": [true, "ignore-params", "ignore-properties"],
|
||||
"prefer-for-of": true,
|
||||
"no-empty": [true, "allow-empty-functions"],
|
||||
"no-magic-numbers": [true, -1, 0, 1],
|
||||
"no-parameter-reassignment": true,
|
||||
"arrow-return-shorthand": true,
|
||||
"no-default-export": true,
|
||||
"prefer-template": true,
|
||||
"only-arrow-functions": [true, "allow-named-functions"]
|
||||
},
|
||||
"jsRules": true
|
||||
}
|
Loading…
Reference in New Issue