Skip to content

Commit

Permalink
Update tslint
Browse files Browse the repository at this point in the history
  • Loading branch information
blakeembrey committed Dec 22, 2015
1 parent d6dad31 commit b9863fa
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 24 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"LICENSE"
],
"scripts": {
"lint": "tslint src/**/*.ts",
"lint": "tslint \"src/**/*.ts\"",
"build": "npm run build-ts",
"build-ts": "rm -rf dist && tsc",
"test-spec": "mocha dist/**/*.spec.js -R spec --bail",
Expand Down Expand Up @@ -57,7 +57,7 @@
"ntypescript": "^1.201507091536.1",
"pre-commit": "^1.0.10",
"proxyquire": "^1.7.2",
"tslint": "^3.0.0",
"tslint": "^3.2.1",
"typescript": "^1.6.2",
"typings": "^0.3.0"
},
Expand Down
50 changes: 29 additions & 21 deletions src/ts-node.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import tsconfig = require('tsconfig')
import { resolve, relative, extname, basename, isAbsolute } from 'path'
import { relative, basename } from 'path'
import { readFileSync, statSync } from 'fs'
import { EOL } from 'os'
import sourceMapSupport = require('source-map-support')
Expand All @@ -11,7 +11,7 @@ import { BaseError } from 'make-error'
/**
* Common TypeScript interfaces between versions.
*/
export interface TS_Common {
export interface TSCommon {
sys: any
service: any
ScriptSnapshot: {
Expand All @@ -27,21 +27,21 @@ export interface TS_Common {
/**
* The TypeScript 1.7+ interface.
*/
export interface TS_1_7ish extends TS_Common {
export interface TS17ish extends TSCommon {
parseJsonConfigFileContent (config: any, host: any, fileName: string): any
}

/**
* TypeScript 1.5+ interface.
*/
export interface TS_1_5ish extends TS_Common {
export interface TS15ish extends TSCommon {
parseConfigFile (config: any, host: any, fileName: string): any
}

/**
* TypeScript compatible compilers.
*/
export type TSish = TS_1_5ish | TS_1_7ish
export type TSish = TS15ish | TS17ish

/**
* Export the current version.
Expand Down Expand Up @@ -79,22 +79,26 @@ function readConfig (options: Options, cwd: string, ts: TSish) {
compilerOptions: {}
}

config.compilerOptions = extend({
target: 'es5',
module: 'commonjs'
}, config.compilerOptions, {
rootDir: cwd,
sourceMap: true,
inlineSourceMap: false,
inlineSources: false,
declaration: false
})
config.compilerOptions = extend(
{
target: 'es5',
module: 'commonjs'
},
config.compilerOptions,
{
rootDir: cwd,
sourceMap: true,
inlineSourceMap: false,
inlineSources: false,
declaration: false
}
)

if (typeof (<TS_1_5ish> ts).parseConfigFile === 'function') {
return (<TS_1_5ish> ts).parseConfigFile(config, ts.sys, fileName)
if (typeof (<TS15ish> ts).parseConfigFile === 'function') {
return (<TS15ish> ts).parseConfigFile(config, ts.sys, fileName)
}

return (<TS_1_7ish> ts).parseJsonConfigFileContent(config, ts.sys, fileName)
return (<TS17ish> ts).parseJsonConfigFileContent(config, ts.sys, fileName)
}

/**
Expand Down Expand Up @@ -256,7 +260,9 @@ export function getVersion (fileName: string): string {
export function getFile (fileName: string): string {
try {
return readFileSync(fileName, 'utf8')
} catch (err) {}
} catch (error) {
return
}
}

/**
Expand Down Expand Up @@ -311,7 +317,7 @@ export function printDiagnostics (diagnostics: string[]) {
* Sanitize the source map content.
*/
function getSourceMap (map: string, fileName: string, code: string): string {
var sourceMap = JSON.parse(map)
const sourceMap = JSON.parse(map)
sourceMap.file = fileName
sourceMap.sources = [fileName]
sourceMap.sourcesContent = [code]
Expand All @@ -325,9 +331,11 @@ function getSourceMap (map: string, fileName: string, code: string): string {
export class TSError extends BaseError {

name = 'TSError'
diagnostics: string[]

constructor (public diagnostics: string[]) {
constructor (diagnostics: string[]) {
super('Unable to compile TypeScript')
this.diagnostics = diagnostics
}

print () {
Expand Down
1 change: 0 additions & 1 deletion tslint.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
true,
140
],
"member-access": true,
"member-ordering": [
true,
"public-before-private",
Expand Down

0 comments on commit b9863fa

Please sign in to comment.