🚨 Adding tslint and fixing warnings

This commit is contained in:
C-3PO 2018-06-21 14:37:29 +02:00
parent e93190c723
commit 6f59625056
Signed by: c3po
GPG key ID: 62993C4BB4D86F24
4 changed files with 25 additions and 12 deletions

1
.gitignore vendored
View file

@ -1,2 +1,3 @@
.vscode
dist dist
node_modules node_modules

View file

@ -1,14 +1,14 @@
interface Settings { interface ISettings {
[key: string]: any, [key: string]: any;
product?: 'assets_swtor_de_de' | 'assets_swtor_en_us' | 'assets_swtor_fr_fr' | 'assets_swtor_main' | 'assets_swtor_test_de_de' | 'assets_swtor_test_en_us' | 'assets_swtor_test_fr_fr' | 'assets_swtor_test_main' | 'eualas' | 'movies_de_de' | 'movies_en_us' | 'movies_fr_fr' | 'patcher2014' | 'patcher2017' | 'retailclient_betatest' | 'retailclient_cstraining' | 'retailclient_liveeptest' | 'retailclient_publictest' | 'retailclient_squadron157' | 'retailclient_swtor' product?: 'assets_swtor_de_de' | 'assets_swtor_en_us' | 'assets_swtor_fr_fr' | 'assets_swtor_main' | 'assets_swtor_test_de_de' | 'assets_swtor_test_en_us' | 'assets_swtor_test_fr_fr' | 'assets_swtor_test_main' | 'eualas' | 'movies_de_de' | 'movies_en_us' | 'movies_fr_fr' | 'patcher2014' | 'patcher2017' | 'retailclient_betatest' | 'retailclient_cstraining' | 'retailclient_liveeptest' | 'retailclient_publictest' | 'retailclient_squadron157' | 'retailclient_swtor';
release?: number, //TODO: allow 'current', but how will we know what current version is? release?: number; //TODO: allow 'current', but how will we know what current version is?
from?: number, from?: number;
outputType?: 'info' | 'file', //whether to just show JSON information, or actually write files into a directory outputType?: 'info' | 'file'; //whether to just show JSON information, or actually write files into a directory
} }
const allowedProducts: Settings["product"][] = ['assets_swtor_de_de', 'assets_swtor_en_us', 'assets_swtor_fr_fr', 'assets_swtor_main', 'assets_swtor_test_de_de', 'assets_swtor_test_en_us', 'assets_swtor_test_fr_fr', 'assets_swtor_test_main', 'eualas', 'movies_de_de', 'movies_en_us', 'movies_fr_fr', 'patcher2014', 'patcher2017', 'retailclient_betatest', 'retailclient_cstraining', 'retailclient_liveeptest', 'retailclient_publictest', 'retailclient_squadron157', 'retailclient_swtor']; const allowedProducts: Array<ISettings['product']> = ['assets_swtor_de_de', 'assets_swtor_en_us', 'assets_swtor_fr_fr', 'assets_swtor_main', 'assets_swtor_test_de_de', 'assets_swtor_test_en_us', 'assets_swtor_test_fr_fr', 'assets_swtor_test_main', 'eualas', 'movies_de_de', 'movies_en_us', 'movies_fr_fr', 'patcher2014', 'patcher2017', 'retailclient_betatest', 'retailclient_cstraining', 'retailclient_liveeptest', 'retailclient_publictest', 'retailclient_squadron157', 'retailclient_swtor'];
const settings: Settings = {}; const settings: ISettings = {};
/** Sets the given setting to the given value. Throws an error if key is invalid, or value doesn't match the key. */ /** Sets the given setting to the given value. Throws an error if key is invalid, or value doesn't match the key. */
export const set = (key: string, value: any) => { export const set = (key: string, value: any) => {
@ -16,8 +16,8 @@ export const set = (key: string, value: any) => {
case 'product': case 'product':
//TODO: need to verify input (one of allowed products) //TODO: need to verify input (one of allowed products)
if (typeof value !== 'string') { throw new Error(`product must be a string but it's a "${typeof value}".`); } if (typeof value !== 'string') { throw new Error(`product must be a string but it's a "${typeof value}".`); }
if (!allowedProducts.includes(value as Settings["product"])) { throw new Error(`"${value}" is not an allowed product.`); } if (!allowedProducts.includes(value as ISettings['product'])) { throw new Error(`"${value}" is not an allowed product.`); }
settings.product = value as Settings["product"]; settings.product = value as ISettings['product'];
break; break;
case 'release': case 'release':
//verify input (must be a number >=0, and >settings.from) //verify input (must be a number >=0, and >settings.from)

View file

@ -1,7 +1,5 @@
import * as config from './config'; import * as config from './config';
console.log('Hello world!');
//TODO: read arguments from command-line instead: process.argv //TODO: read arguments from command-line instead: process.argv
config.set('product', 'assets_swtor_en_us'); config.set('product', 'assets_swtor_en_us');
config.set('release', 120); config.set('release', 120);

14
src/tslint.json Normal file
View file

@ -0,0 +1,14 @@
{
"defaultSeverity": "error",
"extends": [
"tslint:recommended"
],
"jsRules": {},
"rules": {
"comment-format": false,
"max-line-length": false,
"no-bitwise": false,
"quotemark": [true, "single"]
},
"rulesDirectory": []
}