Skip to content
This repository was archived by the owner on Nov 22, 2024. It is now read-only.

Commit

Permalink
build: add some tsrule to aid consistence and avoid code smells
Browse files Browse the repository at this point in the history
  • Loading branch information
alan-agius4 committed Dec 24, 2019
1 parent 00266c2 commit 59d5dbc
Show file tree
Hide file tree
Showing 2 changed files with 94 additions and 19 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
},
"scripts": {
"postinstall": "ngc -p ./angular-metadata.tsconfig.json && node --preserve-symlinks --preserve-symlinks-main ./tools/postinstall-patches.js && yarn ngcc",
"lint": "tslint -c tslint.json '+(modules|tools)/**/*.ts' --exclude '**/+(node_modules|hello-world-app)/**/*'",
"lint": "tslint -c tslint.json '+(modules|tools)/**/*.ts' -p tsconfig.json",
"build": "npm run bazel:build",
"prebuildifier": "bazel build --noshow_progress @com_github_bazelbuild_buildtools//buildifier",
"bazel:format": "find . -type f \\( -name \"*.bzl\" -or -name BUILD -or -name BUILD.bazel -or -name WORKSPACE \\) ! -path \"*/node_modules/*\" | xargs buildifier -v",
Expand Down
111 changes: 93 additions & 18 deletions tslint.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,44 +3,97 @@
"./tools/tslint-rules/"
],
"rules": {
"max-line-length": [true, 100],
"max-line-length": [
true,
100
],
// Disable this flag because of SHA tslint#48b0c597f9257712c7d1f04b55ed0aa60e333f6a
// TSLint now shows warnings if types for properties are inferred. This rule needs to be
// disabled because all properties need to have explicit types set to work for Dgeni.
"no-inferrable-types": false,
"arrow-return-shorthand": true,
"no-duplicate-imports": true,
"no-angle-bracket-type-assertion": true,
"no-conditional-assignment": true,
"no-non-null-assertion": true,
"no-unnecessary-qualifier": true,
"no-string-throw": true,
"encoding": true,
"no-floating-promises": true,
"no-import-side-effect": [
true,
{
"ignore-module": "^(?!rxjs\/)"
}
],
"align": [
true,
"elements",
"members",
"parameters",
"statements"
],
"class-name": true,
"comment-format": [
true,
"check-space"
],
"indent": [
true,
"spaces"
"spaces",
2
],
"array-type": [
true,
"array-simple"
],
"deprecation": {
"severity": "warning"
},
"eofline": true,
"import-spacing": false,
"match-default-export-name": true,
"newline-before-return": true,
"no-consecutive-blank-lines": [
true,
2
],
"no-duplicate-variable": true,
"no-eval": true,
"no-arg": true,
"no-internal-module": true,
"no-trailing-whitespace": true,
"no-bitwise": true,
"no-shadowed-variable": true,
"no-debugger": true,
"no-console": true,
"no-internal-module": true,
"no-trailing-whitespace": true,
"no-unused-expression": true,
"no-var-keyword": true,
"no-debugger": true,
"one-line": [
true,
"check-catch",
"check-else",
"check-finally",
"check-open-brace",
"check-whitespace"
],
"ordered-imports": [
true,
{
"import-sources-order": "lowercase-last",
"named-imports-order": "lowercase-last"
}
],
"prefer-const": true,
"quotemark": [
true,
"single",
"avoid-escape"
],
"semicolon": true,
"semicolon": [
true,
"always"
],
"typedef-whitespace": [
true,
{
Expand All @@ -56,33 +109,52 @@
true,
"ban-keywords",
"check-format",
"allow-leading-underscore"
"allow-leading-underscore",
"allow-pascal-case"
],
"whitespace": [
true,
"check-branch",
"check-decl",
"check-module",
"check-preblock",
"check-operator",
"check-separator",
"check-type",
"check-preblock"
"check-typecast"
],
// Bans jasmine helper functions that will prevent the CI from properly running tests.
"ban": [
true,
["fit"],
["fdescribe"],
["xit"],
["xdescribe"],
{"name": "Object.assign", "message": "Use the spread operator instead."}
[
"fit"
],
[
"fdescribe"
],
[
"xit"
],
[
"xdescribe"
],
{
"name": "Object.assign",
"message": "Use the spread operator instead."
}
],
// Disallows importing the whole RxJS library. Submodules can be still imported.
// Avoids inconsistent linebreak styles in source files. Forces developers to use LF linebreaks.
"linebreak-style": [true, "LF"],
"linebreak-style": [
true,
"LF"
],
// Namespaces are no allowed, because of Closure compiler.
"no-namespace": true,
"jsdoc-format": [true, "check-multiline-start"],

"jsdoc-format": [
true,
"check-multiline-start"
],
// Custom Rules
"ts-loader": true,
"no-exposed-todo": true,
Expand All @@ -97,9 +169,12 @@
"deletion-target": true
},
"linterOptions": {
"format": "codeFrame",
"exclude": [
// Exclude schematic template files that can't be linted.
"**/schematics/**/files/**/*"
"**/schematics/**/files/**/*",
"**/node_modules/**/*",
"**/hello-world-app/**/*"
]
}
}
}

0 comments on commit 59d5dbc

Please sign in to comment.