Rules
TypeScript Specific
These rules find errors related to TypeScript features:
- member-access - Requires explicit visibility declarations for class members.
- member-ordering - Enforces member ordering.
- no-any - Diallows usages of
any
as a type declaration. - no-inferrable-types - Disallows explicit type declarations for variables or parameters initialized to a number, string, or boolean.
- no-internal-module - Disallows internal
module
- no-namespace - Disallows use of internal
module
s andnamespace
s. - no-reference - Disallows
/// <reference path=>
imports (use ES6-style imports instead). - no-var-requires - Disallows the use of require statements except in import statements.
- typedef - Requires type definitions to exist.
- typedef-whitespace - Requires or disallows whitespace for type definitions.
Functionality
These rules catch common errors in JS programming or otherwise confusing constructs that are prone to producing bugs:
- ban - Bans the use of specific functions.
- curly - Enforces braces for
if
/for
/do
/while
statements. - forin - Requires a
for ... in
statement to be filtered with anif
statement. - label-position - Only allows labels in sensible locations.
- label-undefined - Checks that labels are defined before usage.
- no-arg - Disallows use of
arguments.callee
. - no-bitwise - Disallows bitwise operators.
- no-conditional-assignment - Disallows any type of assignment in conditionals.
- no-console - Bans the use of specified
console
methods. - no-construct - Disallows access to the constructors of
String
,Number
, andBoolean
. - no-debugger - Disallows
debugger
statements. - no-duplicate-key - Disallows duplicate keys in object literals.
- no-duplicate-variable - Disallows duplicate variable declarations in the same block scope.
- no-empty - Disallows empty blocks.
- no-eval - Disallows
eval
function invocations. - no-invalid-this - Disallows using the
this
keyword outside of classes. - no-null-keyword - Disallows use of the
null
keyword literal. - no-shadowed-variable - Disallows shadowing variable declarations.
- no-string-literal - Disallows object access via string literals.
- no-switch-case-fall-through - Disallows falling through case statements.
- no-unreachable - Disallows unreachable code after
break
,catch
,throw
, andreturn
statements. - no-unused-expression - Disallows unused expression statements.
- no-unused-variable - Disallows unused imports, variables, functions and private class members.
- no-use-before-declare - Disallows usage of variables before their declaration.
- no-var-keyword - Disallows usage of the
var
keyword. - radix - Requires the radix parameter to be specified when calling
parseInt
. - switch-default - Require a
default
case in allswitch
statements. - triple-equals - Requires
===
and!==
in place of==
and!=
. - use-isnan - Enforces use of the
isNaN()
function to check for NaN references instead of a comparison to theNaN
constant. - use-strict - Requires using ECMAScript 5’s strict mode.
Maintainability
These rules make code maintenance easier:
- eofline - Ensures the file ends with a newline.
- indent - Enforces indentation with tabs or spaces.
- linebreak-style - Enforces a consistent linebreak style.
- max-line-length - Requires lines to be under a certain max length.
- no-default-export - Disallows default exports in ES6-style modules.
- no-mergeable-namespace - Disallows mergeable namespaces in the same file.
- no-require-imports - Disallows invocation of
require()
. - no-trailing-whitespace - Disallows trailing whitespace at the end of a line.
- object-literal-sort-keys - Requires keys in object literals to be sorted alphabetically
- trailing-comma - Requires or disallows trailing commas in array and object literals, destructuring assignments and named imports.
Style
These rules enforce consistent style across your codebase:
- align - Enforces vertical alignment.
- class-name - Enforces PascalCased class and interface names.
- comment-format - Enforces formatting rules for single-line comments.
- interface-name - Requires interface names to begin with a capital ‘I’
- jsdoc-format - Enforces basic format rules for JSDoc comments.
- new-parens - Requires parentheses when invoking a constructor via the
new
keyword. - no-angle-bracket-type-assertion - Requires the use of
as Type
for type assertions instead of<Type>
. - no-consecutive-blank-lines - Disallows more than one blank line in a row.
- no-constructor-vars - Disallows parameter properties.
- one-line - Requires the specified tokens to be on the same line as the expression preceding them.
- one-variable-per-declaration - Disallows multiple variable definitions in the same declaration statement.
- quotemark - Requires single or double quotes for string literals.
- semicolon - Enforces consistent semicolon usage at the end of every statement.
- variable-name - Checks variable names for various errors.
- whitespace - Enforces whitespace style conventions.