From df4382f08295443a9a452954584d0fd364b8a1e6 Mon Sep 17 00:00:00 2001 From: Alan Agius Date: Fri, 13 Mar 2020 10:09:48 +0100 Subject: [PATCH] feat(@schematics/angular): update default tslint.json rules In tslint version 6, several recommanded rules have been removed in the following PRs: https://github.com/palantir/tslint/pull/4871 https://github.com/palantir/tslint/pull/4312 With this change, we bring back these rules in the CLI. --- .../angular/application/index_spec.ts | 2 +- .../workspace/files/tslint.json.template | 71 +++++++++++++++++-- 2 files changed, 65 insertions(+), 8 deletions(-) diff --git a/packages/schematics/angular/application/index_spec.ts b/packages/schematics/angular/application/index_spec.ts index 80e9c3412ef6..4e569a19a226 100644 --- a/packages/schematics/angular/application/index_spec.ts +++ b/packages/schematics/angular/application/index_spec.ts @@ -378,7 +378,7 @@ describe('Application Schematic', () => { const content = JSON.parse(tree.readContent('/tslint.json')); expect(content.extends).toMatch('tslint:recommended'); expect(content.rules['component-selector'][2]).toMatch('app'); - expect(content.rules['trailing-comma']).toBeDefined(); + expect(content.rules['no-console']).toBeDefined(); }); it(`should create correct paths when 'newProjectRoot' is blank`, async () => { diff --git a/packages/schematics/angular/workspace/files/tslint.json.template b/packages/schematics/angular/workspace/files/tslint.json.template index e77091336b06..def88d1c87aa 100644 --- a/packages/schematics/angular/workspace/files/tslint.json.template +++ b/packages/schematics/angular/workspace/files/tslint.json.template @@ -4,22 +4,34 @@ "codelyzer" ], "rules": { + "align": { + "options": [ + "parameters", + "statements" + ] + }, "array-type": false, - "arrow-parens": false, + "arrow-return-shorthand": true, + "curly": true, "deprecation": { "severity": "warning" }, + "eofline": true, "import-blacklist": [ true, "rxjs/Rx" ], - "interface-name": false, + "import-spacing": true, + "indent": { + "options": [ + "spaces" + ] + }, "max-classes-per-file": false, "max-line-length": [ true, 140 ], - "member-access": false, "member-ordering": [ true, { @@ -31,7 +43,6 @@ ] } ], - "no-consecutive-blank-lines": false, "no-console": [ true, "debug", @@ -53,13 +64,59 @@ true, "as-needed" ], - "object-literal-sort-keys": false, - "ordered-imports": false, "quotemark": [ true, "single" ], - "trailing-comma": false, + "semicolon": { + "options": [ + "always" + ] + }, + "space-before-function-paren": { + "options": { + "anonymous": "never", + "asyncArrow": "always", + "constructor": "never", + "method": "never", + "named": "never" + } + }, + "typedef-whitespace": { + "options": [ + { + "call-signature": "nospace", + "index-signature": "nospace", + "parameter": "nospace", + "property-declaration": "nospace", + "variable-declaration": "nospace" + }, + { + "call-signature": "onespace", + "index-signature": "onespace", + "parameter": "onespace", + "property-declaration": "onespace", + "variable-declaration": "onespace" + } + ] + }, + "variable-name": { + "options": [ + "ban-keywords", + "check-format", + "allow-pascal-case" + ] + }, + "whitespace": { + "options": [ + "check-branch", + "check-decl", + "check-operator", + "check-separator", + "check-type", + "check-typecast" + ] + }, "component-class-suffix": true, "contextual-lifecycle": true, "directive-class-suffix": true,