
ESLint rules for TSLint
Improve your TSLint with the missing ESLint Rules
You want to code in TypeScript but miss all the rules available in ESLint?
Now you can combine both worlds by using this TSLint plugin!
Usage
Install from NPM to your Dev Dependencies
npm install --save-dev tslint-eslint-rules
Configure TSLint to use tslint-eslint-rules folder:
In your tslint.json file, add the rulesDirectory property, e.g:
{
"rulesDirectory": "node_modules/tslint-eslint-rules/dist/rules",
"rules": {
"no-constant-condition": true
}
}
You can also pass an array of strings to the rulesDirectory property to combine this plugin with other community custom rules.
Configure your rules
In your tslint.json file, insert the rules as described below.
The list below shows all the existing ESLint rules and the similar rules available in TSLint.
Possible Errors
The following rules point out areas where you might have made mistakes.
-
comma-dangle => trailing-comma (native)
-
Description: disallow or enforce trailing commas (recommended)
-
Usage
"trailing-comma": [
true,
{
"multiline": "never",
"singleline": "never"
}
]
-
no-cond-assign => no-conditional-assignment (native)
-
no-console => no-console (native)
-
Description: disallow use of console in the node environment (recommended)
-
Usage
"no-console": [
true,
"debug",
"info",
"time",
"timeEnd",
"trace"
]
-
no-constant-condition => no-constant-condition (tslint-eslint-rules)
-
no-control-regex => no-control-regex (tslint-eslint-rules)
-
no-debugger => no-debugger (native)
-
no-dupe-args => not applicable to TypeScript
- Description: disallow duplicate arguments in functions (recommended)
-
no-dupe-keys => no-duplicate-key (native)
-
no-duplicate-case => no-duplicate-case (tslint-eslint-rules)
-
no-empty-character-class => no-empty-character-class (tslint-eslint-rules)
-
no-empty => no-empty (native)
-
no-ex-assign => no-ex-assign (tslint-eslint-rules)
-
no-extra-boolean-cast => no-extra-boolean-cast (tslint-eslint-rules)
-
no-extra-parens => no-extra-parens (tslint-eslint-rules) TODO (low priority)
-
Description: disallow unnecessary parentheses
-
Usage
"no-extra-parens": [
true,
"functions"
]
"no-extra-parens": [
true,
"all"
]
-
no-extra-semi => no-extra-semi (tslint-eslint-rules)
-
no-func-assign => not applicable to TypeScript
- Description: disallow overwriting functions written as function declarations (recommended)
-
no-inner-declarations => no-inner-declarations (tslint-eslint-rules)
-
Description: disallow function or variable declarations in nested blocks (recommended)
-
Usage
"no-inner-declarations": [
true,
"functions"
]
"no-inner-declarations": [
true,
"both"
]
-
no-invalid-regexp => no-invalid-regex (tslint-eslint-rules)
-
no-irregular-whitespace => no-irregular-whitespace (tslint-eslint-rules)
-
no-negated-in-lhs => not applicable to TypeScript
- Description: disallow negation of the left operand of an
in expression (recommended)
-
no-obj-calls => not applicable to TypeScript
- Description: disallow the use of object properties of the global object (
Math and JSON) as functions (recommended)
-
no-regex-spaces => no-regex-spaces (tslint-eslint-rules)
-
no-sparse-arrays => no-sparse-arrays (tslint-eslint-rules)
-
no-unexpected-multiline => no-unexpected-multiline (tslint-eslint-rules)
-
no-unreachable => no-unreachable (native)
-
Description: disallow unreachable statements after a return, throw, continue, or break statement (recommended)
-
Usage
"no-unreachable": true
-
use-isnan => use-isnan (tslint-eslint-rules)
-
valid-jsdoc => valid-jsdoc (tslint-eslint-rules)
-
Description: Ensure JSDoc comments are valid
-
Usage
"valid-jsdoc": [
true,
{
"prefer": {
"return": "returns"
},
"requireReturn": false,
"requireParamDescription": true,
"requireReturnDescription": true,
"matchDescription": "^[A-Z][A-Za-z0-9\\s]*[.]$"
}
]
-
valid-typeof => valid-typeof (tslint-eslint-rules)
Best Practices
These are rules designed to prevent you from making mistakes. They either prescribe a better way of doing something or help you avoid footguns.
-
accessor-pairs => accessor-pairs (tslint-eslint-rules) TODO
-
Description: Enforces getter/setter pairs in objects
-
Usage
"accessor-pairs": [
true,
{
"getWithoutSet" : true,
"setWithoutGet" : true
}
]
-
block-scoped-var => accessor-pairs (tslint-eslint-rules) TODO
-
complexity => complexity (tslint-eslint-rules) TODO
-
Description: specify the maximum cyclomatic complexity allowed in a program
-
Usage
"complexity": [
true,
3
]
-
consistent-return => consistent-return (tslint-eslint-rules) TODO
-
curly => curly (native)
-
default-case => switch-default (native)
-
dot-location => dot-location (tslint-eslint-rules) TODO
-
Description: enforces consistent newlines before or after dots
-
Usage
"dot-location": [
true,
"object"
]
"dot-location": [
true,
"property"
]
-
dot-notation => dot-notation (tslint-eslint-rules) TODO
-
Description: encourages use of dot notation whenever possible
-
Usage
"dot-notation": [
true,
{
"allowKeywords": true,
"allowPattern": ""
}
]
-
eqeqeq => triple-equals (native)
-
guard-for-in => forin (native)
-
no-alert => no-alert (tslint-eslint-rules) TODO
-
no-caller => no-arg (native)
-
no-case-declarations => no-case-declarations (tslint-eslint-rules) TODO
-
no-div-regex => no-div-regex (tslint-eslint-rules) TODO
-
no-else-return => no-else-return (tslint-eslint-rules) TODO
-
no-empty-label => no-empty-label (tslint-eslint-rules) TODO
-
no-empty-pattern => no-empty-pattern (tslint-eslint-rules) TODO
-
no-eq-null => no-eq-null (tslint-eslint-rules) TODO
-
no-eval => no-eval (native)
-
no-extend-native => no-extend-native (tslint-eslint-rules) TODO
-
Description: disallow adding to native types
-
Usage
"no-extend-native": [
true,
{
"exceptions": ["Object", "String"]
}
]
-
no-extra-bind => no-extra-bind (tslint-eslint-rules) TODO
-
no-fallthrough => no-switch-case-fall-through (native)
-
no-floating-decimal => no-floating-decimal (tslint-eslint-rules) TODO
-
no-implicit-coercion => no-implicit-coercion (tslint-eslint-rules) TODO
-
Description: disallow the type conversions with shorter notations
-
Usage
"no-implicit-coercion": [
true,
{
"boolean": true,
"number": true,
"string": true
}
]
-
no-implied-eval => no-implied-eval (tslint-eslint-rules) TODO
-
no-invalid-this => no-invalid-this (tslint-eslint-rules) TODO
-
no-iterator => no-iterator (tslint-eslint-rules) TODO
-
no-labels => no-labels (tslint-eslint-rules) TODO
-
no-lone-blocks => no-lone-blocks (tslint-eslint-rules) TODO
-
no-loop-func => no-loop-func (tslint-eslint-rules) TODO
-
no-magic-numbers => no-magic-numbers (tslint-eslint-rules) TODO
-
Description: disallow the use of magic numbers
-
Usage
"no-magic-numbers": [
true,
{
"ignore": [0, 1, 2],
"enforceConst": false,
"detectObjects": false
}
]
-
no-multi-spaces => no-multi-spaces (tslint-eslint-rules) TODO
-
Description: disallow use of multiple spaces
-
Usage
"no-multi-spaces": [
true,
{
"exceptions": [ { "ImportDeclation": true }, { "Property": false } ]
}
]
-
no-multi-str => no-multi-str (tslint-eslint-rules) TODO
-
no-native-reassign => Not applicable to TypeScript
- Description: disallow reassignments of native objects
-
no-new-func => no-new-func (tslint-eslint-rules) TODO
-
no-new-wrappers => no-new-wrappers (tslint-eslint-rules) TODO // ou no-construct
-
no-new => no-new (tslint-eslint-rules) TODO
-
no-octal-escape => no-octal-escape (tslint-eslint-rules) TODO
-
no-octal => Not applicable to TypeScript
- Description: disallow use of octal literals (recommended)
-
no-param-reassign => no-param-reassign (tslint-eslint-rules) TODO
-
Description: disallow reassignment of function parameters
-
Usage
"no-param-reassign": [
true,
{
"props": false
}
]
-
no-process-env => no-process-env (tslint-eslint-rules) TODO
-
no-proto => no-proto (tslint-eslint-rules) TODO
-
no-redeclare => no-duplicate-variable (native)
-
no-return-assign => no-return-assign (tslint-eslint-rules) TODO
-
Description: disallow use of assignment in return statement
-
Usage
"no-return-assign": [
true,
"except-parens"
]
"no-return-assign": [
true,
"always"
]
-
no-script-url => no-script-url (tslint-eslint-rules) TODO
-
no-self-compare => no-self-compare (tslint-eslint-rules) TODO
-
no-sequences => no-sequences (tslint-eslint-rules) TODO
-
no-throw-literal => no-throw-literal (tslint-eslint-rules) TODO
-
no-unused-expressions => no-unused-expression (native)
-
no-useless-call => no-useless-call (tslint-eslint-rules) TODO
-
no-useless-concat => no-useless-concat (tslint-eslint-rules) TODO
-
no-void => no-void (tslint-eslint-rules) TODO
-
no-warning-comments => no-warning-comments (tslint-eslint-rules) TODO
-
Description: disallow Usage of configurable warning terms in comments e.g. TODO or FIXME
-
Usage
"no-warning-comments": [
true,
{
"terms": ["todo", "fixme", "xxx"],
"location": "start"
}
]
-
no-with => no-with (tslint-eslint-rules) TODO
-
radix => radix (native)
-
vars-on-top => vars-on-top (tslint-eslint-rules) TODO
-
wrap-iife => wrap-iife (tslint-eslint-rules) TODO
-
Description: require immediate function invocation to be wrapped in parentheses
-
Usage
"wrap-iife": [
true,
"inside"
]
"wrap-iife": [
true,
"outside"
]
"wrap-iife": [
true,
"any"
]
-
yoda => yoda (tslint-eslint-rules) TODO
-
Description: require or disallow Yoda conditions
-
Usage
"yoda": [
true,
"never"
]
"yoda": [
true,
"always"
]
Strict Mode
These rules relate to using strict mode.
- strict => strict (tslint-eslint-rules) TODO
-
Description: controls location of Use Strict Directives
-
Usage
"strict": [
true,
"function"
]
"strict": [
true,
"global"
]
"strict": [
true,
"never"
]
Variables
These rules have to do with variable declarations.
-
init-declarations => init-declarations (tslint-eslint-rules) TODO
-
Description: enforce or disallow variable initializations at definition
-
Usage
"init-declarations": [
true,
"always"
{
"ignoreForLoopInit": false
}
]
"init-declarations": [
true,
"never"
{
"ignoreForLoopInit": false
}
]
-
no-catch-shadow => no-catch-shadow (tslint-eslint-rules) TODO
-
no-delete-var => not applicable to TypeScript
- Description: disallow deletion of variables (recommended)
-
no-label-var => no-label-var (tslint-eslint-rules) TODO
-
no-shadow-restricted-names => no-shadow-restricted-names (tslint-eslint-rules) TODO
-
no-shadow => no-shadowed-variable (native)
-
no-undef-init => no-undef-init (tslint-eslint-rules) TODO
-
no-undef => not applicable to TypeScript
- Description: disallow use of undeclared variables unless mentioned in a
/*global */ block (recommended)
-
no-undefined => no-undefined (tslint-eslint-rules) TODO
-
no-unused-vars => no-unused-variable (native)
-
no-use-before-define => no-use-before-define (native)
Node.js and CommonJS
These rules are specific to JavaScript running on Node.js or using CommonJS in the browser.
-
callback-return => callback-return (tslint-eslint-rules) TODO
-
Description: enforce return after a callback
-
Usage
"callback-return": [
true,
[
"callback",
"cb",
"next"
]
]
-
global-require => global-require (tslint-eslint-rules) TODO
-
handle-callback-err => handle-callback-err (tslint-eslint-rules) TODO
-
Description: enforce error handling in callbacks
-
Usage
"handle-callback-err": [
true,
"^(err|error|anySpecificError)$"
]
-
no-mixed-requires => no-mixed-requires (tslint-eslint-rules) TODO
-
Description: disallow mixing regular variable and require declarations
-
Usage
"no-mixed-requires": [
true,
{
"grouping": false
}
]
-
no-new-require => no-new-require (tslint-eslint-rules) TODO
-
no-path-concat => no-path-concat (tslint-eslint-rules) TODO
-
no-process-exit => no-process-exit (tslint-eslint-rules) TODO
-
no-restricted-modules => no-restricted-modules (tslint-eslint-rules) TODO
-
Description: restrict Usage of specified node modules
-
Usage
"no-restricted-modules": [
true,
[
"fs",
"cluster",
"moduleName"
]
]
-
no-sync => no-sync (tslint-eslint-rules) TODO
Stylistic Issues
These rules are purely matters of style and are quite subjective.
-
array-bracket-spacing => array-bracket-spacing (tslint-eslint-rules) TODO
-
Description: enforce spacing inside array brackets
-
Usage
"array-bracket-spacing": [
true,
"always",
{
"singleValue": true,
"objectsInArrays": true,
"arraysInArrays": true
}
]
"array-bracket-spacing": [
true,
"never",
{
"singleValue": false,
"objectsInArrays": false,
"arraysInArrays": false
}
]
-
block-spacing => block-spacing (tslint-eslint-rules) TODO
-
Description: disallow or enforce spaces inside of single line blocks
-
Usage
"block-spacing": [
true,
"always"
]
"block-spacing": [
true,
"never"
]
-
brace-style => brace-style (tslint-eslint-rules) TODO
-
Description: enforce one true brace style
-
Usage
"brace-style": [
true,
"1tbs",
{
"allowSingleLine": true
}
]
"brace-style": [
true,
"stroustrup",
{
"allowSingleLine": true
}
]
"brace-style": [
true,
"allman",
{
"allowSingleLine": true
}
]
-
camelcase => variable-name (native)
-
comma-spacing => comma-spacing (tslint-eslint-rules) TODO
-
Description: enforce spacing before and after comma
-
Usage
"comma-spacing": [
true,
{
"before": false,
"after": true
}
]
-
comma-style => comma-style (tslint-eslint-rules) TODO
-
Description: enforce one true comma style
-
Usage
"comma-style": [
true,
"first"
]
"comma-style": [
true,
"last"
]
-
computed-property-spacing => computed-property-spacing (tslint-eslint-rules) TODO
-
Description: require or disallow padding inside computed properties
-
Usage
"computed-property-spacing": [
true,
"always"
]
"computed-property-spacing": [
true,
"never"
]
-
consistent-this => consistent-this (tslint-eslint-rules) TODO
-
Description: enforce consistent naming when capturing the current execution context
-
Usage
"consistent-this": [
true,
"self"
]
-
eol-last => eol-last (tslint-eslint-rules) TODO
-
Description: enforce newline at the end of file, with no multiple empty lines
-
Usage
"eol-last": [
true,
"unix"
]
"eol-last": [
true,
"windows"
]
-
func-names => func-names (tslint-eslint-rules) TODO
-
func-style => func-style (tslint-eslint-rules) TODO
-
Description: enforce use of function declarations or expressions
-
Usage
"func-style": [
true,
"declaration"
{
"allowArrowFunctions": true
}
]
"func-style": [
true,
"expression"
{
"allowArrowFunctions": true
}
]
-
id-length => id-length (tslint-eslint-rules) TODO
-
Description: this option enforces minimum and maximum identifier lengths (variable names, property names etc.)
-
Usage
"id-length": [
true,
{
"min": 2,
"max": 10,
"properties": "always",
"exceptions": [ "x", "bolinha" ]
}
]
"id-length": [
true,
{
"min": 2,
"max": 10,
"properties": "never",
"exceptions": [ "x", "bolinha" ]
}
]
-
id-match => id-match (tslint-eslint-rules) TODO
-
Description: require identifiers to match the provided regular expression
-
Usage
"id-match": [
true,
"^[a-z]+([A-Z][a-z]+)*$",
{
"properties": false
}
]
-
indent => indent (native)
-
Description: specify tab or space width for your code
-
Usage
"indent": [
true,
"spaces"
]
"indent": [
true,
"tabs"
]
-
jsx-quotes => jsx-quotes (tslint-eslint-rules) TODO
-
Description: specify whether double or single quotes should be used in JSX attributes
-
Usage
"jsx-quotes": [
true,
"prefer-double"
]
"jsx-quotes": [
true,
"prefer-single"
]
-
key-spacing => key-spacing (tslint-eslint-rules) TODO
-
Description: enforce spacing between keys and values in object literal properties
-
Usage
"key-spacing": [
true,
{
"align": "value",
"beforeColon": false,
"afterColon": true,
"mode": "minimum"
}
]
-
linebreak-style => linebreak-style (tslint-eslint-rules) TODO
-
Description: disallow mixed 'LF' and 'CRLF' as linebreaks
-
Usage
"linebreak-style": [
true,
"unix"
]
"linebreak-style": [
true,
"windows"
]
-
lines-around-comment => lines-around-comment (tslint-eslint-rules) TODO
-
Description: enforce empty lines around comments
-
Usage
"lines-around-comment": [
true,
{
"beforeBlockComment": true,
"afterBlockComment": false,
"beforeLineComment": false,
"afterLineComment": false,
"allowBlockStart": false,
"allowBlockEnd": false,
"allowObjectStart": false,
"allowObjectEnd": false,
"allowArrayStart": false,
"allowArrayEnd": false
}
]
-
max-nested-callbacks => max-nested-callbacks (tslint-eslint-rules) TODO
-
new-cap => Not applicable to TypeScript
- Description: require a capital letter for constructors
-
new-parens => new-parens (tslint-eslint-rules) TODO
-
newline-after-var => newline-after-var (tslint-eslint-rules) TODO
-
Description: require or disallow an empty newline after variable declarations
-
Usage
"newline-after-var": [
true,
"never"
]
"newline-after-var": [
true,
"always"
]
-
no-array-constructor => no-array-constructor (tslint-eslint-rules) TODO
-
no-continue => no-continue (tslint-eslint-rules) TODO
-
no-inline-comments => no-inline-comments (tslint-eslint-rules) TODO
-
no-lonely-if => no-lonely-if (tslint-eslint-rules) TODO
-
no-mixed-spaces-and-tabs => ident (native)
-
Description: disallow mixed spaces and tabs for indentation (recommended)
-
Usage
"ident": "spaces"
"ident": "tabs"
Note: When using TSLint ident rule, it will enforce the consistent use of the chosen identation. The ESLint rule allows an option for Smart Tabs, but there are some open issues, and we're not going to support this.
-
no-multiple-empty-lines => no-multiple-empty-lines (tslint-eslint-rules) TODO
-
Description: disallow multiple empty lines
-
Usage
"no-multiple-empty-lines": [
true,
{
"max": 2,
"maxEOF": 1
}
]
-
no-negated-condition => no-negated-condition (tslint-eslint-rules) TODO
-
no-nested-ternary => no-nested-ternary (tslint-eslint-rules) TODO
-
no-new-object => no-new-object (tslint-eslint-rules) TODO
-
no-restricted-syntax => no-restricted-syntax (tslint-eslint-rules) TODO
-
Description: disallow use of certain syntax in code
-
Usage
"no-restricted-syntax": [
true,
"FunctionExpression",
"WithStatement"
]
-
no-spaced-func => no-spaced-func (tslint-eslint-rules) TODO
-
no-ternary => no-ternary (tslint-eslint-rules) TODO
-
no-trailing-spaces => no-trailing-whitespace (native)
-
no-underscore-dangle => no-underscore-dangle (tslint-eslint-rules) TODO
-
Description: disallow dangling underscores in identifiers
-
Usage
"no-underscore-dangle": [
true,
{
"allow": ["foo_", "_bar"]
}
]
-
no-unneeded-ternary => no-unneeded-ternary (tslint-eslint-rules) TODO
-
Description: disallow the use of ternary operators when a simpler alternative exists
-
Usage
"no-unneeded-ternary": [
true,
{
"defaultAssignment": true
}
]
-
object-curly-spacing => object-curly-spacing (tslint-eslint-rules) TODO
-
Description: require or disallow padding inside curly braces
-
Usage
"object-curly-spacing": [
true,
"always"
]
"object-curly-spacing": [
true,
"never"
]
-
one-var => one-var (tslint-eslint-rules) TODO
-
Description: require or disallow one variable declaration per function
-
Usage
"one-var": [
true,
"always"
]
"one-var": [
true,
"never"
]
-
operator-assignment => operator-assignment (tslint-eslint-rules) TODO
-
Description: require assignment operator shorthand where possible or prohibit it entirely
-
Usage
"operator-assignment": [
true,
"always"
]
"operator-assignment": [
true,
"never"
]
-
operator-linebreak => operator-linebreak (tslint-eslint-rules) TODO
-
Description: enforce operators to be placed before or after line breaks
-
Usage
"operator-linebreak": [
true,
"before",
{
"overrides": { "?": "after"}
}
]
"operator-linebreak": [
true,
"after",
{
"overrides": { "?": "after"}
}
]
"operator-linebreak": [
true,
"none",
{
"overrides": { "?": "none", "+=": "none"}
}
]
-
padded-blocks => padded-blocks (tslint-eslint-rules) TODO
-
Description: enforce padding within blocks
-
Usage
"padded-blocks": [
true,
"always"
]
"padded-blocks": [
true,
"never"
]
-
quote-props => quote-props (tslint-eslint-rules) TODO
-
Description: require quotes around object literal property names
-
Usage
"quote-props": [
true,
"always"
]
"quote-props": [
true,
"as-needed"
]
"quote-props": [
true,
"consistent"
]
"quote-props": [
true,
"consistent-as-needed"
]
-
quotes => quote-props (tslint-eslint-rules) TODO
-
Description: specify whether backticks, double or single quotes should be used
-
Usage
"quotes": [
true,
"single"
]
"quotes": [
true,
"single",
"avoid-escape"
]
"quotes": [
true,
"double"
]
"quotes": [
true,
"double",
"avoid-escape"
]
"quotes": [
true,
"backtick"
]
"quotes": [
true,
"backtick",
"avoid-escape"
]
-
require-jsdoc => require-jsdoc (tslint-eslint-rules) TODO
-
Description: Require JSDoc comment
-
Usage
"require-jsdoc": [
true,
{
"require":
{
"FunctionDeclaration": true,
"MethodDefinition": false,
"ClassDeclaration": false
}
}
]
-
semi-spacing => semi-spacing (tslint-eslint-rules) TODO
-
Description: enforce spacing before and after semicolons
-
Usage
"semi-spacing": [
true,
{
"before": false,
"after": true
}
]
-
semi => semi (tslint-eslint-rules) TODO
-
Description: require or disallow use of semicolons instead of ASI
-
Usage
"semi": [
true,
"always"
]
"semi": [
true,
"never"
]
-
sort-vars => sort-vars (tslint-eslint-rules) TODO
-
Description: sort variables within the same declaration block
-
Usage
"sort-vars": [
true,
{
"ignoreCase": false
}
]
-
space-after-keywords => space-after-keywords (tslint-eslint-rules) TODO
-
Description: require a space after certain keywords
-
Usage
"space-after-keywords": [
true,
"always"
]
"space-after-keywords": [
true,
"never"
]
-
space-before-blocks => space-before-blocks (tslint-eslint-rules) TODO
-
Description: require or disallow a space before blocks
-
Usage
"space-before-blocks": [
true,
"always"
]
"space-before-blocks": [
true,
"never"
]
"space-before-blocks": [
true,
{
"functions": "never",
"keywords": "always"
}
]
-
space-before-function-paren => space-before-function-paren (tslint-eslint-rules) TODO
-
Description: require or disallow a space before function opening parenthesis
-
Usage
"space-before-function-paren": [
true,
"always"
]
"space-before-function-paren": [
true,
"never"
]
"space-before-function-paren": [
true,
{
"anonymous": "always",
"named": "never"
}
]
-
space-before-keywords => space-before-keywords (tslint-eslint-rules) TODO
-
Description: require a space before certain keywords
-
Usage
"space-before-keywords": [
true,
"always"
]
"space-before-keywords": [
true,
"never"
]
-
space-in-parens => space-in-parens (tslint-eslint-rules) TODO
-
Description: require or disallow spaces inside parentheses
-
Usage
"space-in-parens": [
true,
"always"
]
"space-in-parens": [
true,
"never"
]
-
space-infix-ops => space-infix-ops (tslint-eslint-rules) TODO
-
space-return-throw-case => space-return-throw-case (tslint-eslint-rules) TODO
-
Description: require a space after return, throw, and case
-
Usage
"space-return-throw-case": true
-
space-unary-ops => space-unary-ops (tslint-eslint-rules) TODO
-
Description: require or disallow spaces before/after unary operators
-
Usage
"space-unary-ops": [
true,
{
"words": true,
"nonwords": false
}
]
-
spaced-comment => spaced-comment (tslint-eslint-rules) TODO
-
Description: require or disallow a space immediately following the // or /* in a comment
-
Usage
"spaced-comment": [
true,
"always"
]
"spaced-comment": [
true,
"never"
]
"spaced-comment": [
true,
"always",
{
"exceptions": ["-", "+"]
}
]
"spaced-comment": [
true,
"always",
{
"line": {
"markers": ["/"]
"exceptions": ["-", "+"]
},
"block": {
"markers": ["/"]
"exceptions": ["-", "+"]
}
}
]
-
wrap-regex => wrap-regex (tslint-eslint-rules) TODO
ECMAScript 6
These rules are only relevant to ES6 environments.
-
arrow-body-style => arrow-body-style (tslint-eslint-rules) TODO
-
Description: require braces in arrow function body
-
Usage
"arrow-body-style": [
true,
"as-needed"
]
"arrow-body-style": [
true,
"always"
]
-
arrow-parens => arrow-parens (tslint-eslint-rules) TODO
-
Description: require parens in arrow function arguments
-
Usage
"arrow-parens": [
true,
"as-needed"
]
"arrow-parens": [
true,
"always"
]
-
arrow-spacing => arrow-spacing (tslint-eslint-rules) TODO
-
Description: require space before/after arrow function's arrow
-
Usage
"arrow-spacing": [
true,
{
"before": true,
"after": true
}
]
-
constructor-super => constructor-super (tslint-eslint-rules) TODO
-
generator-star-spacing => generator-star-spacing (tslint-eslint-rules) TODO
-
Description: enforce spacing around the * in generator functions
-
Usage
"generator-star-spacing": [
true,
{
"before": true,
"after": true
}
]
-
no-arrow-condition => no-arrow-condition (tslint-eslint-rules) TODO
-
no-class-assign => no-class-assign (tslint-eslint-rules) TODO
-
no-const-assign => no-const-assign (tslint-eslint-rules) TODO
-
no-dupe-class-members => Not applicable to TypeScript
- Description: disallow duplicate name in class members
-
no-this-before-super => no-this-before-super (tslint-eslint-rules) TODO
-
no-var => no-var-keyword (native)
-
object-shorthand => object-shorthand (tslint-eslint-rules) TODO
-
Description: require method and property shorthand syntax for object literals
-
Usage
"object-shorthand": [
true,
"always"
]
"object-shorthand": [
true,
"methods"
]
"object-shorthand": [
true,
"properties"
]
"object-shorthand": [
true,
"never"
]
-
prefer-arrow-callback => prefer-arrow-callback (tslint-eslint-rules) TODO
-
prefer-const => prefer-const (tslint-eslint-rules) TODO
-
prefer-reflect => prefer-reflect (tslint-eslint-rules) TODO
-
Description: suggest using Reflect methods where applicable
-
Usage
"prefer-reflect": [
true,
{
"exceptions": ["apply", "call", "defineProperty", "getOwnPropertyDescriptor", "getPrototypeOf", "setPrototypeOf", "isExtensible", "getOwnPropertyNames", "preventExtensions", "delete"]
}
]
-
prefer-spread => prefer-spread (tslint-eslint-rules) TODO
-
prefer-template => prefer-template (tslint-eslint-rules) TODO
-
require-yield => require-yield (tslint-eslint-rules) TODO
Contributing
Bugs, rules requests, doubts etc., open a Github Issue.
If you didn't find the rule, you can also create an ESLint custom rule for TSLint:
- Open an issue asking for the rule
- Fork this repository
- Create a branch with the rule name, e.g: no-if-usage
- Run
npm install
- Run
gulp to run the tests and watch for file changes
- Create your rule tests at
./src/test/rules and your rule in ./src/rules with the convetion:
- Name: rule-name (hyphenated, e.g: no-if-usage)
- File: ruleNameRule.ts (camelCased and with the
Rule suffix, e.g: noIfUsageRule.ts)
- Test File: ruleNameRuleTests.ts (camelCased and with the
RuleTests suffix, e.g: noIfUsageRuleTests.ts)
- Check if all the tests are passing
- Commit the changes to your repo with the following convention:
- Example:
[feat] added use-isnan rule (closes #20)
- Finally, open a Pull Request
You can also contribute with PRs for fixing bugs, or improving documentation, performance. The commit convention for these are, respectively:
- Example:
[bug] fixed no-constant-condition rule (closes #9)
- Example:
[docs] improved README.md file (closes #32)
- Example:
[perf] improved valid-typeof rule (closes #48)
LICENSE
MIT