strict-tslint-config
An opinionated TSLint configuration preset. Works best together with strict TypeScript settings and Prettier.
Getting started
First, install strict-tslint-config
as a dev dependency:
yarn add -D strict-tslint-config
Then create a TSLint configuration file (tslint.json
) like this:
Now you can run TSLint as follows (assuming that TypeScript and Prettier are configured accordingly):
# Lint your TS sources yarn tslint --config tslint.json --project . '**/*.{ts,tsx}' # Lint your JS sources yarn tslint --config tslint.json '**/*.js'
Configuration preset
This dynamically generated configuration preset is compatible to
TSLint in version ^5.10.0
. It is based
on the built-in configuration preset tslint:all
:
tslint:all
turns on all rules to their strictest settings. This will use type checking, so it must be combined with the--project option
. (Exceptions include rules such as"ban"
,"import-blacklist"
, and"file-header"
, which have no sensible defaults, and deprecated rules.)
It is assumed that TypeScript is configured
with strict settings, e.g. "strict": true
and "noImplicitReturns": true
.
Also, it is assumed that Prettier is used for formatting
your sources.
The deviations from the configuration preset
tslint:all@5.11.0
are documented below:
- TypeScript and JavaScript rule overrides
- TypeScript-only rule overrides
- JavaScript-only rule overrides
TypeScript and JavaScript rule overrides
align
- Unnecessary because of Prettier.
{- align: [- true- "parameters"- "arguments"- "statements"- "elements"- "members"- ] }
arrow-parens
- Unnecessary because of Prettier.
{- arrow-parens: true }
comment-format
{ comment-format: [ true "check-space"- "check-uppercase" ] }
file-name-casing
{ file-name-casing: [ true- "camel-case"+ "kebab-case" ] }
indent
- Unnecessary because of Prettier.
{- indent: [- true- "spaces"- ] }
max-classes-per-file
{- max-classes-per-file: [- true- 1- ] }
max-file-line-count
{- max-file-line-count: [- true- 1000- ] }
max-line-length
- Unnecessary because of Prettier.
{- max-line-length: [- true- 120- ] }
member-ordering
{ member-ordering: [ true- {- order: "statics-first"- alphabetize: true- }+ {+ order: "statics-first"+ } ] }
newline-per-chained-call
- Unnecessary because of Prettier.
{- newline-per-chained-call: true }
no-console
{- no-console: true }
no-empty
{- no-empty: true+ no-empty: [+ true+ "allow-empty-catch"+ ] }
no-implicit-dependencies
{- no-implicit-dependencies: true+ no-implicit-dependencies: [+ true+ "dev"+ ] }
no-magic-numbers
{- no-magic-numbers: true }
no-null-keyword
{- no-null-keyword: true }
no-submodule-imports
{- no-submodule-imports: true }
no-this-assignment
{- no-this-assignment: true+ no-this-assignment: [+ true+ {+ allow-destructuring: true+ }+ ] }
no-unnecessary-callback-wrapper
{- no-unnecessary-callback-wrapper: true }
no-unnecessary-class
{ no-unnecessary-class: [ true+ "allow-constructor-only" "allow-empty-class"+ "allow-static-only" ] }
object-literal-key-quotes
- Unnecessary because of Prettier.
{- object-literal-key-quotes: [- true- "consistent-as-needed"- ] }
object-literal-sort-keys
{- object-literal-sort-keys: true }
only-arrow-functions
{- only-arrow-functions: true+ only-arrow-functions: [+ true+ "allow-declarations"+ ] }
ordered-imports
{ ordered-imports: [ true- {- import-sources-order: "case-insensitive"- named-imports-order: "case-insensitive"- module-source-path: "full"- }+ {+ import-sources-order: "lowercase-last"+ named-imports-order: "lowercase-last"+ } ] }
prefer-template
{- prefer-template: true+ prefer-template: [+ true+ "allow-single-concat"+ ] }
quotemark
- Unnecessary because of Prettier.
{- quotemark: [- true- "double"- "avoid-escape"- "avoid-template"- ] }
semicolon
- Unnecessary because of Prettier.
{- semicolon: [- true- "always"- ] }
switch-default
- TypeScript-only: Unnecessary because of the TypeScript setting
--noImplicitReturns
.
{- switch-default: true }
trailing-comma
- Unnecessary because of Prettier.
{- trailing-comma: [- true- {- multiline: "always"- singleline: "never"- }- ] }
triple-equals
{- triple-equals: true+ triple-equals: [+ true+ "allow-null-check"+ ] }
variable-name
{ variable-name: [ true "ban-keywords" "check-format"+ "allow-pascal-case"+ "allow-leading-underscore" ] }
whitespace
- Unnecessary because of Prettier.
{- whitespace: [- true- "check-branch"- "check-decl"- "check-operator"- "check-module"- "check-separator"- "check-type"- "check-typecast"- "check-preblock"- "check-type-operator"- "check-rest-spread"- ] }
TypeScript-only rule overrides
array-type
{ array-type: [ true- "array-simple"+ "array" ] }
completed-docs
{- completed-docs: true }
interface-name
{- interface-name: true+ interface-name: [+ true+ "never-prefix"+ ] }
no-empty-interface
{- no-empty-interface: true }
no-inferrable-types
{ no-inferrable-types: [ true "ignore-params"+ "ignore-properties" ] }
no-parameter-properties
{- no-parameter-properties: true }
no-unbound-method
{- no-unbound-method: true+ no-unbound-method: [+ true+ "ignore-static"+ ] }
no-unsafe-any
{- no-unsafe-any: true }
no-unused-variable
- Deprecated since TypeScript 2.9. Please use the built-in compiler checks instead.
{- no-unused-variable: true }
no-void-expression
{- no-void-expression: true+ no-void-expression: [+ true+ "ignore-arrow-function-shorthand"+ ] }
return-undefined
{- return-undefined: true }
strict-boolean-expressions
{- strict-boolean-expressions: true+ strict-boolean-expressions: [+ "allow-null-union"+ "allow-undefined-union"+ "allow-string"+ "allow-number"+ ] }
typedef
{ typedef: [ true "call-signature"- "arrow-call-signature" "parameter"- "arrow-parameter" "property-declaration"- "variable-declaration"- "member-variable-declaration" ] }
JavaScript-only rule overrides
no-require-imports
{- no-require-imports: true }
switch-default
- TypeScript-only: Unnecessary because of the TypeScript setting
--noImplicitReturns
.
{+ switch-default: true }
Copyright (c) 2018-present, Clemens Akens. Released under the terms of the MIT License.