Skip to content

Commit f674bad

Browse files
committed
Enable linting for examples and fix errors
1 parent eb02124 commit f674bad

File tree

8 files changed

+27
-11
lines changed

8 files changed

+27
-11
lines changed

.travis.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,4 @@ install:
88
script:
99
- 'npm test'
1010
- 'npm run lint'
11+
- 'npm run lint-examples'
Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
import k8s = require('@kubernetes/client-node');
22

3-
let kc = new k8s.KubeConfig();
3+
const kc = new k8s.KubeConfig();
44
kc.loadFromDefault();
55

6-
let attach = new k8s.Attach(kc);
7-
attach.attach('default', 'nginx-4217019353-9gl4s', 'nginx', process.stdout, process.stderr, null /* stdin */, false /* tty */);
6+
const attach = new k8s.Attach(kc);
7+
attach.attach('default', 'nginx-4217019353-9gl4s', 'nginx',
8+
process.stdout, process.stderr, null /* stdin */, false /* tty */);
Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
import k8s = require('@kubernetes/client-node');
22

3-
let command = process.argv[2];
3+
const command = process.argv[2];
44

5-
let kc = new k8s.KubeConfig();
5+
const kc = new k8s.KubeConfig();
66
kc.loadFromDefault();
77

8-
let exec = new k8s.Exec(kc);
9-
exec.exec('default', 'nginx-4217019353-9gl4s', 'nginx', command, process.stdout, process.stderr, process.stdin, true /* tty */);
8+
const exec = new k8s.Exec(kc);
9+
exec.exec('default', 'nginx-4217019353-9gl4s', 'nginx', command,
10+
process.stdout, process.stderr, process.stdin, true /* tty */);

examples/typescript/port-forward/port-forward.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,8 @@ const forward = new k8s.PortForward(kc);
1111
// This simple server just forwards traffic from itself to a service running in kubernetes
1212
// -> localhost:8080 -> port-forward-tunnel -> kubernetes-pod
1313
// This is basically equivalent to 'kubectl port-forward ...' but in TypeScript.
14-
const server = net.createServer(function(socket) {
14+
const server = net.createServer((socket) => {
1515
forward.portForward('default', 'demo', [8080], socket, null, socket);
1616
});
1717

1818
server.listen(8080, '127.0.0.1');
19-

examples/typescript/simple/example.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,10 @@ const k8sApi = kc.makeApiClient(k8s.Core_v1Api);
66

77
k8sApi.listNamespacedPod('default')
88
.then((res) => {
9+
// tslint:disable-next-line:no-console
910
console.log(res.body);
1011
});
1112

1213
// Example of instantiating a Pod object.
13-
let pod = {
14+
const pod = {
1415
} as k8s.V1Pod;

examples/typescript/tsconfig.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"extends": "../../tsconfig.json",
3+
"include": [
4+
"**/*.ts"
5+
]
6+
}
7+

examples/typescript/watch/watch-example.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,19 +10,24 @@ const req = watch.watch('/api/v1/namespaces',
1010
// callback is called for each received object.
1111
(type, obj) => {
1212
if (type === 'ADDED') {
13+
// tslint:disable-next-line:no-console
1314
console.log('new object:');
1415
} else if (type === 'MODIFIED') {
16+
// tslint:disable-next-line:no-console
1517
console.log('changed object:');
1618
} else if (type === 'DELETED') {
19+
// tslint:disable-next-line:no-console
1720
console.log('deleted object:');
1821
} else {
22+
// tslint:disable-next-line:no-console
1923
console.log('unknown type: ' + type);
2024
}
21-
25+
// tslint:disable-next-line:no-console
2226
console.log(obj);
2327
},
2428
// done callback is called if the watch terminates normally
2529
(err) => {
30+
// tslint:disable-next-line:no-console
2631
console.log(err);
2732
});
2833

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
"types": "dist/index.d.ts",
1616
"scripts": {
1717
"lint": "tslint --project \".\"",
18+
"lint-examples": "tslint --project \"./examples/typescript\"",
1819
"clean": "rm -Rf node_modules/ dist/",
1920
"build": "tsc",
2021
"watch": "tsc --watch",

0 commit comments

Comments
 (0)