Skip to content
This repository was archived by the owner on May 1, 2020. It is now read-only.

Commit 989953b

Browse files
committed
feature(lint): ability to disable lint (used in Ionic E2E tests)
1 parent 64bc17f commit 989953b

File tree

3 files changed

+48
-6
lines changed

3 files changed

+48
-6
lines changed

src/build.spec.ts

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,8 @@ describe('build', () => {
4848
runAot: true
4949
};
5050

51+
const getBooleanPropertyValueSpy = spyOn(helpers, helpers.getBooleanPropertyValue.name).and.returnValue(true);
52+
5153
return build.build(context).then(() => {
5254
expect(helpers.readFileAsync).toHaveBeenCalled();
5355
expect(copy.copy).toHaveBeenCalled();
@@ -57,9 +59,11 @@ describe('build', () => {
5759
expect(sass.sass).toHaveBeenCalled();
5860
expect(minify.minifyCss).toHaveBeenCalled();
5961
expect(lint.lint).toHaveBeenCalled();
62+
expect(getBooleanPropertyValueSpy.calls.first().args[0]).toEqual(Constants.ENV_ENABLE_LINT);
6063

6164
expect(transpile.transpile).not.toHaveBeenCalled();
6265
}).catch(err => {
66+
console.log('err: ', err.message);
6367
expect(true).toEqual(false);
6468
});
6569
});
@@ -73,13 +77,45 @@ describe('build', () => {
7377
runAot: false
7478
};
7579

80+
const getBooleanPropertyValueSpy = spyOn(helpers, helpers.getBooleanPropertyValue.name).and.returnValue(true);
81+
7682
return build.build(context).then(() => {
7783
expect(helpers.readFileAsync).toHaveBeenCalled();
7884
expect(copy.copy).toHaveBeenCalled();
7985
expect(transpile.transpile).toHaveBeenCalled();
8086
expect(bundle.bundle).toHaveBeenCalled();
8187
expect(sass.sass).toHaveBeenCalled();
8288
expect(lint.lint).toHaveBeenCalled();
89+
expect(getBooleanPropertyValueSpy.calls.first().args[0]).toEqual(Constants.ENV_ENABLE_LINT);
90+
expect(postprocess.postprocess).toHaveBeenCalled();
91+
expect(preprocess.preprocess).toHaveBeenCalled();
92+
expect(ngc.ngc).not.toHaveBeenCalled();
93+
expect(minify.minifyJs).not.toHaveBeenCalled();
94+
expect(minify.minifyCss).not.toHaveBeenCalled();
95+
}).catch(err => {
96+
expect(true).toEqual(false);
97+
});
98+
});
99+
100+
it('should skip lint', () => {
101+
let context: BuildContext = {
102+
isProd: false,
103+
optimizeJs: false,
104+
runMinifyJs: false,
105+
runMinifyCss: false,
106+
runAot: false
107+
};
108+
109+
const getBooleanPropertyValueSpy = spyOn(helpers, helpers.getBooleanPropertyValue.name).and.returnValue(false);
110+
111+
return build.build(context).then(() => {
112+
expect(helpers.readFileAsync).toHaveBeenCalled();
113+
expect(copy.copy).toHaveBeenCalled();
114+
expect(transpile.transpile).toHaveBeenCalled();
115+
expect(bundle.bundle).toHaveBeenCalled();
116+
expect(sass.sass).toHaveBeenCalled();
117+
expect(lint.lint).not.toHaveBeenCalled();
118+
expect(getBooleanPropertyValueSpy.calls.first().args[0]).toEqual(Constants.ENV_ENABLE_LINT);
83119
expect(postprocess.postprocess).toHaveBeenCalled();
84120
expect(preprocess.preprocess).toHaveBeenCalled();
85121
expect(ngc.ngc).not.toHaveBeenCalled();

src/build.ts

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -126,11 +126,13 @@ function buildProject(context: BuildContext) {
126126
return postprocess(context);
127127
})
128128
.then(() => {
129-
// kick off the tslint after everything else
130-
// nothing needs to wait on its completion unless bailing on lint error is enabled
131-
const result = lint(context);
132-
if (getBooleanPropertyValue(Constants.ENV_BAIL_ON_LINT_ERROR)) {
133-
return result;
129+
if (getBooleanPropertyValue(Constants.ENV_ENABLE_LINT)) {
130+
// kick off the tslint after everything else
131+
// nothing needs to wait on its completion unless bailing on lint error is enabled
132+
const result = lint(context);
133+
if (getBooleanPropertyValue(Constants.ENV_BAIL_ON_LINT_ERROR)) {
134+
return result;
135+
}
134136
}
135137
})
136138
.catch(err => {
@@ -183,7 +185,9 @@ export function buildUpdate(changedFiles: ChangedFile[], context: BuildContext)
183185
if (requiresLintUpdate) {
184186
// a ts file changed, so let's lint it too, however
185187
// this task should run as an after thought
186-
lintUpdate(changedFiles, context);
188+
if (getBooleanPropertyValue(Constants.ENV_ENABLE_LINT)) {
189+
lintUpdate(changedFiles, context);
190+
}
187191
}
188192

189193
logger.finish('green', true);

src/util/constants.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,8 @@ export const ENV_OPTIMIZATION_LOADER = 'IONIC_OPTIMIZATION_LOADER';
5050
export const ENV_AOT_WRITE_TO_DISK = 'IONIC_AOT_WRITE_TO_DISK';
5151
export const ENV_BAIL_ON_LINT_ERROR = 'IONIC_BAIL_ON_LINT_ERROR';
5252
export const ENV_BUILD_TO_ES5 = 'IONIC_BUILD_TO_ES5';
53+
export const ENV_ENABLE_LINT = 'IONIC_ENABLE_LINT';
54+
export const ENV_DISABLE_LOGGING = 'IONIC_DISABLE_LOGGING';
5355

5456
export const ENV_PRINT_ORIGINAL_DEPENDENCY_TREE = 'IONIC_PRINT_ORIGINAL_DEPENDENCY_TREE';
5557
export const ENV_PRINT_MODIFIED_DEPENDENCY_TREE = 'IONIC_PRINT_MODIFIED_DEPENDENCY_TREE';

0 commit comments

Comments
 (0)