From f922b2e0cb5978182b63a1114186fb3f4774ae8e Mon Sep 17 00:00:00 2001 From: Oscar Hinton Date: Mon, 30 Oct 2017 22:49:56 +0100 Subject: [PATCH] Add TSLint (#340) * Add tslint. * Disable alphabetic ordering. * Change place on selectionTitle. --- package.json | 6 ++- src/popup/app/app.d.ts | 2 +- .../app/components/cipher-items.component.ts | 12 ++--- tslint.json | 44 +++++++++++++++++++ webpack.common.js | 5 +++ 5 files changed, 61 insertions(+), 8 deletions(-) create mode 100644 tslint.json diff --git a/package.json b/package.json index 1d982aa645..cc618dba72 100644 --- a/package.json +++ b/package.json @@ -5,7 +5,9 @@ "start:firefox": "web-ext run --source-dir ./dist/", "dev": "gulp build && webpack --config webpack.dev.js", "dev:watch": "gulp build && webpack --config webpack.dev.js --watch", - "prod": "gulp build && webpack --config webpack.prod.js" + "prod": "gulp build && webpack --config webpack.prod.js", + "lint": "tslint src/**/*.ts || true", + "lint:fix": "tslint src/**/*.ts --fix" }, "devDependencies": { "angular": "1.6.6", @@ -52,6 +54,8 @@ "sweetalert": "1.1.3", "tldjs": "2.0.0", "ts-loader": "^3.0.5", + "tslint": "^5.8.0", + "tslint-loader": "^3.5.3", "typescript": "^2.5.3", "vinyl-source-stream": "1.1.0", "web-ext": "2.0.0", diff --git a/src/popup/app/app.d.ts b/src/popup/app/app.d.ts index 55799ae9cf..7bf7506fcf 100644 --- a/src/popup/app/app.d.ts +++ b/src/popup/app/app.d.ts @@ -1 +1 @@ -declare module '*.html'; \ No newline at end of file +declare module '*.html'; diff --git a/src/popup/app/components/cipher-items.component.ts b/src/popup/app/components/cipher-items.component.ts index aff45dae08..54dd4931d3 100644 --- a/src/popup/app/components/cipher-items.component.ts +++ b/src/popup/app/components/cipher-items.component.ts @@ -8,11 +8,11 @@ class CipherItemsController implements ng.IController { } - public view(cipher: any) { + view(cipher: any) { return this.onView()(cipher); } - public select(cipher: any) { + select(cipher: any) { return this.onSelected()(cipher); } @@ -22,9 +22,9 @@ export const CipherItemsComponent = { bindings: { ciphers: '<', selectionTitle: '<', + onSelected: '&', onView: '&', - onSelected: '&' }, - template: template, - controller: CipherItemsController -} + controller: CipherItemsController, + template, +}; diff --git a/tslint.json b/tslint.json new file mode 100644 index 0000000000..54a37c68e7 --- /dev/null +++ b/tslint.json @@ -0,0 +1,44 @@ +{ + "extends": "tslint:recommended", + "rules": { + "ban-types": { + "options": [ + ["Object", "Avoid using the `Object` type. Did you mean `object`?"], + ["Boolean", "Avoid using the `Boolean` type. Did you mean `boolean`?"], + ["Number", "Avoid using the `Number` type. Did you mean `number`?"], + ["String", "Avoid using the `String` type. Did you mean `string`?"], + ["Symbol", "Avoid using the `Symbol` type. Did you mean `symbol`?"] + ] + }, + "member-access": [true, "no-public"], + "member-ordering": [true, {"order": [ + "public-static-field", + "public-static-method", + "protected-static-field", + "protected-static-method", + "private-static-field", + "private-static-method", + "public-instance-field", + "protected-instance-field", + "private-instance-field", + "public-constructor", + "protected-constructor", + "private-constructor", + "public-instance-method", + "protected-instance-method", + "private-instance-method" + ]}], + "object-literal-sort-keys": false, + "quotemark": [true, "single"], + "whitespace": [ + true, + "check-branch", + "check-decl", + "check-module", + "check-operator", + "check-preblock", + "check-separator", + "check-type" + ] + } +} diff --git a/webpack.common.js b/webpack.common.js index 7229d2c361..0e17f57c09 100644 --- a/webpack.common.js +++ b/webpack.common.js @@ -15,6 +15,11 @@ module.exports = { }, module: { rules: [ + { + test: /\.ts$/, + enforce: 'pre', + loader: 'tslint-loader' + }, { test: /\.tsx?$/, use: 'ts-loader',