Skip to content
This repository was archived by the owner on Dec 1, 2019. It is now read-only.

Commit fa71235

Browse files
author
Nikita Korotkih
committed
refactor(*): minor refactorings - coding style fixes; add CONTIBUTING.md; add scripts to package.json
1 parent dd9906d commit fa71235

10 files changed

+153
-72
lines changed

CONTRIBUTING.md

+75
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
Contribution Guide for Manhattan Project
2+
========================================
3+
4+
## Git Commit Guidelines
5+
6+
These guidelines have been copied from the [AngularJS](https://github.com/angular/angular.js/blob/master/CONTRIBUTING.md#-git-commit-guidelines)
7+
project.
8+
9+
We have very precise rules over how our git commit messages can be formatted. This leads to **more
10+
readable messages** that are easy to follow when looking through the **project history**. But also,
11+
we use the git commit messages to **generate the change log**.
12+
13+
### Commit Message Format
14+
Each commit message consists of a **header**, a **body** and a **footer**. The header has a special
15+
format that includes a **type**, a **scope** and a **subject**:
16+
17+
```
18+
<type>(<scope>): <subject>
19+
<BLANK LINE>
20+
<body>
21+
<BLANK LINE>
22+
<footer>
23+
```
24+
25+
Any line of the commit message cannot be longer 100 characters! This allows the message to be easier
26+
to read on github as well as in various git tools.
27+
28+
### Type
29+
Must be one of the following:
30+
31+
* **feat**: A new feature
32+
* **fix**: A bug fix
33+
* **docs**: Documentation only changes
34+
* **style**: Changes that do not affect the meaning of the code (white-space, formatting, missing
35+
semi-colons, etc)
36+
* **refactor**: A code change that neither fixes a bug or adds a feature
37+
* **perf**: A code change that improves performance
38+
* **test**: Adding missing tests
39+
* **chore**: Changes to the build process or auxiliary tools and libraries such as documentation
40+
generation
41+
42+
### Scope
43+
In our project scope refers to BEM block which is touched by changes.
44+
45+
### Subject
46+
The subject contains succinct description of the change:
47+
48+
* use the imperative, present tense: "change" not "changed" nor "changes"
49+
* don't capitalize first letter
50+
* no dot (.) at the end
51+
52+
###Body
53+
Just as in the **subject**, use the imperative, present tense: "change" not "changed" nor "changes"
54+
The body should include the motivation for the change and contrast this with previous behavior.
55+
56+
###Footer
57+
The footer should contain any information about **Breaking Changes** and is also the place to
58+
reference GitHub issues that this commit **Closes**.
59+
60+
The last line of commits introducing breaking changes should be in the form `BREAKING_CHANGE: <desc>`
61+
62+
63+
A detailed explanation can be found in this [document][commit-message-format].
64+
65+
[commit-message-format]: https://docs.google.com/document/d/1QrDFcIiPjSLDn3EL15IJygNPiHORgU1_OOAqWjiDU5Y/edit#
66+
67+
## Pull Request reviews comments
68+
69+
Following abbreviations should be used in PR merge comments:
70+
71+
* `r+ {sha}`: review passed for all commits up to `{sha}`
72+
* `r-`: review revealed some errors, changes must be done to proceed
73+
* `r? @spanferov`: request for review from another user
74+
* `re-r? @spanferov`: request another user to do review again
75+
* `cc @spanferov, @smbd`: current message is also intended for...

package.json

+5-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,10 @@
77
"grunt": "grunt",
88
"prepublish": "grunt",
99
"babel": "babel dist --presets es2015 --out-dir dist.babel --watch",
10-
"test": "mocha"
10+
"babel-compile": "babel dist --presets es2015 --out-dir dist.babel",
11+
"test": "mocha",
12+
"build": "npm run grunt && npm run babel-compile",
13+
"lint": "./node_modules/.bin/tslint src/*.ts"
1114
},
1215
"author": "Stanislav Panferov <[email protected]> (http://panferov.me/)",
1316
"repository": {
@@ -57,6 +60,7 @@
5760
"mkdirp": "^0.5.1",
5861
"mocha": "^2.3.4",
5962
"rimraf": "^2.5.0",
63+
"tslint": "^3.2.2-dev.1",
6064
"typescript": "^1.8.0-dev.20151202"
6165
}
6266
}

src/cache.ts

+6-6
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,15 @@ import * as path from 'path';
55
import * as zlib from 'zlib';
66

77
export interface CompiledModule {
8-
fileName: string,
9-
text: string,
10-
map?: string,
11-
mapName?: string
8+
fileName: string;
9+
text: string;
10+
map?: string;
11+
mapName?: string;
1212
}
1313

1414
export function findCompiledModule(fileName: string): CompiledModule {
1515
let baseFileName = fileName.replace(/(\.ts|\.tsx)$/, '');
16-
let compiledFileName = `${baseFileName}.js`
16+
let compiledFileName = `${baseFileName}.js`;
1717

1818
if (fs.existsSync(compiledFileName)) {
1919
let mapFileName = `${baseFileName}.js.map`;
@@ -27,7 +27,7 @@ export function findCompiledModule(fileName: string): CompiledModule {
2727
map: isMapExists
2828
? fs.readFileSync(mapFileName).toString()
2929
: null
30-
}
30+
};
3131
return result;
3232
} else {
3333
return null;

src/checker-runtime.ts

+7-7
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ export enum MessageType {
1212
}
1313

1414
export interface IMessage {
15-
messageType: MessageType,
16-
payload: any
15+
messageType: MessageType;
16+
payload: any;
1717
}
1818

1919
export interface IInitPayload {
@@ -63,8 +63,8 @@ export class ModuleResolutionHost implements ts.ModuleResolutionHost {
6363
}
6464

6565
export class Host implements ts.LanguageServiceHost {
66-
moduleResolutionHost: ModuleResolutionHost
67-
resolver: SyncResolver
66+
moduleResolutionHost: ModuleResolutionHost;
67+
resolver: SyncResolver;
6868

6969
constructor() {
7070
this.moduleResolutionHost = new ModuleResolutionHost(this);
@@ -94,7 +94,7 @@ export class Host implements ts.LanguageServiceHost {
9494
file = {
9595
version: 0,
9696
text: fs.readFileSync(fileName, { encoding: 'utf8' }).toString()
97-
}
97+
};
9898

9999
if (path.basename(fileName) !== 'package.json') {
100100
env.files[fileName_] = file;
@@ -142,7 +142,7 @@ export class Host implements ts.LanguageServiceHost {
142142
}
143143
}
144144
catch (e) {
145-
resolvedFileName = null
145+
resolvedFileName = null;
146146
}
147147

148148
let tsResolved = env.compiler.resolveModuleName(
@@ -157,7 +157,7 @@ export class Host implements ts.LanguageServiceHost {
157157
} else {
158158
resolvedModule = {
159159
resolvedFileName: resolvedFileName || ''
160-
}
160+
};
161161
}
162162

163163
resolvedModules.push(resolvedModule);

src/deps.ts

+22-22
Original file line numberDiff line numberDiff line change
@@ -9,26 +9,26 @@ let objectAssign = require('object-assign');
99
type FileSet = {[fileName: string]: boolean};
1010

1111
export interface IResolver {
12-
(base: string, dep: string): Promise<string>
12+
(base: string, dep: string): Promise<string>;
1313
}
1414

1515
export interface IDependency {
1616
add(fileName: string): void;
17-
clear(): void
17+
clear(): void;
1818
}
1919

2020
export interface IExternals {
21-
[key: string]: string
21+
[key: string]: string;
2222
}
2323

2424
export function createResolver(externals: IExternals, webpackResolver: any): IResolver {
2525
let resolver: IResolver = Promise.promisify(webpackResolver) as any;
2626

2727
function resolve(base: string, dep: string): Promise<string> {
2828
if (externals && externals.hasOwnProperty(dep)) {
29-
return Promise.resolve<string>('%%ignore')
29+
return Promise.resolve<string>('%%ignore');
3030
} else {
31-
return resolver(base, dep)
31+
return resolver(base, dep);
3232
}
3333
}
3434

@@ -45,7 +45,7 @@ function isImportOrExportDeclaration(node: ts.Node) {
4545
}
4646

4747
function isImportEqualsDeclaration(node: ts.Node) {
48-
return !!(<any>node).moduleReference && (<any>node).moduleReference.hasOwnProperty('expression')
48+
return !!(<any>node).moduleReference && (<any>node).moduleReference.hasOwnProperty('expression');
4949
}
5050

5151
function isIgnoreDependency(absulutePath: string) {
@@ -63,7 +63,7 @@ export class FileAnalyzer {
6363

6464
async checkDependencies(resolver: IResolver, fileName: string): Promise<boolean> {
6565
if (this.validFiles.isFileValid(fileName)) {
66-
return false
66+
return false;
6767
}
6868

6969
this.validFiles.markFileValid(fileName);
@@ -79,7 +79,7 @@ export class FileAnalyzer {
7979
await this.checkDependenciesInternal(resolver, fileName);
8080
} catch (err) {
8181
this.validFiles.markFileInvalid(fileName);
82-
throw err
82+
throw err;
8383
}
8484

8585
return changed;
@@ -178,13 +178,13 @@ export class FileAnalyzer {
178178
detailedError.fileName = fileName;
179179

180180
throw detailedError;
181-
})
181+
});
182182
}
183183
}
184184

185185
export interface IDependencyGraphItem {
186186
fileName: string;
187-
dependencies: IDependencyGraphItem[]
187+
dependencies: IDependencyGraphItem[];
188188
}
189189

190190
export class DependencyManager {
@@ -202,7 +202,7 @@ export class DependencyManager {
202202
return new DependencyManager(
203203
_.cloneDeep(this.dependencies),
204204
_.cloneDeep(this.knownTypeDeclarations)
205-
)
205+
);
206206
}
207207

208208
addDependency(fileName: string, depFileName: string): void {
@@ -226,27 +226,27 @@ export class DependencyManager {
226226
}
227227

228228
clearDependencies(fileName: string): void {
229-
this.dependencies[fileName] = []
229+
this.dependencies[fileName] = [];
230230
}
231231

232232
clearCompiledModules(fileName: string): void {
233-
this.compiledModules[fileName] = []
233+
this.compiledModules[fileName] = [];
234234
}
235235

236236
getDependencies(fileName: string): string[] {
237237
if (!this.dependencies.hasOwnProperty(fileName)) {
238238
this.clearDependencies(fileName);
239239
}
240240

241-
return this.dependencies[fileName].slice()
241+
return this.dependencies[fileName].slice();
242242
}
243243

244244
addTypeDeclaration(fileName: string) {
245-
this.knownTypeDeclarations[fileName] = true
245+
this.knownTypeDeclarations[fileName] = true;
246246
}
247247

248248
hasTypeDeclaration(fileName: string): boolean {
249-
return this.knownTypeDeclarations.hasOwnProperty(fileName)
249+
return this.knownTypeDeclarations.hasOwnProperty(fileName);
250250
}
251251

252252
getTypeDeclarations(): {[fileName: string]: boolean} {
@@ -272,7 +272,7 @@ export class DependencyManager {
272272
appliedDeps[depFileName] = true;
273273
walk(depFileName, depContext);
274274
}
275-
})
275+
});
276276
};
277277

278278
walk(fileName, result);
@@ -285,8 +285,8 @@ export class DependencyManager {
285285
}
286286

287287
this.compiledModules[fileName].forEach((mod) => {
288-
deps.add(mod)
289-
})
288+
deps.add(mod);
289+
});
290290
}
291291

292292
applyChain(fileName: string, deps: IDependency) {
@@ -301,8 +301,8 @@ export class DependencyManager {
301301
let itemFileName = item.fileName;
302302
if (!appliedDeps[itemFileName]) {
303303
appliedDeps[itemFileName] = true;
304-
deps.add(itemFileName)
305-
item.dependencies.forEach((dep) => walk(dep))
304+
deps.add(itemFileName);
305+
item.dependencies.forEach((dep) => walk(dep));
306306
}
307307
};
308308

@@ -314,7 +314,7 @@ export class ValidFilesManager {
314314
files: {[fileName: string]: boolean} = {};
315315

316316
isFileValid(fileName: string): boolean {
317-
return !!this.files[fileName]
317+
return !!this.files[fileName];
318318
}
319319

320320
markFileValid(fileName: string) {

0 commit comments

Comments
 (0)