Skip to content

Commit 3ec03e9

Browse files
clydinhansl
authored andcommitted
revert: build: integrate prettier code formatter
This reverts commit 920be3a.
1 parent 79f8413 commit 3ec03e9

File tree

7 files changed

+174
-500
lines changed

7 files changed

+174
-500
lines changed

.lintstagedrc

Lines changed: 0 additions & 5 deletions
This file was deleted.

.prettierrc

Lines changed: 0 additions & 5 deletions
This file was deleted.

etc/rules/Rule.ts

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
/**
2+
* @license
3+
* Copyright Google Inc. All Rights Reserved.
4+
*
5+
* Use of this source code is governed by an MIT-style license that can be
6+
* found in the LICENSE file at https://angular.io/license
7+
*/
8+
import * as Lint from 'tslint';
9+
import * as ts from 'typescript';
10+
11+
12+
// An empty rule so that tslint does not error on rules '//' (which are comments).
13+
export class Rule extends Lint.Rules.AbstractRule {
14+
public static metadata: Lint.IRuleMetadata = {
15+
ruleName: '//',
16+
type: 'typescript',
17+
description: ``,
18+
rationale: '',
19+
options: null,
20+
optionsDescription: `Not configurable.`,
21+
typescriptOnly: false,
22+
};
23+
24+
public apply(sourceFile: ts.SourceFile): Lint.RuleFailure[] {
25+
return [];
26+
}
27+
}

etc/rules/singleEofLineRule.ts

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
/**
2+
* @license
3+
* Copyright Google Inc. All Rights Reserved.
4+
*
5+
* Use of this source code is governed by an MIT-style license that can be
6+
* found in the LICENSE file at https://angular.io/license
7+
*/
8+
import * as Lint from 'tslint';
9+
import * as ts from 'typescript';
10+
11+
12+
export class Rule extends Lint.Rules.AbstractRule {
13+
public static metadata: Lint.IRuleMetadata = {
14+
ruleName: 'single-eof-line',
15+
type: 'style',
16+
description: `Ensure the file ends with a single new line.`,
17+
rationale: `This is similar to eofline, but ensure an exact count instead of just any new
18+
line.`,
19+
options: null,
20+
optionsDescription: `Two integers indicating minimum and maximum number of new lines.`,
21+
typescriptOnly: false,
22+
};
23+
24+
public static FAILURE_STRING = 'You need to have a single blank line at end of file.';
25+
26+
public apply(sourceFile: ts.SourceFile): Lint.RuleFailure[] {
27+
const length = sourceFile.text.length;
28+
if (length === 0) {
29+
// Allow empty files.
30+
return [];
31+
}
32+
33+
const matchEof = /\r?\n((\r?\n)*)$/.exec(sourceFile.text);
34+
if (!matchEof) {
35+
const lines = sourceFile.getLineStarts();
36+
const fix = Lint.Replacement.appendText(
37+
length,
38+
sourceFile.text[lines[1] - 2] === '\r' ? '\r\n' : '\n',
39+
);
40+
41+
return [
42+
new Lint.RuleFailure(sourceFile, length, length, Rule.FAILURE_STRING, this.ruleName, fix),
43+
];
44+
} else if (matchEof[1]) {
45+
const lines = sourceFile.getLineStarts();
46+
const fix = Lint.Replacement.replaceFromTo(
47+
matchEof.index,
48+
length,
49+
sourceFile.text[lines[1] - 2] === '\r' ? '\r\n' : '\n',
50+
);
51+
52+
return [
53+
new Lint.RuleFailure(sourceFile, length, length, Rule.FAILURE_STRING, this.ruleName, fix),
54+
];
55+
}
56+
57+
return [];
58+
}
59+
}

package.json

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
"build-tsc": "tsc -p tsconfig.json",
2525
"fix": "npm run admin -- lint --fix",
2626
"lint": "npm run admin -- lint",
27-
"precise-commits": "precise-commits",
2827
"prebuildifier": "bazel build --noshow_progress @com_github_bazelbuild_buildtools//buildifier",
2928
"buildifier": "find . -type f \\( -name BUILD -or -name BUILD.bazel \\) ! -path \"*/node_modules/*\" | xargs $(bazel info bazel-bin)/external/com_github_bazelbuild_buildtools/buildifier/buildifier",
3029
"templates": "node ./bin/devkit-admin templates",
@@ -34,6 +33,7 @@
3433
"test:watch": "nodemon --watch packages -e ts ./bin/devkit-admin test",
3534
"validate": "node ./bin/devkit-admin validate",
3635
"validate-commits": "./bin/devkit-admin validate-commits",
36+
"prepush": "node ./bin/devkit-admin hooks/pre-push",
3737
"preinstall": "node ./tools/yarn/check-yarn.js",
3838
"webdriver-update": "webdriver-manager update --standalone false --gecko false --versions.chrome 2.45"
3939
},
@@ -103,23 +103,20 @@
103103
"conventional-commits-parser": "^3.0.0",
104104
"gh-got": "^8.0.1",
105105
"git-raw-commits": "^2.0.0",
106-
"husky": "^1.3.1",
106+
"husky": "^0.14.3",
107107
"istanbul": "^0.4.5",
108108
"jasmine": "^2.6.0",
109109
"jasmine-spec-reporter": "^4.2.1",
110110
"karma": "~4.0.0",
111111
"karma-jasmine": "^2.0.1",
112112
"karma-jasmine-html-reporter": "^1.4.0",
113113
"license-checker": "^20.1.0",
114-
"lint-staged": "^8.1.4",
115114
"minimatch": "^3.0.4",
116115
"minimist": "^1.2.0",
117116
"npm-registry-client": "8.6.0",
118117
"pacote": "^9.2.3",
119118
"pidtree": "^0.3.0",
120119
"pidusage": "^2.0.17",
121-
"precise-commits": "^1.0.2",
122-
"prettier": "^1.16.4",
123120
"rxjs": "~6.4.0",
124121
"semver": "^5.3.0",
125122
"source-map": "^0.5.6",
@@ -129,14 +126,7 @@
129126
"through2": "^2.0.3",
130127
"tree-kill": "^1.2.0",
131128
"ts-node": "^5.0.0",
132-
"tslint-config-prettier": "^1.18.0",
133129
"tslint-no-circular-imports": "^0.6.0",
134130
"tslint-sonarts": "^1.7.0"
135-
},
136-
"husky": {
137-
"hooks": {
138-
"pre-commit": "lint-staged",
139-
"pre-push": "node ./bin/devkit-admin hooks/pre-push"
140-
}
141131
}
142132
}

tslint.json

Lines changed: 60 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,23 +3,19 @@
33
// Consider using cognitive-complexity and refactor
44
// Consider using no-useless-cast but it's annoying
55
"extends": [
6-
"tslint-no-circular-imports",
7-
"tslint-config-prettier"
6+
"tslint-no-circular-imports"
87
],
98
"rulesDirectory": [
109
"dist/etc/rules",
1110
"node_modules/tslint-sonarts/lib/rules"
1211
],
13-
"linterOptions": {
14-
"exclude": ["dist-schema/**"],
15-
"format": "codeFrame"
16-
},
1712
"rules": {
1813
// ==================================================================================================
1914
// custom rules defined in etc/rules/**
2015
"defocus": true,
2116
"import-groups": true,
2217
"no-global-tslint-disable": true,
18+
"single-eof-line": true,
2319
// ==================================================================================================
2420
// tslint-sonarts rules. See https://github.com/SonarSource/SonarTS
2521
// These rules are part of the bug detection section of tslint-sonarts
@@ -56,21 +52,45 @@
5652
"no-floating-promises": true,
5753
"no-implicit-dependencies": true,
5854
"no-import-side-effect": [true, {"ignore-module": "^(?!rxjs\/)"}],
55+
"align": [
56+
true,
57+
"elements",
58+
"members",
59+
"parameters",
60+
"statements"
61+
],
62+
"max-line-length": [true, 100],
5963
"no-inferrable-types": true,
6064
"class-name": true,
6165
"comment-format": [
6266
true,
6367
"check-space"
6468
],
69+
"indent": [
70+
true,
71+
"spaces"
72+
],
73+
"eofline": true,
74+
"import-spacing": true,
6575
"match-default-export-name": true,
6676
"newline-before-return": true,
77+
"no-consecutive-blank-lines": [true, 2],
6778
"no-duplicate-variable": true,
6879
"no-eval": true,
6980
"no-any": true,
7081
"no-arg": true,
7182
"no-internal-module": true,
83+
"no-trailing-whitespace": true,
7284
"no-unused-expression": true,
7385
"no-var-keyword": true,
86+
"one-line": [
87+
true,
88+
"check-catch",
89+
"check-else",
90+
"check-finally",
91+
"check-open-brace",
92+
"check-whitespace"
93+
],
7494
"ordered-imports": [
7595
true,
7696
{
@@ -79,6 +99,29 @@
7999
}
80100
],
81101
"prefer-const": true,
102+
"quotemark": [
103+
true,
104+
"single",
105+
"avoid-escape"
106+
],
107+
"semicolon": [true, "always"],
108+
"trailing-comma": [
109+
true,
110+
{
111+
"multiline": "always",
112+
"singleline": "never"
113+
}
114+
],
115+
"typedef-whitespace": [
116+
true,
117+
{
118+
"call-signature": "nospace",
119+
"index-signature": "nospace",
120+
"parameter": "nospace",
121+
"property-declaration": "nospace",
122+
"variable-declaration": "nospace"
123+
}
124+
],
82125
"curly": true,
83126
"file-header": [
84127
true,
@@ -90,6 +133,17 @@
90133
"check-format",
91134
"allow-leading-underscore",
92135
"allow-pascal-case"
136+
],
137+
"whitespace": [
138+
true,
139+
"check-branch",
140+
"check-decl",
141+
"check-module",
142+
"check-preblock",
143+
"check-operator",
144+
"check-separator",
145+
"check-type",
146+
"check-typecast"
93147
]
94148
}
95149
}

0 commit comments

Comments
 (0)