Skip to content

Add TSLint to the project #430

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Feb 26, 2017
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,14 @@ module.exports = function(grunt)
out: 'src/typings/typescript/typescript.js'
}
},
tslint: {
options: {
configuration: 'tslint.json'
},
files: {
src: [ 'src/**/*.ts' ]
}
},
'string-replace': {
version: {
files: {
Expand Down Expand Up @@ -82,9 +90,10 @@ module.exports = function(grunt)
grunt.loadNpmTasks('grunt-string-replace');
grunt.loadNpmTasks('grunt-contrib-clean');
grunt.loadNpmTasks('grunt-ts');
grunt.loadNpmTasks('grunt-tslint');
grunt.loadNpmTasks('grunt-mocha-istanbul');

grunt.registerTask('default', ['ts:typedoc', 'string-replace:version']);
grunt.registerTask('default', ['tslint', 'ts:typedoc', 'string-replace:version']);
grunt.registerTask('build_and_test', ['default', 'specs', 'mocha_istanbul:coverage']);
grunt.registerTask('specs', ['clean:specsBefore', 'build-specs', 'clean:specsAfter']);

Expand Down
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,10 @@
"grunt-mocha-istanbul": "^5.0.1",
"grunt-string-replace": "^1.2.0",
"grunt-ts": "^5.5.1",
"grunt-tslint": "^4.0.1",
"istanbul": "^0.4.1",
"mocha": "^3.0.2"
"mocha": "^3.0.2",
"tslint": "^4.4.2"
},
"files": [
"bin",
Expand Down
12 changes: 6 additions & 6 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
export {Application} from "./lib/application";
export {CliApplication} from "./lib/cli";
export {Application} from './lib/application';
export {CliApplication} from './lib/cli';

export {EventDispatcher, Event} from "./lib/utils/events";
export {resetReflectionID} from "./lib/models/reflections/abstract";
export {normalizePath} from "./lib/utils/fs";
export {ProjectReflection} from "./lib/models/reflections/project";
export {EventDispatcher, Event} from './lib/utils/events';
export {resetReflectionID} from './lib/models/reflections/abstract';
export {normalizePath} from './lib/utils/fs';
export {ProjectReflection} from './lib/models/reflections/project';
35 changes: 17 additions & 18 deletions src/lib/application.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,19 @@
* in [[TypeDoc.Models]] and the final rendering is defined in [[TypeDoc.Output]].
*/

import * as Path from "path";
import * as FS from "fs";
import * as Util from "util";
import * as typescript from "typescript";
import {Minimatch, IMinimatch} from "minimatch";
import * as Path from 'path';
import * as FS from 'fs';
import * as typescript from 'typescript';
import {Minimatch, IMinimatch} from 'minimatch';

import {Converter} from "./converter/index";
import {Renderer} from "./output/renderer";
import {ProjectReflection} from "./models/index";
import {Logger, ConsoleLogger, CallbackLogger, PluginHost, writeFile} from "./utils/index";
import {Converter} from './converter/index';
import {Renderer} from './output/renderer';
import {ProjectReflection} from './models/index';
import {Logger, ConsoleLogger, CallbackLogger, PluginHost, writeFile} from './utils/index';

import {AbstractComponent, ChildableComponent, Component, Option} from "./utils/component";
import {Options, OptionsReadMode, IOptionsReadResult} from "./utils/options/index"
import {ParameterType} from "./utils/options/declaration";
import {AbstractComponent, ChildableComponent, Component, Option} from './utils/component';
import {Options, OptionsReadMode, IOptionsReadResult} from './utils/options/index';
import {ParameterType} from './utils/options/declaration';


/**
Expand All @@ -36,7 +35,7 @@ import {ParameterType} from "./utils/options/declaration";
* and emit a series of events while processing the project. Subscribe to these Events
* to control the application flow or alter the output.
*/
@Component({name:"application", internal:true})
@Component({name:'application', internal:true})
export class Application extends ChildableComponent<Application, AbstractComponent<Application>>
{
options:Options;
Expand All @@ -62,7 +61,7 @@ export class Application extends ChildableComponent<Application, AbstractCompone
name: 'logger',
help: 'Specify the logger that should be used, \'none\' or \'console\'',
defaultValue: 'console',
type: ParameterType.Mixed,
type: ParameterType.Mixed
})
loggerType:string|Function;

Expand All @@ -83,7 +82,7 @@ export class Application extends ChildableComponent<Application, AbstractCompone
/**
* The version number of TypeDoc.
*/
static VERSION:string = '{{ VERSION }}';
static VERSION = '{{ VERSION }}';



Expand Down Expand Up @@ -114,9 +113,9 @@ export class Application extends ChildableComponent<Application, AbstractCompone
this.options.read(options, OptionsReadMode.Prefetch);

const logger = this.loggerType;
if (typeof logger == 'function') {
if (typeof logger === 'function') {
this.logger = new CallbackLogger(<any>logger);
} else if (logger == 'none') {
} else if (logger === 'none') {
this.logger = new Logger();
}

Expand All @@ -129,7 +128,7 @@ export class Application extends ChildableComponent<Application, AbstractCompone
* Return the application / root component instance.
*/
get application():Application {
return this
return this;
}


Expand Down
12 changes: 6 additions & 6 deletions src/lib/cli.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import * as typescript from "typescript";
import * as typescript from 'typescript';

import {Application} from "./application";
import {Option} from "./utils/component";
import {OptionsReadMode, IOptionsReadResult} from "./utils/options/options";
import {ParameterHint, ParameterType} from "./utils/options/declaration";
import {getOptionsHelp} from "./utils/options/help";
import {Application} from './application';
import {Option} from './utils/component';
import {IOptionsReadResult} from './utils/options/options';
import {ParameterHint, ParameterType} from './utils/options/declaration';
import {getOptionsHelp} from './utils/options/help';


export const enum ExitCode
Expand Down
15 changes: 7 additions & 8 deletions src/lib/converter/components.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import * as ts from "typescript";
import * as ts from 'typescript';

import {Application} from "../application";
import {Component, AbstractComponent} from "../utils/component";
import {Reflection} from "../models/reflections/abstract";
import {Type} from "../models/types/abstract";
import {Context} from "./context";
import {Converter} from "./converter";
import {Component, AbstractComponent} from '../utils/component';
import {Reflection} from '../models/reflections/abstract';
import {Type} from '../models/types/abstract';
import {Context} from './context';
import {Converter} from './converter';


export {Component};
Expand All @@ -32,7 +31,7 @@ export abstract class ConverterTypeComponent extends ConverterComponent
* The priority this converter should be executed with.
* A higher priority means the converter will be applied earlier.
*/
priority:number = 0;
priority = 0;
}


Expand Down
21 changes: 10 additions & 11 deletions src/lib/converter/context.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import * as ts from "typescript";
import {Minimatch, IMinimatch} from "minimatch";
import * as ts from 'typescript';
import {Minimatch, IMinimatch} from 'minimatch';

import {Logger} from "../utils/loggers";
import {Reflection, ProjectReflection, ContainerReflection, Type} from "../models/index";
import {createTypeParameter} from "./factories/type-parameter";
import {Converter} from "./converter";
import {Logger} from '../utils/loggers';
import {Reflection, ProjectReflection, ContainerReflection, Type} from '../models/index';
import {createTypeParameter} from './factories/type-parameter';
import {Converter} from './converter';


/**
Expand Down Expand Up @@ -141,7 +141,7 @@ export class Context
let nodeType:ts.Type;
try {
nodeType = this.checker.getTypeAtLocation(node);
} catch (error) {
} catch (error) {
}
if (!nodeType) {
if (node.symbol) {
Expand Down Expand Up @@ -223,9 +223,8 @@ export class Context
* @param callback The callback that should be executed.
*/
withSourceFile(node:ts.SourceFile, callback:Function) {
const options = this.converter.application.options;
const externalPattern = this.externalPattern;
let isExternal = this.fileNames.indexOf(node.fileName) == -1;
let isExternal = this.fileNames.indexOf(node.fileName) === -1;
if (externalPattern) {
isExternal = isExternal || externalPattern.match(node.fileName);
}
Expand All @@ -237,7 +236,7 @@ export class Context
let isDeclaration = node.isDeclarationFile;
if (isDeclaration) {
const lib = this.converter.getDefaultLib();
const isLib = node.fileName.substr(-lib.length) == lib;
const isLib = node.fileName.substr(-lib.length) === lib;
if (!this.converter.includeDeclarations || isLib) {
return;
}
Expand Down Expand Up @@ -322,7 +321,7 @@ export class Context

if (baseNode.symbol) {
const id = this.getSymbolID(baseNode.symbol);
if (this.inheritedChildren && this.inheritedChildren.indexOf(id) != -1) {
if (this.inheritedChildren && this.inheritedChildren.indexOf(id) !== -1) {
return target;
} else {
this.inheritedChildren = this.inheritedChildren || [];
Expand Down
4 changes: 2 additions & 2 deletions src/lib/converter/convert-expression.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as ts from "typescript";
import * as _ts from "../ts-internal";
import * as ts from 'typescript';
import * as _ts from '../ts-internal';


/**
Expand Down
Loading