tslint.json
TypeScript Lint configuration file
| Type | object |
|---|---|
| File match |
tslint.json
tslint.yaml
tslint.yml
|
| Schema URL | https://catalog.lintel.tools/schemas/schemastore/tslint-json/latest.json |
| Source | https://www.schemastore.org/tslint.json |
Validate with Lintel
npx @lintel/lintel check
Properties
The name of a built-in configuration preset, or a path or array of paths to other configuration files which are extended by this configuration. These values are handled using node module resolution semantics.
A path to a directory or an array of paths to directories of custom rules. These values are handled using node module resolution semantics, if an index.js is placed in your rules directory.
A map of rules that will be used to lint TypeScript files. These rules apply to .ts and .tsx files.
109 nested properties
Requires parentheses around the parameters of arrow function definitions.
Suggests to convert () => { return x; } to () => x.
Bans the use of specific functions or global methods.
In a binary expression, a literal should always be on the right-hand side if possible. For example, prefer 'x + 1' over '1 + x'.
Enforces PascalCased class and interface names.
Enforces formatting rules for single-line comments.
Enforces documentation for important items be filled out.
Enforces a threshold of cyclomatic complexity.
Enforces a certain header comment for all files, matched by a regular expression.
Enforces a consistent file naming convention.
Requires a for ... in statement to be filtered with an if statement.
Disallows importing the specified modules directly via import and require.
Instead only sub modules may be imported from that module.
Ensures proper spacing between import statement keywords
Enforces basic format rules for JSDoc comments.
Only allows labels in sensible locations.
A file may not contain more than the specified number of classes
Requires files to remain under a certain number of lines
Requires lines to be under a certain max length.
Enforces blank line before return when not the only line in the block.
Requires that chained method calls be broken apart onto separate lines.
Requires parentheses when invoking a constructor via the new keyword.
Disallows any type of assignment in conditionals.
Disallows one or more blank lines in a row.
Disallows access to the constructors of String, Number, and Boolean.
Disallows default exports in ES6-style modules.
Disallows multiple import statements from the same module.
Warns if 'super()' appears twice in a constructor.
Prevents duplicate cases in switch statements.
Disallows duplicate variable declarations in the same block scope.
Bans usage of the delete operator with computed key expressions.
Forbid for…in statements https://palantir.github.io/tslint/rules/no-for-in/
Disallows iterating over an array with a for-in loop.
Disallows importing modules that are not listed as dependency in the project's package.json.
Avoid import statements with side-effect.
Warns on use of ${ in non-template strings.
Disallows using the this keyword outside of classes.
Disallow irregular whitespace outside of strings and comments
Disallows the use constant number values outside of variable assignments. When no list of allowed values is specified, -1, 0 and 1 are allowed by default.
Forbid explicitly declared or implicitly returned union types with both null and undefined as members https://palantir.github.io/tslint/rules/no-null-undefined-union/
Disallows use of the null keyword literal.
Disallows reassigning parameters.
Disallows /// <reference path=> imports (use ES6-style imports instead).
Disallows shadowing variable declarations.
Forbids array literals to contain missing elements.
Forbids unnecessary string literal property access.
Allows obj["prop-erty"] (can't be a regular property access).
Disallows obj["property"] (should be obj.property).
Flags throwing plain strings or concatenations of strings because only Errors produce proper stack traces.
Disallows importing any submodule.
Disallows falling through case statements.
Disallows unnecessary references to this.
Disallows trailing whitespace at the end of a line.
Replaces x => f(x) with just f.
To catch more cases, enable only-arrow-functions and arrow-return-shorthand too.
Disallows classes that are not strictly necessary.
Forbids a 'var'/'let' statement or destructuring initializer to be initialized to 'undefined'.
Disallows control flow statements, such as return, continue break and throws in finally blocks.
Disallows unused expression statements.
Disallows usage of variables before their declaration.
Requires expressions of type void to appear in statement position.
Checks that decimal literals should begin with '0.' instead of just '.', and should not end with a trailing '0'.
Enforces consistent object literal property quote style.
Enforces use of ES6 object literal shorthand when possible.
Checks ordering of keys in object literals.
Requires the specified tokens to be on the same line as the expression preceding them.
Disallows multiple variable definitions in the same declaration statement.
Disallows traditional (non-arrow) function expressions.
Requires that import statements be alphabetized.
Recommends to use a conditional expression instead of assigning to the same thing in each branch of an if statement.
Requires that variable declarations use const instead of let and var if possible.
Recommends a 'for-of' loop over a standard 'for' loop if the index is only used to access the array being iterated.
Warns for class methods that do not use 'this'.
Prefer foo(): void over foo: () => void in interfaces and types.
Enforces the use of the ES2015 object spread operator over Object.assign() where appropriate.
Prefer a switch statement to an if statement with simple === comparisons.
Prefer a template expression over string literal concatenation.
Prefer while loops instead of for loops without an initializer and incrementor.
Force functions marked async contain an await or return statement https://palantir.github.io/tslint/rules/no-async-without-await/
Requires any function or method that returns a promise to be marked async.
Requires single or double quotes for string literals.
Requires the radix parameter to be specified when calling parseInt.
When adding two variables, operands must both be of type number or of type string.
Prefer return; in void functions and return undefined; in value-returning functions.
Enforces consistent semicolon usage at the end of every statement.
Require or disallow a space before function parenthesis
Enforces spaces within parentheses or disallow them.
Require a default case in all switch statements.
Checks whether the final clause of a switch statement ends in break;.
Requires or disallows trailing commas in array and object literals, destructuring assignments, function typings, named imports and exports and function parameters.
Requires === and !== in place of == and !=.
Makes sure result of typeof is compared to correct string values
Enforces use of the isNaN() function to check for NaN references instead of a comparison to the NaN constant.
Checks variable names for various errors.
The severity level used when a rule specifies "default" as its severity level. If undefined, "error" is used.
Additional linter options.
1 nested properties
An array of globs. Any file matching these globs will not be linted. All exclude patterns are relative to the configuration file they were specified in.
Definitions
Severity level. Level "error" will cause exit code 2.
Requires parentheses around the parameters of arrow function definitions.
Suggests to convert () => { return x; } to () => x.
Bans the use of specific functions or global methods.
In a binary expression, a literal should always be on the right-hand side if possible. For example, prefer 'x + 1' over '1 + x'.
Enforces PascalCased class and interface names.
Enforces formatting rules for single-line comments.
Enforces documentation for important items be filled out.
Enforces a threshold of cyclomatic complexity.
Enforces a certain header comment for all files, matched by a regular expression.
Enforces a consistent file naming convention.
Requires a for ... in statement to be filtered with an if statement.
Disallows importing the specified modules directly via import and require.
Instead only sub modules may be imported from that module.
Ensures proper spacing between import statement keywords
Enforces basic format rules for JSDoc comments.
Only allows labels in sensible locations.
A file may not contain more than the specified number of classes
Requires files to remain under a certain number of lines
Requires lines to be under a certain max length.
Enforces blank line before return when not the only line in the block.
Requires that chained method calls be broken apart onto separate lines.
Requires parentheses when invoking a constructor via the new keyword.
Disallows any type of assignment in conditionals.
Disallows one or more blank lines in a row.
Disallows access to the constructors of String, Number, and Boolean.
Disallows default exports in ES6-style modules.
Disallows multiple import statements from the same module.
Warns if 'super()' appears twice in a constructor.
Prevents duplicate cases in switch statements.
Disallows duplicate variable declarations in the same block scope.
Bans usage of the delete operator with computed key expressions.
Forbid for…in statements https://palantir.github.io/tslint/rules/no-for-in/
Disallows iterating over an array with a for-in loop.
Disallows importing modules that are not listed as dependency in the project's package.json.
Avoid import statements with side-effect.
Warns on use of ${ in non-template strings.
Disallows using the this keyword outside of classes.
Disallow irregular whitespace outside of strings and comments
Disallows the use constant number values outside of variable assignments. When no list of allowed values is specified, -1, 0 and 1 are allowed by default.
Forbid explicitly declared or implicitly returned union types with both null and undefined as members https://palantir.github.io/tslint/rules/no-null-undefined-union/
Disallows use of the null keyword literal.
Disallows reassigning parameters.
Disallows /// <reference path=> imports (use ES6-style imports instead).
Disallows shadowing variable declarations.
Forbids array literals to contain missing elements.
Forbids unnecessary string literal property access.
Allows obj["prop-erty"] (can't be a regular property access).
Disallows obj["property"] (should be obj.property).
Flags throwing plain strings or concatenations of strings because only Errors produce proper stack traces.
Disallows importing any submodule.
Disallows falling through case statements.
Disallows unnecessary references to this.
Disallows trailing whitespace at the end of a line.
Replaces x => f(x) with just f.
To catch more cases, enable only-arrow-functions and arrow-return-shorthand too.
Disallows classes that are not strictly necessary.
Forbids a 'var'/'let' statement or destructuring initializer to be initialized to 'undefined'.
Disallows control flow statements, such as return, continue break and throws in finally blocks.
Disallows unused expression statements.
Disallows usage of variables before their declaration.
Requires expressions of type void to appear in statement position.
Checks that decimal literals should begin with '0.' instead of just '.', and should not end with a trailing '0'.
Enforces consistent object literal property quote style.
Enforces use of ES6 object literal shorthand when possible.
Checks ordering of keys in object literals.
Requires the specified tokens to be on the same line as the expression preceding them.
Disallows multiple variable definitions in the same declaration statement.
Disallows traditional (non-arrow) function expressions.
Requires that import statements be alphabetized.
Recommends to use a conditional expression instead of assigning to the same thing in each branch of an if statement.
Requires that variable declarations use const instead of let and var if possible.
Recommends a 'for-of' loop over a standard 'for' loop if the index is only used to access the array being iterated.
Warns for class methods that do not use 'this'.
Prefer foo(): void over foo: () => void in interfaces and types.
Enforces the use of the ES2015 object spread operator over Object.assign() where appropriate.
Prefer a switch statement to an if statement with simple === comparisons.
Prefer a template expression over string literal concatenation.
Prefer while loops instead of for loops without an initializer and incrementor.
Force functions marked async contain an await or return statement https://palantir.github.io/tslint/rules/no-async-without-await/
Requires any function or method that returns a promise to be marked async.
Requires single or double quotes for string literals.
Requires the radix parameter to be specified when calling parseInt.
When adding two variables, operands must both be of type number or of type string.
Prefer return; in void functions and return undefined; in value-returning functions.
Enforces consistent semicolon usage at the end of every statement.
Require or disallow a space before function parenthesis
Enforces spaces within parentheses or disallow them.
Require a default case in all switch statements.
Checks whether the final clause of a switch statement ends in break;.
Requires or disallows trailing commas in array and object literals, destructuring assignments, function typings, named imports and exports and function parameters.
Requires === and !== in place of == and !=.
Makes sure result of typeof is compared to correct string values
Enforces use of the isNaN() function to check for NaN references instead of a comparison to the NaN constant.
Checks variable names for various errors.
Enforces function overloads to be consecutive.
Requires using either 'T[]' or 'Array
Warns for an awaited value that is not a Promise.
Bans specific types from being used. Does not ban the corresponding runtime objects from being used.
An interface or literal type with just a call signature can be written as a function type.
Requires interface names to begin with a capital 'I'
Prefer an interface declaration over a type literal (type T = { ... })
Requires that a default import have the same name as the declaration it imports. Does nothing for anonymous default exports.
Requires explicit visibility declarations for class members.
Requires the use of as Type for type assertions instead of <Type>.
Warns on comparison to a boolean literal, as in x === true.
Promises returned by functions must be handled appropriately.
Disallows explicit type declarations for variables or parameters initialized to a number, string, or boolean.
Disallow type inference of {} (empty object type) at function and constructor call sites
Disallows mergeable namespaces in the same file.
Warns on apparent attempts to define constructors for interfaces or new for classes.
Disallows use of internal modules and namespaces.
Forbids an object literal to appear in a type assertion expression.
Casting to any is still allowed.
Disallows parameter properties in class constructors.
Forbids JSDoc which duplicates TypeScript functionality.
Don't <reference types="foo" /> if you import foo anyway.
Warns when a method is used as outside of a method call.
Warns when a namespace qualifier (A.x) is unnecessary.
Warns if a type assertion does not change the type of an expression.
Warns when using an expression of type 'any' in a dynamic way.
Uses are only allowed if they would work for {} | null | undefined.
Type casts and tests are allowed.
Expressions that work on all values (such as "" + x) are allowed.
Disallows unused imports, variables, functions and private class members. Similar to tsc's --noUnusedParameters and --noUnusedLocals options, but does not interrupt code compilation.
Disallows the use of require statements except in import statements.
Requires that private variables are marked as readonly if they're never modified outside of the constructor.
Restricts the types allowed in boolean expressions. By default only booleans are allowed.
The following nodes are checked:
- Arguments to the
!,&&, and||operators - The condition in a conditional expression (
cond ? x : y) - Conditions for
if,for,while, anddo-whilestatements.
Warns for type predicates that are always true or always false. Works for 'typeof' comparisons to constants (e.g. 'typeof foo === "string"'), and equality comparison to 'null'/'undefined'. (TypeScript won't let you compare '1 === 2', but it has an exception for '1 === undefined'.) Does not yet work for 'instanceof'. Does not warn for 'if (x.y)' where 'x.y' is always truthy. For that, see strict-boolean-expressions.
This rule requires strictNullChecks to work properly.
Requires or disallows whitespace for type definitions.
Checks that type literal members are separated by semicolons. Enforces a trailing semicolon for multiline type literals.
Warns for any two overloads that could be unified into one by using a union or an optional/rest parameter.
Warns if an explicitly specified type argument is the default for that type parameter.
Prevents using the built-in Function constructor.