Skip to content

Commit b6aa9ed

Browse files
LingLing
Ling
authored and
Ling
committed
Support for typescript@2.2.2 and tslint@5.0.0, Fixes #2, #3
1 parent 0f24a99 commit b6aa9ed

13 files changed

+833
-737
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@
33
npm-debug.log
44
node_modules/
55
bin/
6+
release/

README.md

+3
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,9 @@ export PATH=$PATH:node_modules/.bin
4949

5050
## Updates
5151

52+
### 0.3.30
53+
- Support for typescript@2.2.2 and tslint@5.0.0
54+
5255
### 0.3.2
5356
- Format ts files when you run `standard --pretty`
5457

package.json

+7-8
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "typescript-standard",
3-
"version": "0.3.14",
3+
"version": "0.3.30",
44
"engines": {
55
"node": ">=4.0.0"
66
},
@@ -11,9 +11,9 @@
1111
},
1212
"scripts": {
1313
"test": "node_modules/.bin/standard --pretty",
14-
"build": "npm run build:clean && npm run build:webpack",
15-
"build:clean": "rm -f ./bin/*.js",
16-
"build:tsc": "node_modules/.bin/tsc -p tsconfig.release.json",
14+
"build": "npm run build:clean && npm run build:tsc && npm run build:webpack",
15+
"build:clean": "rm -rf ./bin ./release",
16+
"build:tsc": "npm run build:clean && node_modules/.bin/tsc --noEmit -p tsconfig.release.json",
1717
"build:webpack": "node_modules/.bin/webpack --display-error-details --config ./webpack.config.ts",
1818
"prepublish": "npm run build"
1919
},
@@ -49,15 +49,14 @@
4949
"devDependencies": {
5050
"@types/glob": "latest",
5151
"@types/node": "latest",
52-
"@types/webpack": "latest",
5352
"ts-loader": "latest",
5453
"ts-node": "latest",
5554
"typescript-standard": "latest",
5655
"webpack": "latest"
5756
},
5857
"dependencies": {
59-
"glob": "latest",
60-
"tslint": "latest",
61-
"typescript": "latest"
58+
"glob": "^7.1.1",
59+
"tslint": "^5.0.0",
60+
"typescript": "^2.2.2"
6261
}
6362
}

src/lib/validator/config.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import * as path from 'path'
22
import * as glob from 'glob'
33
import { findup, find, load, isDirectory, includesInArray, startsWith } from '../utils'
44
import { ValidatorOption } from './option'
5+
import { Linter } from 'tslint';
56

67
export class ValidatorConfigParser {
78

@@ -10,7 +11,7 @@ export class ValidatorConfigParser {
1011
if (!defaultTSLintOptions) {
1112
return null;
1213
}
13-
const configuration = load(defaultTSLintOptions);
14+
const configuration = Linter.loadConfigurationFromPath(defaultTSLintOptions);
1415
return new ValidatorOption(format, configuration);
1516
}
1617

src/lib/validator/format.ts

+7-25
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,13 @@
1-
import { Formatters } from 'tslint'
1+
import { FormatterFunction, Formatters } from 'tslint'
22

33
export class ValidatorOutputFormat {
44

5-
// values
6-
static PROSE_OUTPUT = Formatters.ProseFormatter;
7-
static JSON_OUTPUT = Formatters.JsonFormatter;
8-
static PMD_OUTPUT = Formatters.PmdFormatter;
9-
static VERBOSE_OUTPUT = Formatters.VerboseFormatter;
10-
static STYLISH_OUTPUT = Formatters.StylishFormatter;
11-
static FILELIST_OUTPUT = Formatters.FileslistFormatter;
12-
13-
static getFormatter(formatter: string): Function {
14-
switch (formatter) {
15-
case 'prose':
16-
return ValidatorOutputFormat.PROSE_OUTPUT;
17-
case 'json':
18-
return ValidatorOutputFormat.JSON_OUTPUT;
19-
case 'pmg':
20-
return ValidatorOutputFormat.PMD_OUTPUT;
21-
case 'verbose':
22-
return ValidatorOutputFormat.VERBOSE_OUTPUT;
23-
case 'stylish':
24-
return ValidatorOutputFormat.STYLISH_OUTPUT;
25-
case 'filelist':
26-
return ValidatorOutputFormat.FILELIST_OUTPUT;
27-
default:
28-
return ValidatorOutputFormat.JSON_OUTPUT;
5+
static getFormatter(formatter: string): string | FormatterFunction {
6+
if (formatter) {
7+
return formatter
8+
}
9+
else {
10+
return 'json';
2911
}
3012
}
3113

src/lib/validator/option.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
import { ILinterOptions } from 'tslint'
1+
import { FormatterFunction, ILinterOptions } from 'tslint'
22
import { ValidatorOutputFormat } from './format';
33
import { IConfigurationFile } from 'tslint/lib/configuration';
44

55
export class ValidatorOption {
66

77
configuration?: IConfigurationFile;
8-
formatter?: Function;
8+
formatter?: string | FormatterFunction;
99
formattersDirectory?: string;
1010
rulesDirectory?: string | string[];
1111

src/lib/validator/result.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ export class ValidateResult {
99
output: string;
1010

1111
constructor(result: LintResult) {
12-
this.failureCount = result.failureCount;
12+
this.failureCount = result.errorCount;
1313
this.failures = result.failures;
1414
this.format = result.format;
1515
this.output = result.output;

src/lib/validator/validator.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@ export class Validator {
2020
const contents = fs.readFileSync(file, 'utf8');
2121
const linter = new Linter(this.validatorOption.options());
2222
linter.lint(file, contents, this.validatorOption.configuration);
23-
return new ValidateResult(linter.getResult());
23+
const results = linter.getResult();
24+
return new ValidateResult(results);
2425
}
2526

2627
}

tsconfig.json

+1-2
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,7 @@
1010
"node_modules/@types/"
1111
],
1212
"types": [
13-
"node",
14-
"webpack"
13+
"node"
1514
]
1615
},
1716
"formatterOptions": {

tsconfig.release.json

+2-5
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,12 @@
11
{
22
"compilerOptions": {
3-
"target": "es5",
4-
"lib": [
5-
"es5"
6-
],
3+
"target": "es6",
4+
"lib": ["es2016"],
75
"declaration": true,
86
"module": "commonjs",
97
"newLine": "LF",
108
"removeComments": true,
119
"experimentalDecorators": true,
12-
"sourceMap": true,
1310
"outDir": "release",
1411
"pretty": true
1512
},

tslint.json

+3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
{
2+
"jsRules": {
3+
"curly": true
4+
},
25
"rules": {
36
"member-access": false,
47
"member-ordering": [

webpack.config.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -27,15 +27,15 @@ export default [{
2727
},
2828
externals: externalNodeModules,
2929
resolve: {
30-
extensions: ['', '.ts']
30+
extensions: ['.ts']
3131
},
3232
module: {
3333
loaders: [
3434
{ test: /\.ts$/, loader: 'ts-loader' }
3535
]
3636
},
3737
plugins: [
38-
new webpack.BannerPlugin('#!/usr/bin/env node', { raw: 1, entryOnly: 1 })
38+
new webpack.BannerPlugin({ banner: '#!/usr/bin/env node', raw: 1, entryOnly: 1 })
3939
// new webpack.optimize.UglifyJsPlugin({
4040
// compress: {
4141
// warnings: false
@@ -58,7 +58,7 @@ export default [{
5858
},
5959
externals: externalNodeModules,
6060
resolve: {
61-
extensions: ['', '.ts']
61+
extensions: ['.ts']
6262
},
6363
module: {
6464
loaders: [

0 commit comments

Comments
 (0)