Skip to content

Commit 0a406e8

Browse files
committed
refactor(@angular-devkit/build-angular) remove _loadTslint method
1 parent 96bee9c commit 0a406e8

File tree

1 file changed

+11
-17
lines changed
  • packages/angular_devkit/build_angular/src/tslint

1 file changed

+11
-17
lines changed

packages/angular_devkit/build_angular/src/tslint/index.ts

+11-17
Original file line numberDiff line numberDiff line change
@@ -22,18 +22,6 @@ interface LintResult extends tslint.LintResult {
2222
fileNames: string[];
2323
}
2424

25-
async function _loadTslint() {
26-
let tslint;
27-
try {
28-
tslint = await import('tslint');
29-
} catch {
30-
throw new Error('Unable to find TSLint. Ensure TSLint is installed.');
31-
}
32-
33-
return tslint;
34-
}
35-
36-
3725
async function _run(
3826
options: TslintBuilderOptions,
3927
context: BuilderContext,
@@ -55,11 +43,17 @@ async function _run(
5543
throw new Error('A "project" must be specified to enable type checking.');
5644
}
5745

58-
const projectTslint = await _loadTslint();
46+
let tslint;
47+
try {
48+
tslint = await import('tslint');
49+
} catch {
50+
throw new Error('Unable to find TSLint. Ensure TSLint is installed.');
51+
}
52+
5953
const tslintConfigPath = options.tslintConfig
6054
? path.resolve(systemRoot, options.tslintConfig)
6155
: null;
62-
const Linter = projectTslint.Linter;
56+
const Linter = tslint.Linter;
6357

6458
let result: undefined | LintResult = undefined;
6559
if (options.tsConfig) {
@@ -72,7 +66,7 @@ async function _run(
7266
let i = 0;
7367
for (const program of allPrograms) {
7468
const partial = await _lint(
75-
projectTslint,
69+
tslint,
7670
systemRoot,
7771
tslintConfigPath,
7872
options,
@@ -102,15 +96,15 @@ async function _run(
10296
context.reportProgress(++i, allPrograms.length);
10397
}
10498
} else {
105-
result = await _lint(projectTslint, systemRoot, tslintConfigPath, options);
99+
result = await _lint(tslint, systemRoot, tslintConfigPath, options);
106100
}
107101

108102
if (result == undefined) {
109103
throw new Error('Invalid lint configuration. Nothing to lint.');
110104
}
111105

112106
if (!options.silent) {
113-
const Formatter = projectTslint.findFormatter(options.format || '');
107+
const Formatter = tslint.findFormatter(options.format || '');
114108
if (!Formatter) {
115109
throw new Error(`Invalid lint format "${options.format}".`);
116110
}

0 commit comments

Comments
 (0)