Skip to content

Commit aeb4ff5

Browse files
committed
feat(@schematics/angular): reallow --lint-fix for Angular schematics
1 parent d67a4bf commit aeb4ff5

File tree

23 files changed

+138
-6
lines changed

23 files changed

+138
-6
lines changed

packages/schematics/angular/component/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ import {
2929
import { InsertChange } from '../utility/change';
3030
import { getWorkspace } from '../utility/config';
3131
import { buildRelativePath, findModuleFromOptions } from '../utility/find-module';
32+
import { applyLintFix } from '../utility/lint-fix';
3233
import { parseName } from '../utility/parse-name';
3334
import { buildDefaultPath } from '../utility/project';
3435
import { validateHtmlSelector, validateName } from '../utility/validation';
@@ -164,6 +165,7 @@ export default function(options: ComponentOptions): Rule {
164165
addDeclarationToNgModule(options),
165166
mergeWith(templateSource),
166167
])),
168+
options.lintFix ? applyLintFix(options.path) : noop(),
167169
]);
168170
};
169171
}

packages/schematics/angular/component/schema.d.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,4 +71,8 @@ export interface Schema {
7171
* Specifies if the component is an entry component of declaring module.
7272
*/
7373
entryComponent?: boolean;
74+
/**
75+
* Specifies whether to apply lint fixes after generating the component.
76+
*/
77+
lintFix?: boolean;
7478
}

packages/schematics/angular/component/schema.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,11 @@
103103
"type": "boolean",
104104
"default": false,
105105
"description": "Specifies if the component is an entry component of declaring module."
106+
},
107+
"lintFix": {
108+
"type": "boolean",
109+
"default": false,
110+
"description": "Specifies whether to apply lint fixes after generating the component."
106111
}
107112
},
108113
"required": [],

packages/schematics/angular/directive/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import { addDeclarationToModule, addExportToModule } from '../utility/ast-utils'
2525
import { InsertChange } from '../utility/change';
2626
import { getWorkspace } from '../utility/config';
2727
import { buildRelativePath, findModuleFromOptions } from '../utility/find-module';
28+
import { applyLintFix } from '../utility/lint-fix';
2829
import { parseName } from '../utility/parse-name';
2930
import { buildDefaultPath } from '../utility/project';
3031
import { validateHtmlSelector } from '../utility/validation';
@@ -137,6 +138,7 @@ export default function (options: DirectiveOptions): Rule {
137138
addDeclarationToNgModule(options),
138139
mergeWith(templateSource),
139140
])),
141+
options.lintFix ? applyLintFix(options.path) : noop(),
140142
]);
141143
};
142144
}

packages/schematics/angular/directive/schema.d.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,4 +47,8 @@ export interface Schema {
4747
* Specifies if declaring module exports the directive.
4848
*/
4949
export?: boolean;
50+
/**
51+
* Specifies whether to apply lint fixes after generating the component.
52+
*/
53+
lintFix?: boolean;
5054
}

packages/schematics/angular/directive/schema.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,11 @@
6868
"type": "boolean",
6969
"default": false,
7070
"description": "Specifies if declaring module exports the directive."
71+
},
72+
"lintFix": {
73+
"type": "boolean",
74+
"default": false,
75+
"description": "Specifies whether to apply lint fixes after generating the directive."
7176
}
7277
},
7378
"required": [],

packages/schematics/angular/enum/index.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,12 @@ import {
1616
chain,
1717
mergeWith,
1818
move,
19+
noop,
1920
template,
2021
url,
2122
} from '@angular-devkit/schematics';
2223
import { getWorkspace } from '../utility/config';
24+
import { applyLintFix } from '../utility/lint-fix';
2325
import { parseName } from '../utility/parse-name';
2426
import { buildDefaultPath } from '../utility/project';
2527
import { Schema as EnumOptions } from './schema';
@@ -53,6 +55,7 @@ export default function (options: EnumOptions): Rule {
5355
branchAndMerge(chain([
5456
mergeWith(templateSource),
5557
])),
58+
options.lintFix ? applyLintFix(options.path) : noop(),
5659
]);
5760
};
5861
}

packages/schematics/angular/enum/schema.d.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,8 @@ export interface Schema {
1919
* The name of the project.
2020
*/
2121
project?: string;
22+
/**
23+
* Specifies whether to apply lint fixes after generating the component.
24+
*/
25+
lintFix?: boolean;
2226
}

packages/schematics/angular/enum/schema.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,11 @@
2424
"$default": {
2525
"$source": "projectName"
2626
}
27+
},
28+
"lintFix": {
29+
"type": "boolean",
30+
"default": false,
31+
"description": "Specifies whether to apply lint fixes after generating the enum."
2732
}
2833
},
2934
"required": [],

packages/schematics/angular/guard/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import {
2121
url,
2222
} from '@angular-devkit/schematics';
2323
import { getWorkspace } from '../utility/config';
24+
import { applyLintFix } from '../utility/lint-fix';
2425
import { parseName } from '../utility/parse-name';
2526
import { buildDefaultPath } from '../utility/project';
2627
import { Schema as GuardOptions } from './schema';
@@ -55,6 +56,7 @@ export default function (options: GuardOptions): Rule {
5556
branchAndMerge(chain([
5657
mergeWith(templateSource),
5758
])),
59+
options.lintFix ? applyLintFix(options.path) : noop(),
5860
]);
5961
};
6062
}

0 commit comments

Comments
 (0)