9
9
import { Rule , SchematicContext , TaskId , Tree } from '@angular-devkit/schematics' ;
10
10
import { RunSchematicTask , TslintFixTask } from '@angular-devkit/schematics/tasks' ;
11
11
import { getWorkspace } from '@schematics/angular/utility/config' ;
12
- import * as path from 'path' ;
12
+ import { TargetVersion } from './index' ;
13
+ import { createTslintConfig } from './tslint-update' ;
13
14
14
15
/** Entry point for `ng update` from Angular CLI. */
15
- export default function ( ) : Rule {
16
+ export function createUpdateRule ( targetVersion : TargetVersion ) : Rule {
16
17
return ( tree : Tree , context : SchematicContext ) => {
17
18
18
19
const allTsConfigPaths = getTsConfigPaths ( tree ) ;
@@ -23,64 +24,11 @@ export default function(): Rule {
23
24
'Material repository that includes the name of your TypeScript configuration.' ) ;
24
25
}
25
26
27
+ const tslintConfig = createTslintConfig ( targetVersion ) ;
28
+
26
29
for ( const tsconfig of allTsConfigPaths ) {
27
30
// Run the update tslint rules.
28
- tslintFixTasks . push ( context . addTask ( new TslintFixTask ( {
29
- rulesDirectory : [
30
- path . join ( __dirname , 'rules/' ) ,
31
- path . join ( __dirname , 'rules/attribute-selectors' ) ,
32
- path . join ( __dirname , 'rules/class-names' ) ,
33
- path . join ( __dirname , 'rules/class-inheritance' ) ,
34
- path . join ( __dirname , 'rules/input-names' ) ,
35
- path . join ( __dirname , 'rules/output-names' ) ,
36
- path . join ( __dirname , 'rules/css-selectors' ) ,
37
- path . join ( __dirname , 'rules/element-selectors' ) ,
38
- path . join ( __dirname , 'rules/property-names' ) ,
39
- path . join ( __dirname , 'rules/method-calls' ) ,
40
- ] ,
41
- rules : {
42
- // Attribute selector update rules.
43
- 'attribute-selectors-string-literal' : true ,
44
- 'attribute-selectors-stylesheet' : true ,
45
- 'attribute-selectors-template' : true ,
46
-
47
- // Class name update rules
48
- 'class-names-identifier' : true ,
49
- 'class-names-identifier-misc' : true ,
50
-
51
- // CSS selectors update rules
52
- 'css-selectors-string-literal' : true ,
53
- 'css-selectors-stylesheet' : true ,
54
- 'css-selectors-template' : true ,
55
-
56
- // Element selector update rules
57
- 'element-selectors-string-literal' : true ,
58
- 'element-selectors-stylesheet' : true ,
59
- 'element-selectors-template' : true ,
60
-
61
- // Input name update rules
62
- 'input-names-stylesheet' : true ,
63
- 'input-names-template' : true ,
64
-
65
- // Output name update rules
66
- 'output-names-template' : true ,
67
-
68
- // Property name update rules
69
- 'property-names-access' : true ,
70
- 'property-names-misc' : true ,
71
-
72
- // Method call checks
73
- 'method-calls-check' : true ,
74
-
75
- // Class inheritance
76
- 'class-inheritance-check' : true ,
77
- 'class-inheritance-misc' : true ,
78
-
79
- // Additional misc rules.
80
- 'check-import-misc' : true ,
81
- 'check-template-misc' : true
82
- }
83
- } , {
31
+ tslintFixTasks . push ( context . addTask ( new TslintFixTask ( tslintConfig , {
84
32
silent : false ,
85
33
ignoreErrors : true ,
86
34
tsConfigPath : tsconfig ,
@@ -92,13 +40,6 @@ export default function(): Rule {
92
40
} ;
93
41
}
94
42
95
- /** Post-update schematic to be called when update is finished. */
96
- export function postUpdate ( ) : Rule {
97
- return ( ) => console . log (
98
- '\nComplete! Please check the output above for any issues that were detected but could not' +
99
- ' be automatically fixed.' ) ;
100
- }
101
-
102
43
/**
103
44
* Gets all tsconfig paths from a CLI project by reading the workspace configuration
104
45
* and looking for common tsconfig locations.
0 commit comments