Skip to content

Commit

Permalink
Merge pull request #172 from Tyriar/tslint
Browse files Browse the repository at this point in the history
Update tslint, add rules
  • Loading branch information
Tyriar authored Jan 17, 2018
2 parents c68f60b + 4afcdc7 commit 893dde6
Show file tree
Hide file tree
Showing 8 changed files with 1,422 additions and 24 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@ before_install:
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then export CXX=g++-4.8 ; fi
script:
- npm test
- npm run tslint
- npm run lint
1,382 changes: 1,382 additions & 0 deletions package-lock.json

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
],
"scripts": {
"tsc": "tsc",
"tslint": "tslint src/**/*.ts",
"lint": "tslint src/**/*.ts",
"install": "node scripts/install.js",
"postinstall": "node scripts/post-install.js",
"test": "cross-env NODE_ENV=test mocha -R spec lib/*.test.js",
Expand All @@ -48,7 +48,7 @@
"cross-env": "^3.2.4",
"mocha": "^3.1.2",
"pollUntil": "^1.0.3",
"tslint": "^4.3.1",
"tslint": "^5.9.1",
"typescript": "^2.1.4"
}
}
6 changes: 3 additions & 3 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,17 +28,17 @@ if (process.platform === 'win32') {
*/
export function spawn(file?: string, args?: ArgvOrCommandLine, opt?: IPtyForkOptions): ITerminal {
return new Terminal(file, args, opt);
};
}

/** @deprecated */
export function fork(file?: string, args?: ArgvOrCommandLine, opt?: IPtyForkOptions): ITerminal {
return new Terminal(file, args, opt);
};
}

/** @deprecated */
export function createTerminal(file?: string, args?: ArgvOrCommandLine, opt?: IPtyForkOptions): ITerminal {
return new Terminal(file, args, opt);
};
}

export function open(options: IPtyOpenOptions): ITerminal {
return Terminal.open(options);
Expand Down
6 changes: 4 additions & 2 deletions src/interfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@

import * as net from 'net';

export type ProcessEnv = {[key: string]: string};
export interface IProcessEnv {
[key: string]: string;
}

export interface ITerminal {
/**
Expand Down Expand Up @@ -109,7 +111,7 @@ export interface IPtyForkOptions {
cols?: number;
rows?: number;
cwd?: string;
env?: ProcessEnv;
env?: IProcessEnv;
uid?: number;
gid?: number;
encoding?: string;
Expand Down
2 changes: 1 addition & 1 deletion src/terminal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ export abstract class Terminal implements ITerminal {
}

/** See net.Socket.end */
public end(data: string): void{
public end(data: string): void {
this._socket.end(data);
}

Expand Down
10 changes: 5 additions & 5 deletions src/unixTerminal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@ import * as path from 'path';
import * as tty from 'tty';
import * as os from 'os';
import { Terminal, DEFAULT_COLS, DEFAULT_ROWS } from './terminal';
import { ProcessEnv, IPtyForkOptions, IPtyOpenOptions } from './interfaces';
import { IProcessEnv, IPtyForkOptions, IPtyOpenOptions } from './interfaces';
import { ArgvOrCommandLine } from './types';
import { assign } from './utils';

declare type NativePty = {
declare interface INativePty {
master: number;
slave: number;
pty: string;
};
}

const pty = require(path.join('..', 'build', 'Release', 'pty.node'));

Expand Down Expand Up @@ -180,7 +180,7 @@ export class UnixTerminal extends Terminal {
const encoding = opt.encoding ? 'utf8' : opt.encoding;

// open
const term: NativePty = pty.open(cols, rows);
const term: INativePty = pty.open(cols, rows);

self._master = new PipeSocket(<number>term.master);
self._master.setEncoding(encoding);
Expand Down Expand Up @@ -263,7 +263,7 @@ export class UnixTerminal extends Terminal {
pty.resize(this._fd, cols, rows);
}

private _sanitizeEnv(env: ProcessEnv): void {
private _sanitizeEnv(env: IProcessEnv): void {
// Make sure we didn't start our server from inside tmux.
delete env['TMUX'];
delete env['TMUX_PANE'];
Expand Down
34 changes: 24 additions & 10 deletions tslint.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
{
"rules": {
"array-type": [
true,
"array"
],
"class-name": true,
"comment-format": [
true,
Expand All @@ -9,11 +13,21 @@
true,
"spaces"
],
"interface-name": [
true,
"always-prefix"
],
"interface-over-type-literal": true,
"typedef": [
true,
"call-signature",
"parameter"
],
"eofline": true,
"one-variable-per-declaration": [true, "ignore-for-loop"],
"no-eval": true,
"no-internal-module": true,
"no-trailing-whitespace": true,
"one-variable-per-declaration": true,
"no-unsafe-finally": true,
"no-var-keyword": true,
"quotemark": [
Expand All @@ -28,13 +42,6 @@
true,
"allow-null-check"
],
"typedef": [
true,
"call-signature",
"parameter",
"property-declaration",
"member-variable-declaration"
],
"typedef-whitespace": [
true,
{
Expand All @@ -47,15 +54,22 @@
],
"variable-name": [
true,
"ban-keywords"
"ban-keywords",
"check-format",
"allow-leading-underscore",
"allow-pascal-case"
],
"whitespace": [
true,
"check-branch",
"check-decl",
"check-module",
"check-operator",
"check-rest-spread",
"check-separator",
"check-type"
"check-type",
"check-type-operator",
"check-preblock"
]
}
}

0 comments on commit 893dde6

Please sign in to comment.