Skip to content

Commit acc4849

Browse files
author
Will Scullin
committed
Expand linting to catch fdescribe in tests, other issues.
1 parent a848e32 commit acc4849

8 files changed

+63
-15
lines changed

package-lock.json

+15
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+4-3
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@
1414
"scripts": {
1515
"build": "npm run clean && npm run build_utils && webpack",
1616
"build_utils": "tsc --build tsconfig-server.json",
17-
"clean": "rm -r lib dist",
18-
"lint": "tslint --project tsconfig.json --format stylish 'src/**/*.ts' 'server_utils/*.ts'",
19-
"lint-fix": "tslint --fix --project tsconfig.json --format stylish 'src/**/*.ts' 'server_utils/*.ts'",
17+
"clean": "rm -rf lib dist",
18+
"lint": "tslint --project tsconfig-lint.json --format stylish",
19+
"lint-fix": "tslint --fix --project tsconfig-lint.json --format stylish",
2020
"start": "npm run build_utils && webpack-dev-server --config webpack-devserver.config.js --hot --inline --open --color --progress",
2121
"python": "webpack --config webpack-devserver.config.js && python demo/demo.py",
2222
"test": "npm run lint && karma start karma.conf.js",
@@ -50,6 +50,7 @@
5050
"ts-loader": "^5.3.3",
5151
"tslint": "^5.8.0",
5252
"tslint-config-standard": "^8.0.0",
53+
"tslint-defocus": "^2.0.6",
5354
"tslint-eslint-rules": "^4.1.1",
5455
"typescript": "^3.3.3",
5556
"typescript-tslint-plugin": "0.1.2",

server_utils/auth_utils.js

+1
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ function createNonce(len) {
6666
}
6767
return text;
6868
}
69+
;
6970
function createSignedUrl(src, user, host, secret, nonce) {
7071
var jsonTime = JSON.stringify(Math.floor((new Date()).getTime() / 1000));
7172
var jsonNonce = JSON.stringify(nonce || createNonce(16));

tests/auth_utils.spec.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ const testUser = () => ({
3535
'permissions': [
3636
'access_data',
3737
'see_looks',
38-
'see_user_dashboards',
38+
'see_user_dashboards'
3939
] as LookerUserPermission[],
4040
'models': ['powered_by', 'thelook'],
4141
'user_attributes': { 'locale': 'en_US' },
@@ -48,7 +48,7 @@ const testHost = 'test.looker.com'
4848
const testSecret = 'hunter2'
4949
const testNonce = 'abc123'
5050

51-
fdescribe('createSignedUrl', () => {
51+
describe('createSignedUrl', () => {
5252
beforeEach(() => {
5353
jasmine.clock().install()
5454
jasmine.clock().mockDate(new Date(1561486800168))

tests/embed.spec.ts

+9-7
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,14 @@
2525
import { LookerEmbedSDK, LookerEmbedDashboard } from '../src/index'
2626
import { ChattyHost } from '@looker/chatty'
2727
import mock from 'xhr-mock'
28+
import { EmbedClient } from '../src/embed'
2829

2930
const testUrl = '/base/tests/test.html'
3031

3132
describe('LookerEmbed', () => {
3233
let builder
3334
let el
34-
let client
35+
let client: any
3536

3637
beforeEach(() => {
3738
LookerEmbedSDK.init('host.looker.com:9999', '/auth')
@@ -40,7 +41,7 @@ describe('LookerEmbed', () => {
4041
})
4142

4243
describe('with ID', () => {
43-
let fakeDashboardClient
44+
let fakeDashboardClient: any
4445

4546
beforeEach(() => {
4647
mock.setup()
@@ -92,15 +93,15 @@ describe('LookerEmbed', () => {
9293

9394
client.connect()
9495
.then(done.fail)
95-
.catch((error) => {
96+
.catch((error: any) => {
9697
expect(error).toEqual('foo')
9798
done()
9899
})
99100
})
100101
})
101102

102103
describe('with URL', () => {
103-
let fakeDashboardClient
104+
let fakeDashboardClient: any
104105

105106
beforeEach(() => {
106107
fakeDashboardClient = {}
@@ -139,8 +140,8 @@ describe('LookerEmbed', () => {
139140

140141
describe('creating an iframe', () => {
141142
let fakeDashboardClient
142-
let el
143-
let iframe
143+
let el: HTMLDivElement
144+
let iframe: HTMLIFrameElement
144145

145146
beforeEach(() => {
146147
el = document.createElement('div')
@@ -155,7 +156,7 @@ describe('LookerEmbed', () => {
155156
builder.withClassName('classy')
156157
client = builder.build()
157158
spyOn(window, 'fetch')
158-
spyOn(ChattyHost.prototype, 'connect').and.callFake(async function () {
159+
spyOn(ChattyHost.prototype, 'connect').and.callFake(async function (this: any) {
159160
iframe = this.iframe
160161
return Promise.resolve({})
161162
})
@@ -170,6 +171,7 @@ describe('LookerEmbed', () => {
170171
.then(() => {
171172
expect(iframe.sandbox.toString()).toEqual('allow-scripts')
172173
expect(iframe.classList.toString()).toEqual('classy')
174+
// tslint:disable-next-line:deprecation
173175
expect(iframe.frameBorder).toEqual('0')
174176
expect(iframe.src).toMatch(testUrl)
175177
done()

tests/embed_builder.spec.ts

+4-3
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,14 @@
2424

2525
import { LookerEmbedDashboard } from '../src/dashboard_client'
2626
import { EmbedClient } from '../src/embed'
27+
import { EmbedBuilder } from '../src/embed_builder'
2728
import { LookerEmbedExplore } from '../src/explore_client'
2829
import { LookerEmbedSDK } from '../src/index'
2930
import { LookerEmbedLook } from '../src/look_client'
3031

3132
describe('LookerEmbedBuilder', () => {
32-
let builder
33-
let el
33+
let builder: EmbedBuilder<LookerEmbedDashboard>
34+
let el: HTMLDivElement
3435

3536
beforeEach(() => {
3637
LookerEmbedSDK.init('host.looker.com:9999', '/auth')
@@ -153,7 +154,7 @@ describe('LookerEmbedBuilder', () => {
153154
})
154155

155156
it('should add url parameters', () => {
156-
builder.withParams({ alpha: 1, beta: 2 })
157+
builder.withParams({ alpha: '1', beta: '2' })
157158
expect(builder.embedUrl).toMatch('alpha=1&beta=2')
158159
})
159160

tsconfig-lint.json

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
{
2+
"compilerOptions": {
3+
4+
"module": "commonjs",
5+
"moduleResolution": "node",
6+
"noEmit": true,
7+
"noImplicitReturns": true,
8+
"strict": true,
9+
"target": "ES5",
10+
"lib": ["es6", "es2017.object"],
11+
"plugins": [
12+
{
13+
"name": "typescript-tslint-plugin",
14+
"alwaysShowRuleFailuresAsWarnings": true
15+
}
16+
]
17+
},
18+
"exclude": [
19+
"node_modules"
20+
],
21+
"include": [
22+
"src",
23+
"server_utils",
24+
"tests"
25+
]
26+
}

tslint.json

+2
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
{
22
"defaultSeverity": "error",
33
"extends": [
4+
"tslint-defocus",
45
"tslint-config-standard"
56
],
67
"jsRules": {},
78
"rules": {
9+
"defocus": true,
810
"no-namespace": [true, "allow-declarations"],
911
"prefer-const": [true, {"destructuring": "all"}],
1012
"no-reference": true,

0 commit comments

Comments
 (0)