Skip to content

Commit dec1bc1

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

File tree

20 files changed

+121
-7
lines changed

20 files changed

+121
-7
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
@@ -29,6 +29,7 @@ import { parseName } from '../utility/parse-name';
2929
import { buildDefaultPath } from '../utility/project';
3030
import { validateHtmlSelector } from '../utility/validation';
3131
import { Schema as DirectiveOptions } from './schema';
32+
import {applyLintFix} from "../utility/lint-fix";
3233

3334

3435
function addDeclarationToNgModule(options: DirectiveOptions): Rule {
@@ -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/guard/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import { getWorkspace } from '../utility/config';
2424
import { parseName } from '../utility/parse-name';
2525
import { buildDefaultPath } from '../utility/project';
2626
import { Schema as GuardOptions } from './schema';
27+
import {applyLintFix} from "../utility/lint-fix";
2728

2829

2930
export default function (options: GuardOptions): Rule {
@@ -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
}

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,4 +27,8 @@ export interface Schema {
2727
* The name of the project.
2828
*/
2929
project?: string;
30+
/**
31+
* Specifies whether to apply lint fixes after generating the component.
32+
*/
33+
lintFix?: boolean;
3034
}

packages/schematics/angular/guard/schema.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,11 @@
3434
"$default": {
3535
"$source": "projectName"
3636
}
37+
},
38+
"lintFix": {
39+
"type": "boolean",
40+
"default": false,
41+
"description": "Specifies whether to apply lint fixes after generating the guard."
3742
}
3843
},
3944
"required": [],

packages/schematics/angular/interface/index.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,12 @@ import {
1515
chain,
1616
mergeWith,
1717
move,
18+
noop,
1819
template,
1920
url,
2021
} from '@angular-devkit/schematics';
2122
import { getWorkspace } from '../utility/config';
23+
import { applyLintFix } from '../utility/lint-fix';
2224
import { parseName } from '../utility/parse-name';
2325
import { buildDefaultPath } from '../utility/project';
2426
import { Schema as InterfaceOptions } from './schema';
@@ -55,6 +57,7 @@ export default function (options: InterfaceOptions): Rule {
5557
branchAndMerge(chain([
5658
mergeWith(templateSource),
5759
])),
60+
options.lintFix ? applyLintFix(options.path) : noop(),
5861
]);
5962
};
6063
}

0 commit comments

Comments
 (0)