From e65993f0059679a601dd5fd5533e34b9a33ca63a Mon Sep 17 00:00:00 2001 From: Peter Blazejewicz Date: Sun, 2 Jun 2019 14:35:49 +0200 Subject: [PATCH] fix(nx): correct path of TSLint config. Fixes #1435 This change: - fixes path in TSLint config template - add tests coverage for creation and content of the library `tslint.json` configuration file Thanks! --- .../src/schematics/library/files/lib/tslint.json | 2 +- .../src/schematics/library/library.spec.ts | 16 ++++++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/packages/workspace/src/schematics/library/files/lib/tslint.json b/packages/workspace/src/schematics/library/files/lib/tslint.json index 21a0b8e65d..ab29a2a848 100644 --- a/packages/workspace/src/schematics/library/files/lib/tslint.json +++ b/packages/workspace/src/schematics/library/files/lib/tslint.json @@ -1,4 +1,4 @@ { - "extends": "<%= offsetFromRoot %>/tslint.json", + "extends": "<%= offsetFromRoot %>tslint.json", "rules": [] } diff --git a/packages/workspace/src/schematics/library/library.spec.ts b/packages/workspace/src/schematics/library/library.spec.ts index 7fc3426fcb..40f635f1db 100644 --- a/packages/workspace/src/schematics/library/library.spec.ts +++ b/packages/workspace/src/schematics/library/library.spec.ts @@ -150,6 +150,8 @@ describe('lib', () => { expect( tree.exists('libs/my-dir/my-lib/src/lib/my-dir-my-lib.ts') ).toBeTruthy(); + expect(tree.exists('libs/my-dir/my-lib/src/index.ts')).toBeTruthy(); + expect(tree.exists(`libs/my-dir/my-lib/tslint.json`)).toBeTruthy(); }); it('should update angular.json', async () => { @@ -209,6 +211,20 @@ describe('lib', () => { include: ['**/*.ts'] }); }); + + it('should create a local tslint.json', async () => { + const tree = await runSchematic( + 'lib', + { name: 'myLib', directory: 'myDir' }, + appTree + ); + + const tslintJson = readJsonInTree(tree, 'libs/my-dir/my-lib/tslint.json'); + expect(tslintJson).toEqual({ + extends: '../../../tslint.json', + rules: [] + }); + }); }); describe('--unit-test-runner none', () => {