Skip to content

Commit

Permalink
fix(angular): check for root tslint.json before updating to support E…
Browse files Browse the repository at this point in the history
…Slint (#4816)

Closes #4761
  • Loading branch information
brandonroberts authored Feb 17, 2021
1 parent 78a6f98 commit 5d9c76b
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 20 deletions.
7 changes: 7 additions & 0 deletions packages/workspace/src/generators/init/init.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,13 @@ describe('workspace', () => {
const prettierIgnore = tree.read('/.prettierignore').toString();
expect(prettierIgnore).toBe('# existing ignore rules');
});

it('should work with no root tslint.json', async () => {
tree.delete('/tslint.json');
await initGenerator(tree, { name: 'myApp' });

expect(tree.exists('/tslint.json')).toBe(false);
});
});

describe('preserve angular cli layout', () => {
Expand Down
42 changes: 22 additions & 20 deletions packages/workspace/src/generators/init/init.ts
Original file line number Diff line number Diff line change
Expand Up @@ -294,27 +294,29 @@ function updateTsConfigsJson(host: Tree, options: Schema) {
}

function updateTsLint(host: Tree) {
updateJson(host, 'tslint.json', (tslintJson) => {
[
'no-trailing-whitespace',
'one-line',
'quotemark',
'typedef-whitespace',
'whitespace',
].forEach((key) => {
tslintJson[key] = undefined;
if (host.exists(`tslint.json`)) {
updateJson(host, 'tslint.json', (tslintJson) => {
[
'no-trailing-whitespace',
'one-line',
'quotemark',
'typedef-whitespace',
'whitespace',
].forEach((key) => {
tslintJson[key] = undefined;
});
tslintJson.rulesDirectory = tslintJson.rulesDirectory || [];
tslintJson.rulesDirectory.push('node_modules/@nrwl/workspace/src/tslint');
tslintJson.rules['nx-enforce-module-boundaries'] = [
true,
{
allow: [],
depConstraints: [{ sourceTag: '*', onlyDependOnLibsWithTags: ['*'] }],
},
];
return tslintJson;
});
tslintJson.rulesDirectory = tslintJson.rulesDirectory || [];
tslintJson.rulesDirectory.push('node_modules/@nrwl/workspace/src/tslint');
tslintJson.rules['nx-enforce-module-boundaries'] = [
true,
{
allow: [],
depConstraints: [{ sourceTag: '*', onlyDependOnLibsWithTags: ['*'] }],
},
];
return tslintJson;
});
}
}

function updateProjectTsLint(host: Tree, options: Schema) {
Expand Down

0 comments on commit 5d9c76b

Please sign in to comment.