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

Preserve original linterOptions in tslint.json #1548

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions src/lint/lint-factory.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,20 @@ describe('lint factory', () => {
typeCheck: true
});
});

it('should extend configuration with {linterOptions} and preserve original linterOptions', () => {
const tsConfigFilePath = 'tsconfig.json';
const mockConfig = {rulesDirectory: ['node_modules/@ionic'], linterOptions: {exclude: ['vendor/**']}};
spyOn(Configuration, Configuration.loadConfigurationFromPath.name).and.returnValue(mockConfig);
const config = getTsLintConfig(tsConfigFilePath, {
typeCheck: true
});

expect(config.linterOptions).toEqual({
typeCheck: true,
exclude: ['vendor/**']
});
});
});

describe('createLinter()', () => {
Expand Down
8 changes: 7 additions & 1 deletion src/lint/lint-factory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,13 @@ export function getFileNames(context: BuildContext, program: Program): string[]
*/
export function getTsLintConfig(tsLintConfig: string, linterOptions?: LinterOptions): LinterConfig {
const config = Configuration.loadConfigurationFromPath(tsLintConfig);
Object.assign(config, isObject(linterOptions) ? {linterOptions} : {});
if (!isObject(linterOptions)) {
return config;
}
if (!config.linterOptions) {
config.linterOptions = {};
}
Object.assign(config.linterOptions, linterOptions);
return config;
}

Expand Down