Skip to content

Commit

Permalink
add tslint in build and conform code to defined rules
Browse files Browse the repository at this point in the history
  • Loading branch information
fdecampredon committed Apr 21, 2014
1 parent fde9f33 commit 0682892
Show file tree
Hide file tree
Showing 58 changed files with 728 additions and 709 deletions.
1 change: 1 addition & 0 deletions .brackets.json
@@ -1,4 +1,5 @@
{
"spaceUnits": 4,
"typescript": {
"target": "ES5",
"module": "AMD",
Expand Down
14 changes: 13 additions & 1 deletion Gruntfile.js
Expand Up @@ -129,6 +129,18 @@ module.exports = function (grunt) {
}
},

tslint: {
options: {
configuration: grunt.file.readJSON('tslint.json')
},
all: {
src: [
'src/**/*.ts',
'!src/declarations/typescriptServices.d.ts'
]
}
},


jasmine: {
test: {
Expand Down Expand Up @@ -189,7 +201,7 @@ module.exports = function (grunt) {
grunt.registerTask('build-main',['clean:tmp', 'typescript:main', 'browserify:main','clean:tmp']);
grunt.registerTask('build-worker',['clean:tmp', 'typescript:worker', 'browserify:worker', 'clean:tmp']);
grunt.registerTask('build-test', ['clean:tmp', 'typescript:test', 'browserify:test']);
grunt.registerTask('test', ['build-test', 'jasmine', 'clean:tmp']);
grunt.registerTask('test', ['tslint', 'build-test', 'jasmine', 'clean:tmp']);
grunt.registerTask('build',['clean:local', 'build-main', 'build-worker']);
grunt.registerTask('default', ['test', 'build']);
grunt.registerTask('release', ['test', 'build', 'clean:release', 'copy:release','compress']);
Expand Down
2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -19,7 +19,7 @@
"grunt-contrib-clean": "~0.5.0",
"grunt-contrib-jasmine": "~0.5.2",
"grunt-contrib-copy": "~0.4.1",
"grunt-tslint": "~0.4.0",
"grunt-tslint": "~0.4.1",
"grunt-contrib-compress": "~0.5.3",
"grunt-browserify": "~1.3.0",
"istanbulify": "~0.1.0",
Expand Down
18 changes: 9 additions & 9 deletions src/commons/collections.ts
Expand Up @@ -36,8 +36,8 @@ export class StringSet {
*/
constructor(array?: string[]) {
this.map = Object.create(null);
if (array) {
for (var i = 0, l= array.length; i < l;i ++) {
if (array) {
for (var i = 0, l = array.length; i < l; i ++) {
this.add(array[i]);
}
}
Expand Down Expand Up @@ -108,7 +108,7 @@ export class StringMap<T> {
constructor(obj?: {[index: string]: T}) {
this.map = Object.create(null);
this.mascot = <T>{};
if (obj) {
if (obj) {
Object.keys(obj).forEach(key => this.map[key] = obj[key]);
}
}
Expand Down Expand Up @@ -172,11 +172,11 @@ export class StringMap<T> {
* return an array containing the entries of the map
*/
get entries(): MapEntry<T>[] {
return Object.keys(this.map).map(key => { 
return { 
key: key,
value: this.map[key]
}
return Object.keys(this.map).map(key => {
return {
key: key,
value: this.map[key]
};
});
}

Expand All @@ -197,4 +197,4 @@ export class StringMap<T> {
clone(): StringMap<T> {
return new StringMap<T>(this.toObject());
}
}
}
6 changes: 3 additions & 3 deletions src/commons/definition.ts
Expand Up @@ -14,7 +14,7 @@ export interface DefinitionInfo {
/**
* line at which the symbol definition start
*/
lineStart : number;
lineStart: number;

/**
* charachter at which the symbol definition start
Expand All @@ -24,7 +24,7 @@ export interface DefinitionInfo {
/**
* line at which the symbol definition end
*/
lineEnd : number;
lineEnd: number;

/**
* charachter at which the symbol definition end
Expand All @@ -50,4 +50,4 @@ export interface IDefinitionService {
* @return a promise resolving to a list of definition info
*/
getDefinitionForFile(fileName: string, position: CodeMirror.Position): Promise<DefinitionInfo[]>;
}
}
2 changes: 1 addition & 1 deletion src/commons/errorService.ts
Expand Up @@ -14,4 +14,4 @@ interface IErrorService {
getErrorsForFile(fileName: string): Promise<{ errors: brackets.LintingError[]; aborted: boolean }>
}

export = IErrorService;
export = IErrorService;
8 changes: 4 additions & 4 deletions src/commons/fileSystem.ts
Expand Up @@ -33,12 +33,12 @@ export interface IFileSystem {
/**
* return a promise resolving to the project root folder path
*/
getProjectRoot(): Promise<string>
getProjectRoot(): Promise<string>;

/**
* a signal dispatching fine grained change reflecting the change that happens in the working set
*/
projectFilesChanged: signal.Signal<FileChangeRecord[]>
projectFilesChanged: signal.Signal<FileChangeRecord[]>;

/**
* return a promise that resolve with an array of string containing all the files of the projects
Expand Down Expand Up @@ -103,12 +103,12 @@ export interface FileChangeRecord {
/**
* kind of change
*/
kind : FileChangeKind;
kind: FileChangeKind;

/**
* name of the file that have changed
*/
fileName : string;
fileName: string;
}


4 changes: 2 additions & 2 deletions src/commons/immediate.ts
Expand Up @@ -81,7 +81,7 @@ if (typeof window.setImmediate !== 'undefined') {
uidHelper++;
setImmediateQueue.push({
handle: uidHelper,
callBack : typeof expression === 'string' ? new Function(expression): expression,
callBack : typeof expression === 'string' ? new Function(expression) : expression,
parameters: args
});
window.postMessage(sentinel, '*');
Expand All @@ -90,7 +90,7 @@ if (typeof window.setImmediate !== 'undefined') {
clearImmediate(handle: number): void {
canceledImmediate[handle] = true;
}
}
};

Object.freeze(immediateImpl);
}
Expand Down
8 changes: 4 additions & 4 deletions src/commons/lexicalStructure.ts
Expand Up @@ -22,21 +22,21 @@ import Promise = es6Promise.Promise;
/**
* Represent a Lexical Structure item
*/
export interface LexicalStructureItem {
export interface LexicalStructureItem {
/**
* Name of the item
*/
name: string;
name: string;

/**
* Name of the item container
*/
containerName:string;
containerName: string;

/**
* Position of the item in the file
*/
position: CodeMirror.Position;
position: CodeMirror.Position;
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/commons/preferencesManager.ts
Expand Up @@ -15,7 +15,7 @@
'use strict';

import TypeScriptProjectConfig = require('./projectConfig');
import signal = require('./signal')
import signal = require('./signal');
import es6Promise = require('es6-promise');
import Promise = es6Promise.Promise;

Expand Down
2 changes: 1 addition & 1 deletion src/commons/projectConfig.ts
Expand Up @@ -64,4 +64,4 @@ interface TypeScriptProjectConfig {
noImplicitAny?: boolean;
}

export = TypeScriptProjectConfig
export = TypeScriptProjectConfig;
12 changes: 6 additions & 6 deletions src/commons/promiseQueue.ts
Expand Up @@ -41,15 +41,15 @@ class PromiseQueue {
constructor() {
this.promise = new Promise(resolve => {
this.initializer = resolve;
})
});
}

/**
* initialize the queue subsequent call reset the queue
*
* @param val the value passed as initialial result
*/
init<T>(val: Promise<T>):Promise<T>
init<T>(val: Promise<T>): Promise<T>;

/**
* initialize the queue subsequent call reset the queue
Expand All @@ -69,20 +69,20 @@ class PromiseQueue {
/**
* enqueue an action
*/
then<T>(action: () => Promise<T>):Promise<T>
then<T>(action: () => Promise<T>): Promise<T>;
/**
* enqueue an action
*/
then<T>(action: () => T): Promise<T>
then<T>(action: () => T): Promise<T>;
/**
* enqueue an action
*/
then(action: () => void): Promise<void> {
return this.promise = this.promise.then(
() => action(),
() => action()
)
);
}
}

export = PromiseQueue;
export = PromiseQueue;
1 change: 0 additions & 1 deletion src/commons/signal.ts
Expand Up @@ -108,7 +108,6 @@ export class Signal<T> implements ISignal<T> {
* @params parameter the parameter attached to the event dispatching
*/
dispatch(parameter?: T): boolean {
var indexesToRemove: number[];
var hasBeenCanceled = this.listeners.every((listener: (parameter: T) => any) => {
var result = listener(parameter);
return result !== false;
Expand Down
10 changes: 5 additions & 5 deletions src/commons/typeScriptUtils.ts
Expand Up @@ -20,18 +20,18 @@ import TypeScriptProjectConfig = require('./projectConfig');
* helper function that valid a config file
* @param config the config object to validate
*/
export function validateTypeScriptProjectConfig(config : TypeScriptProjectConfig): boolean {
export function validateTypeScriptProjectConfig(config: TypeScriptProjectConfig): boolean {
if (!config) {
return false;
}
if (config.target && ['es3', 'es5'].indexOf(config.target.toLowerCase()) === -1) {
return false
return false;
}
if (config.module && ['none', 'amd', 'commonjs'].indexOf(config.module.toLowerCase()) === -1) {
return false
return false;
}
if (config.sourceRoot && typeof config.sourceRoot !== 'string') {
return false
return false;
}
if (!config.sources || !Array.isArray(config.sources) || !config.sources.every(pattern => typeof pattern === 'string')) {
return false;
Expand All @@ -49,4 +49,4 @@ export var typeScriptProjectConfigDefault: TypeScriptProjectConfig = {
target: 'es3',
module: 'none',
noImplicitAny: false
}
};

0 comments on commit 0682892

Please sign in to comment.