TypeScript support for ESLint. (This is still in the very early stages, so please be patient.)
You'll first need to install ESLint:
$ npm i eslint --save-dev
Next, install typescript-eslint-parser
:
$ npm install typescript-eslint-parser --save-dev
Last, install eslint-plugin-typescript
:
$ npm install eslint-plugin-typescript --save-dev
Note: If you installed ESLint globally (using the -g
flag) then you must also install eslint-plugin-typescript
globally.
Add typescript-eslint-parser
to the parser
field and typescript
to the plugins section of your .eslintrc
configuration file. You can omit the eslint-plugin-
prefix:
{
"parser": "typescript-eslint-parser",
"plugins": [
"typescript"
]
}
Then configure the rules you want to use under the rules section.
{
"rules": {
"typescript/rule-name": "error"
}
}
typescript/type-annotation-spacing
— enforces one space after the colon and zero spaces before the colon of a type annotation.typescript/explicit-member-accessibility
— enforces accessibility modifiers on class properties and methods. (member-access
from TSLint)typescript/interface-name-prefix
— enforces interface names are prefixed. (interface-name
from TSLint)typescript/no-triple-slash-reference
— enforces/// <reference />
is not used. (no-reference
from TSLint)typescript/no-explicit-any
— enforces theany
type is not used. (no-any
from TSLint)typescript/no-angle-bracket-type-assertion
— enforces the use ofas Type
assertions instead of<Type>
assertions. (no-angle-bracket-type-assertion
from TSLint)typescript/no-namespace
— disallows the use of custom TypeScript modules and namespaces.typescript/no-use-before-define
— disallows the use of variables before they are defined.typescript/prefer-namespace-keyword
— enforces the use of the keywordnamespace
overmodule
to declare custom TypeScript modules. (no-internal-module
from TSLint)typescript/no-type-alias
— disallows the use of type aliases. (interface-over-type-literal
from TSLint)typescript/member-ordering
— enforces a standard member declaration order. (member-ordering
from TSLint)typescript/no-unused-vars
— prevents TypeScript-specific constructs from being erroneously flagged as unusedtypescript/adjacent-overload-signatures
— enforces member overloads to be consecutive.typescript/no-parameter-properties
- disallows parameter properties in class constructors. (no-parameter-properties
from TSLint)typescript/class-name-casing
- enforces PascalCased class and interface names. (class-name
from TSLint)typescript/member-delimiter-style
- enforces a member delimiter style in interfaces and type literals.typescript/no-empty-interface
- disallows the declaration of empty interfaces. (no-empty-interface
from TSLint)