File tree 6 files changed +120
-3
lines changed
6 files changed +120
-3
lines changed Original file line number Diff line number Diff line change @@ -55,7 +55,7 @@ ng serve
55
55
```
56
56
Navigate to ` http://localhost:4200/ ` . The app will automatically reload if you change any of the source files.
57
57
58
- You can configure the default HTTP port and the one used by the LiveReload server with two command-line options :
58
+ You can configure the default HTTP port and the one used by the LiveReload server with two command-line options :
59
59
60
60
``` bash
61
61
ng serve --port 4201 --live-reload-port 49153
@@ -176,6 +176,14 @@ ng github-pages:deploy
176
176
177
177
Checkout [ angular-cli-github-pages addon] ( https://github.com/IgorMinar/angular-cli-github-pages ) docs for more info.
178
178
179
+ ### Linting code
180
+
181
+ You can lint your app code by running ` ng lint ` .
182
+ This will use the ` lint ` npm script that in generated projects uses ` tslint ` .
183
+
184
+ You can modify the ` lint ` script in ` package.json ` to run whatever linting tool
185
+ you prefer and ` ng lint ` will still run it.
186
+
179
187
180
188
## Known issues
181
189
Original file line number Diff line number Diff line change 10
10
},
11
11
"scripts" : {
12
12
"start" : " ng server" ,
13
- "postinstall" : " typings install --ambient"
13
+ "postinstall" : " typings install --ambient" ,
14
+ "lint" : " tslint src/**/*.ts"
14
15
},
15
16
"private" : true ,
16
17
"dependencies" : {
31
32
"karma-chrome-launcher" : " ^0.2.1" ,
32
33
"karma-jasmine" : " ^0.3.6" ,
33
34
"protractor" : " ^3.0.0" ,
35
+ "tslint" : " ^3.3.0" ,
34
36
"typescript" : " ^1.7.3" ,
35
37
"typings" : " ^0.6.6"
36
38
}
Original file line number Diff line number Diff line change
1
+ {
2
+ "rules" : {
3
+ "max-line-length" : [true , 100 ],
4
+ "no-inferrable-types" : true ,
5
+ "class-name" : true ,
6
+ "comment-format" : [
7
+ true ,
8
+ " check-space"
9
+ ],
10
+ "indent" : [
11
+ true ,
12
+ " spaces"
13
+ ],
14
+ "eofline" : true ,
15
+ "no-duplicate-variable" : true ,
16
+ "no-eval" : true ,
17
+ "no-arg" : true ,
18
+ "no-internal-module" : true ,
19
+ "no-trailing-whitespace" : true ,
20
+ "no-bitwise" : true ,
21
+ "no-shadowed-variable" : true ,
22
+ "no-unused-expression" : true ,
23
+ "no-unused-variable" : true ,
24
+ "one-line" : [
25
+ true ,
26
+ " check-catch" ,
27
+ " check-else" ,
28
+ " check-open-brace" ,
29
+ " check-whitespace"
30
+ ],
31
+ "quotemark" : [
32
+ true ,
33
+ " single" ,
34
+ " avoid-escape"
35
+ ],
36
+ "semicolon" : true ,
37
+ "typedef-whitespace" : [
38
+ true ,
39
+ {
40
+ "call-signature" : " nospace" ,
41
+ "index-signature" : " nospace" ,
42
+ "parameter" : " nospace" ,
43
+ "property-declaration" : " nospace" ,
44
+ "variable-declaration" : " nospace"
45
+ }
46
+ ],
47
+ "curly" : true ,
48
+ "variable-name" : [
49
+ true ,
50
+ " ban-keywords" ,
51
+ " check-format" ,
52
+ " allow-trailing-underscore"
53
+ ],
54
+ "whitespace" : [
55
+ true ,
56
+ " check-branch" ,
57
+ " check-decl" ,
58
+ " check-operator" ,
59
+ " check-separator" ,
60
+ " check-type"
61
+ ]
62
+ }
63
+ }
Original file line number Diff line number Diff line change
1
+ /* jshint node: true */
2
+ 'use strict' ;
3
+
4
+ var Command = require ( 'ember-cli/lib/models/command' ) ;
5
+ var LintTask = require ( '../tasks/lint' ) ;
6
+
7
+ module . exports = Command . extend ( {
8
+ name : 'lint' ,
9
+ description : 'Lints code in existing project' ,
10
+ works : 'insideProject' ,
11
+ run : function ( ) {
12
+ var lintTask = new LintTask ( {
13
+ ui : this . ui ,
14
+ analytics : this . analytics ,
15
+ project : this . project
16
+ } ) ;
17
+
18
+ return lintTask . run ( ) ;
19
+ }
20
+ } ) ;
Original file line number Diff line number Diff line change @@ -9,7 +9,8 @@ module.exports = {
9
9
'init' : require ( './commands/init' ) ,
10
10
'install' : require ( './commands/install' ) ,
11
11
'uninstall' : require ( './commands/uninstall' ) ,
12
- 'test' : require ( './commands/test' )
12
+ 'test' : require ( './commands/test' ) ,
13
+ 'lint' : require ( './commands/lint' )
13
14
} ;
14
15
}
15
16
} ;
Original file line number Diff line number Diff line change
1
+ /* jshint node: true */
2
+ 'use strict' ;
3
+
4
+ var Promise = require ( 'ember-cli/lib/ext/promise' ) ;
5
+ var Task = require ( 'ember-cli/lib/models/task' ) ;
6
+ var exec = Promise . denodeify ( require ( 'child_process' ) . exec ) ;
7
+
8
+ module . exports = Task . extend ( {
9
+ run : function ( ) {
10
+ var chalk = require ( 'chalk' ) ;
11
+ var ui = this . ui ;
12
+
13
+ return exec ( 'npm run lint' )
14
+ . then ( function ( ) {
15
+ ui . writeLine ( chalk . green ( 'Successfully linted files.' ) ) ;
16
+ } )
17
+ . catch ( function ( /*error*/ ) {
18
+ ui . writeLine ( chalk . red (
19
+ 'Couldn\'t do \'npm run lint\'. Please check this script exists in your package.json.'
20
+ ) ) ;
21
+ } ) ;
22
+ }
23
+ } ) ;
You can’t perform that action at this time.
0 commit comments