@node-ts/code-standards
Version:
A sane and opinionated set of linting rules for TypeScript
198 lines (197 loc) • 6.11 kB
JSON
{
"extends": "tslint:latest",
"rules": {
"no-unnecessary-type-assertion": true,
"array-type": [
true,
"array"
],
"ban-types": {
"options": [
[
"Object",
"Avoid using the `Object` type. Did you mean `object`?"
],
[
"Function",
"Avoid using the `Function` type. Prefer a specific function type, like `() => void`, or use `ts.AnyFunction`."
],
[
"Boolean",
"Avoid using the `Boolean` type. Did you mean `boolean`?"
],
[
"Number",
"Avoid using the `Number` type. Did you mean `number`?"
],
[
"String",
"Avoid using the `String` type. Did you mean `string`?"
]
]
},
"jsdoc-format": true,
"no-internal-module": true,
"no-null-keyword": true,
"no-unnecessary-qualifier": true,
"object-literal-shorthand": true,
"space-within-parens": true,
"triple-equals": true,
// Config different from tslint:latest
"no-implicit-dependencies": [
true,
"dev"
],
"arrow-parens": [true, "ban-single-arg-parens"],
"member-access": [true, "no-public"],
"no-conditional-assignment": true,
"no-console": true,
"no-debugger": true,
"no-eval": true,
"no-object-literal-type-assertion": false,
"no-shadowed-variable": true,
"no-submodule-imports": false,
"ordered-imports": false,
"prefer-conditional-expression": false,
"radix": true,
"file-name-casing": [true, "kebab-case"],
"eofline": true,
"max-line-length": [true, 120],
"ban-comma-operator": true,
"no-angle-bracket-type-assertion": true,
"no-bitwise": false,
"object-literal-sort-keys": false,
"adjacent-overload-signatures": true,
"align": [true, "parameters"],
"arrow-return-shorthand": true,
"await-promise": true,
"callable-types": true,
"class-name": true,
"comment-format": [true, "check-space", "check-uppercase"],
"completed-docs": false, // Should be enabled for domain/busines logic packages
"curly": true,
"cyclomatic-complexity": [true, 20],
"forin": true,
"import-blacklist": [
true,
".",
"./",
"./.",
"../",
"../.",
"../../",
"../../.",
"../../../",
"../../../."
],
"import-spacing": true,
"indent": [true, "spaces", 2],
"interface-name": [true, "never-prefix"],
"interface-over-type-literal": true,
"label-position": true,
"linebreak-style": [true, "LF"],
"max-classes-per-file": [true, 1],
"max-file-line-count": [true, 500],
"member-ordering": [true, {
"order": [
"public-static-field",
"protected-static-field",
"private-static-field",
"public-instance-field",
"protected-instance-field",
"private-instance-field",
"public-constructor",
"protected-constructor",
"private-constructor",
"public-static-method",
"protected-static-method",
"private-static-method",
"public-instance-method",
"protected-instance-method",
"private-instance-method"
]
}],
"new-parens": true,
"no-any": true,
"no-arg": true,
"no-boolean-literal-compare": true,
"no-consecutive-blank-lines": [true, 2],
"no-construct": true,
"no-default-export": true,
"no-duplicate-variable": true,
"no-empty": true,
"no-empty-interface": false,
"no-floating-promises": true,
"no-for-in-array": true,
"no-inferrable-types": [true, "ignore-params"],
"no-inferred-empty-object-type": true,
"no-invalid-this": [true, "check-function-in-method"],
"no-magic-numbers": [true,
-1, 0, 1, 2, // Common numbers in tests etc
10, // Decimal number radix
16, // Hexidecimal number radix
100, // Percentage maximum value
1000, // MS in a second
60 // Seconds in a minute, minutes in an hour
],
"no-misused-new": true,
"no-namespace": [true, "allow-declarations"],
"no-parameter-properties": false,
"no-reference": true,
"no-string-literal": true,
"no-string-throw": true,
"no-switch-case-fall-through": true,
"no-trailing-whitespace": true,
"no-unbound-method": true,
"no-unnecessary-initializer": true,
"no-unsafe-any": true,
"no-unused-expression": true,
"no-use-before-declare": false,
"no-var-keyword": true,
"no-var-requires": true,
"no-void-expression": false,
"object-literal-key-quotes": [true, "as-needed"],
"one-line": [true, "check-catch", "check-finally", "check-else", "check-open-brace", "check-whitespace"],
"one-variable-per-declaration": true,
"prefer-const": true,
"prefer-for-of": true,
"prefer-function-over-method": [true, "allow-public", "allow-protected"],
"prefer-method-signature": true,
"promise-function-async": true,
"quotemark": [true, "single", "avoid-escape"],
"restrict-plus-operands": true,
"semicolon": [true, "never"],
"space-before-function-paren": [true, "always"],
"strict-boolean-expressions": false,
"strict-type-predicates": true,
"switch-default": true,
"trailing-comma": [true, { "multiline": "never", "singleline": "never" }],
"typedef": [ true, "call-signature" ],
"typedef-whitespace": [true, {
"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"
}],
"unified-signatures": true,
"use-isnan": true,
"variable-name": [true, "ban-keywords", "check-format"],
"whitespace": [
true,
"check-branch",
"check-decl",
"check-operator",
"check-module",
"check-separator",
"check-type",
"check-typecast"
]
}
}