From 639b1e344d42cd30edf080cc64730c60129ac7d4 Mon Sep 17 00:00:00 2001 From: Martin Duran Date: Fri, 7 Sep 2018 14:10:55 -0500 Subject: [PATCH 1/5] Adds tslint config --- linters/tslint.json | 153 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 153 insertions(+) create mode 100644 linters/tslint.json diff --git a/linters/tslint.json b/linters/tslint.json new file mode 100644 index 0000000000..2a77ee9fc0 --- /dev/null +++ b/linters/tslint.json @@ -0,0 +1,153 @@ +{ + "extends": ["tslint-eslint-rules"], + "rules": { + + // RECOMMENDATIONS + + "interface-name": [true, "always-prefix"], // Require interface names to begin with a capital ‘I’ + "deprecation": true, // Warn when deprecated APIs are used + + // MODULES + + "no-duplicate-imports": true, // Disallow duplicate imports + + // ARROW FUNCTIONS + + "prefer-arrow-callback": 2, // Require arrow functions as callbacks + "arrow-spacing": [2, { // Require space before/after arrows + "before": true, + "after": true + }], + + // VARIABLES + + "variable-name": [ // Check variable names for various errors + true, + "ban-keywords", + "check-format", + "allow-leading-underscore", + "allow-pascal-case" + ], + "one-variable-per-declaration": true, // Disallow multiple variable definitions in the same declaration statement + "no-duplicate-variable": [ // Disallow duplicate variable declarations in the same block scope, including parameters + true, + "check-parameters" + ], + "no-unused-expression": true, // Disallow unused expression statements + "no-shadowed-variable": true, // Disallow shadowing variable declarations + "no-unused-variable": true, // Disallow unused imports, variables, functions and private class members + "no-use-before-declare": true, // Disallow usage of variables before their declaration + "no-var-keyword": true, // Disallow usage of the var keyword + "prefer-const": true, // Require const when not reassigned + + // OBJECTS + + "object-literal-shorthand": true, // Enforce use of ES6 object literal shorthand + + // TYPES + + "typedef": [ // Require type definitions to exist + true, + "parameter", + "property-declaration" + ], + "typedef-whitespace": [ // Enforce one space after type information + true, + { + "call-signature": "nospace", + "index-signature": "nospace", + "parameter": "nospace", + "property-declaration": "nospace", + "variable-declaration": "nospace" + } + ], + "no-any": true, // Disallow usage of any as a type declaration + "ban-types": [ // Disallow use of Object and String types + true, + ["Object"], + ["Boolean"], + ["String"] + ], + "no-extra-boolean-cast": true, // Prevent unnecessary boolean cast + "no-invalid-regexp": true, // Disallow invalid regular expression strings in the RegExp constructor + "no-construct": true, // Disallow String/Number/Boolean constructors + "radix": true, // Require the radix parameter to be specified when calling parseInt + "no-bitwise": true, // Disallow bitwise operators + + // STRINGS + + "no-eval": true, // Disallow eval function invocations + "quotemark": [true, "single", "jsx-double"], // Prefer single quotes for strings + + // BLOCKS + + "forin": true, // Require a for ... in statement to be filtered with an if statement + "curly": [true, "ignore-same-line"], // Enforce braces for if/for/do/while statements + + // COMPARISON + + "no-duplicate-switch-case": true, // Prevent duplicate cases in switch statements + "no-conditional-assignment": true, // Disallow assignment within conditionals + "cyclomatic-complexity": [true, 8], // Enforce a threshold of cyclomatic complexity + "no-switch-case-fall-through": true, // Disallow falling through case statements + "triple-equals": [true, "allow-null-check"], // Require === and !==, allow null check + + // WHITESPACE + + "whitespace": [ // Enforce whitespace style conventions + true, + "check-branch", + "check-decl", + "check-module", + "check-operator", + "check-separator", + "check-rest-spread", + "check-type", + "check-typecast", + "check-type-operator", + "check-preblock" + ], + "object-curly-spacing": [2, "always"], // Require spaces inside object curly braces + "indent": [true, "spaces", 4], // Enforce 4 spaces + "no-irregular-whitespace": true, // Disallow irregular whitespace + "no-trailing-whitespace": true, // Disallow trailing whitespace at the end of a line + "array-bracket-spacing": [2, "never"], // Disallow spaces inside of brackets + "eofline": true, // Require file to end with a newline + "max-line-length": [ // Disallow lines over 100 characters + true, + { + "limit": 100, + "ignore-pattern": "^import " + } + ], + + // SEMICOLONS + + "semicolon": [true, "always"], // Require semicolons + "no-extra-semi": true, // Disallow extra semicolons + + // COMMENTS + + "jsdoc-format": true, // Enforce basic format rules for JSDoc comments + "valid-jsdoc": [2, { // Require docblocks match params/return type + "requireParamDescription": false, + "requireReturnDescription": false, + "requireReturn": false + }], + "comment-format": [ // Require a space before comment + true, + "check-space" + ], + + // COMMAS + + "trailing-comma": [ // Require trailing commas + true, + { + "multiline": "always", + "singleline": "never" + } + ] + + } +} \ No newline at end of file From effc13019721108dfa28ca9903fc5d257f9de900 Mon Sep 17 00:00:00 2001 From: Martin Duran Date: Fri, 7 Sep 2018 19:12:17 -0500 Subject: [PATCH 2/5] Adds no-multi-spaces --- linters/tslint.json | 1 + 1 file changed, 1 insertion(+) diff --git a/linters/tslint.json b/linters/tslint.json index 2a77ee9fc0..850c4e3a3b 100644 --- a/linters/tslint.json +++ b/linters/tslint.json @@ -94,6 +94,7 @@ // WHITESPACE + "no-multi-spaces": [true], // Disallow multiple spaces "whitespace": [ // Enforce whitespace style conventions true, "check-branch", From a7c2b6acf8cdb6164c9d80a2bf86b9ef8726119c Mon Sep 17 00:00:00 2001 From: Martin Duran Date: Thu, 13 Sep 2018 10:10:16 -0500 Subject: [PATCH 3/5] Changes interface-name rule to never-prefix --- linters/tslint.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/linters/tslint.json b/linters/tslint.json index 850c4e3a3b..88a1c9cd05 100644 --- a/linters/tslint.json +++ b/linters/tslint.json @@ -4,7 +4,7 @@ // RECOMMENDATIONS - "interface-name": [true, "always-prefix"], // Require interface names to begin with a capital ‘I’ + "interface-name": [true, "never-prefix"], // Require interface names to not have an “I” prefix "deprecation": true, // Warn when deprecated APIs are used // MODULES From efa3579004201a61358a1e29b21e042f221f6aca Mon Sep 17 00:00:00 2001 From: Martin Duran Date: Thu, 13 Sep 2018 15:26:57 -0500 Subject: [PATCH 4/5] Bans Function type --- linters/tslint.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/linters/tslint.json b/linters/tslint.json index 88a1c9cd05..0259c01a44 100644 --- a/linters/tslint.json +++ b/linters/tslint.json @@ -66,7 +66,8 @@ true, ["Object"], ["Boolean"], - ["String"] + ["String"], + ["Function"] ], "no-extra-boolean-cast": true, // Prevent unnecessary boolean cast "no-invalid-regexp": true, // Disallow invalid regular expression strings in the RegExp constructor From 044942d095df98909dbd9efb95eb686e5d49343a Mon Sep 17 00:00:00 2001 From: Martin Duran Date: Thu, 13 Sep 2018 15:56:53 -0500 Subject: [PATCH 5/5] Adds member-ordering rule --- linters/tslint.json | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/linters/tslint.json b/linters/tslint.json index 0259c01a44..ef1e3c94bc 100644 --- a/linters/tslint.json +++ b/linters/tslint.json @@ -6,6 +6,12 @@ "interface-name": [true, "never-prefix"], // Require interface names to not have an “I” prefix "deprecation": true, // Warn when deprecated APIs are used + "member-ordering": [ // Enforce member ordering + true, + { + "order": "fields-first" + } + ], // MODULES