Releases: palantir/tslint
v5.4.0
⭐️ Non-breaking API changes
- The
--type-check
CLI option now only enables checking for compiler errors before linting. It is no longer required to enable rules that use the type checker -- only need to supply--project
now.
🎉 New rules, options, and fixers
- [new-rule]
switch-final-break
(#2804) - [new-rule]
use-default-type-parameter
(#2253) - [new-rule]
binary-expression-operand-order
(#2805) - [new-rule-option]
ban
new options format: allows to specify an optional explanation message for function bans, banning nested methods and using a wildcard for object of a method ban (#2547) - [new-rule-option]
no-duplicate-variable
addscheck-parameters
option to check if variable has the same name as a parameter (#2597) - [new-rule-option]
curly
: "as-needed" option (#2842) - [new-rule-option]
no-unbound-method
add option"ignore-static"
(#2751) - [new-rule-option]
strict-boolean-expressions
addsallow-boolean-or-undefined
(#2820) - [new-fixer]
object-literal-shorthand
can fix longhand methods (#2558)
🛠 Bugfixes & enhancements
- [bugfix]
prefer-object-spread
allows constructor, function and method calls and more as first argument toObject.assign
(#2828) - [bugfix]
no-unbound-method
walker skips past the parent if it is a cast or parenthesized expression (#2838) - [bugfix]
object-literal-shorthand
: fixed suggestion for generator functions (#2558) - [bugfix] Fixed issue with case sensitivity of
no-unused-variable
rule on Windows (#2819) - [bugfix] don't crash
tslint --project
ifallowJs
is set in tsconfig.json (#2823) - [bugfix]
align
with option"members"
: check members of class expressions; don't check semicolons in classes (#2668) - [bugfix]
no-inferred-empty-object-type
: fix stack overflow (#2762) - [bugfix]
semicolon
: don't warn about unnecesary semicolon when it is actually needed, e.g. when followed by type assertion or template string (#2655) - [bugfix]
space-before-function-paren
: Ignore async arrow function with no parentheses (#2833) - [bugfix]:
no-unsafe-any
: Don't fail oncontinue label;
(#2830) - [bugfix]
no-unbound-method
: Allow unbound method to be used as a condition (#2834) - [bugfix]
no-unsafe-any
: Allow to switch on a value of typeany
(#2836) - [bugfix]
no-unsafe-any
: Don't markdeclare global {}
as an unsafe any. (#2839) - [bugfix]
indent
now checks indentation of expressions inside template strings (#2826) - [enhancement]
--project
(or-p
) enables rules that require the type checker.--type-check
only checks for errors before linting is no longer required (#2773) - [enhancement]
deprecation
: error message includes deprecation text if available (#2748) - [enhancement]
cyclomatic-complexity
: Don't count empty switch case(#2743) - [enhancement]
strict-boolean-expressions
: Allowany
, andtrue
andfalse
literal types (#2758) - [enhancement]
no-floating-promises
: Allow 'promise.catch()' (#2774) - [enhancement]
comment-format
no longer excludes comments with triple slash from linting except/// <reference path="..."/>
(#2616) - [enhancement]
prefer-object-spread
: lint more locations where return value is used. (#2828) - [enhancement]
semicolon
: option"never"
is now spec compliant (#2655) - [enhancement]
object-literal-shorthand
handles async functions correctly (#2558) - [enhancement]
--test
CLI option: allow passing path to tslint.json (#2784) - [enhancement] Use commander instead of optimist for CLI arguments (#2689)
- [enhancement]
strict-type-predicates
: warn if strictNullChecks is not enabled (#2786)
Thanks to our contributors!
- Klaus Meinhardt
- Manuel Lopez
- Andy Hanson
- Piotr Tomiak
v5.3.2
v5.3.0
⚠️ This release may require a change to tslint.json
- [enhancement]
prefer-switch
: Change defaultmin-cases
to 3. (#2669)
🎉 New rules, options, and fixers
- [new-cli-option] cli: Add
outputAbsolutePaths
option (#2667) - [new-rule]
prefer-object-spread
(#2624) - [new-rule]
encoding
(#2368) - [new-rule]
prefer-conditional-expression
(#2363) - [new-rule-option]
indent
support indent size (#2723) - [new-rule-option]
object-literal-sort-keys
addsignore-case
(#2592) - [new-rule-option]
quotemark
: Addavoid-template
option (#2766) - [new-rule-option]
await-promise
: What's considered a "Promise" is now configurable. (#2661) - [new-fixer]
indent
(#2723) - [new-fixer]
typedef-whitespace
(#2718)
🛠 Bugfixes & enhancements
- [bugfix]
return-undefined
: Treat a return typevoid | undefined
same asvoid
(#2731) - [bugfix]
no-unnecessary-initializer
: HandleBindingElement
anywhere, not just in aVariableDeclaration
. (#2707) - [bugfix]
jsdoc-format
: correctly handle alignment in files with BOM (#2619) - [bugfix]
jsdoc-format
: don't treat empty comments (/**/
) as jsdoc (#2619) - [bugfix]
typedef-whitespace
don't warn for leading whitespace if token is preceded by line break (#2718) - [bugfix] Make "completed-docs" rule respect "public" privacy (or lack thereof) (#2749)
- [bugfix]
jsdoc-format
: fixed error position if line ends with\r\n
(#2619) - [bugfix]
prefer-switch
: add missing checks for some expressions (#2686) - [bugfix]
prefer-template
: Allow"a" + "b" + "c"
. (#2741) - [bugfix]
prefer-const
: fix false positive with variable declared outside of for-of or for-in (#2760) - [bugfix]
--project
: fix file matching with relative path totsconfig.json
(#2688) - [bugfix]
no-default-export
: correctly handleexport default abstract class {...}
(#2630) - [bugfix]
no-mergeable-namespace
: display correct line in error message (#2656) - [bugfix]
object-literal-sort-keys
: handle object spread correctly (#2592) - [bugfix] Consistently output absolute/relative paths (#2667)
- [bugfix]
await-promise
: Consider types derived from a Promise in union types too. (#2661) - [bugfix]
no-unsafe-any
: Fix bug where number literal in type position was flagged as an unsafeany
. (#2712) - [api] Deprecate
Lint.Utils.objectify
(#2764) - [enhancement] better error messages in
variable-name
(#2672) - [enhancement]
typedef
: Use name or parameters for error location (#2460) - [enhancement]
object-literal-sort-keys
: check shorthand properties (#2592) - [enhancement]
space-before-function-paren
: Handleget
/set
accessor (#2700) - [enhancement]
typedef-whitespace
added checks for arrow function, call and construct signature (#2718) - [enhancement]
no-object-literal-type-assertion
: Allow cast toany
(#2671) - [enhancement] cli:
-p
option handles directories (#2756) - [develop] testing rules with type information is enabled when a
tsconfig.json
is found next totslint.json
(#2769) - [configuration] deprecate mixed case tslint.json (#2713)
Thanks to our contributors!
- Andy Hanson
- Klaus Meinhardt
- Martin Probst
- Filipe Silva
- walkerburgin
- René Scheibe
v5.2.0
- [rule-change]
no-console
bans all console methods when no methods are specified (#2610) - [new-rule]
no-object-literal-type-assertion
(#2580) - [new-rule]
no-irregular-whitespace
(#2487) - [new-rule]
prefer-switch
(#2331) - [new-rule]
number-literal-format
(#2526) - [new-rule]
deprecation
(#2395) - [new-rule]
no-unnecessary-type-assertion
(#2519) - [new-fixer]
interface-over-type-literal
(#2617) - [new-fixer]
callable-types
(#2552) - [new-fixer]
no-string-literal
(#2495) - [new-fixer]
no-internal-module
(#2517) - [new-rule-option]
align
rule addedmembers
option, which checks alignment of methods and properties of classes, objects, interfaces, type literals and object destructuring (#2387) - [new-rule-option]
align
rule addedelements
option, which checks alignment of elements in array literals, array destructuring and tuple types (#2387) - [new-rule-option]
trailing-comma
adds more granular options to specify trailing commas for arrays, objects, functions, type literals, imports, and exports (#2538) - [api] Deprecate
ScopeAwareRuleWalker
andBlockScopeAwareRuleWalker
. (#2561) - [develop] added support for error templates in rule tests (#2481)
- [bugfix] Fixes "Severity for rule not found" error (#2516)
- [bugfix]
no-unused-expression
: allowvoid(0)
in addition tovoid 0
andvoid
in expression and statement position (#2645) - [bugfix]
align
: fix false positive for files with BOM (#2642) - [bugfix]
return-undefined
: Handle contextual types with ambiguous signatures; allowany
; and handle async functions. (#2576) - [bugfix]
semicolon
: don't mark semicolon as unnecessary when the next statement is on the same line (#2591) - [bugfix]
no-internal-module
: no more false positives for global augmentation (#2517) - [bugfix]
no-unnecessary-qualifier
: no longer breaks when walking a function that referencesarguments
(#2555) - [bugfix]
prefer-const
no longer shows warnings on ambient declarations (#2391) - [bugfix]
callable-types
: suggest correct fix for interfaces with type arguments (#2552) - [bugfix]
quotemark
: fix regression with jsx attributes (#2605) - [bugfix]
adjacent-overload-signatures
handles functions ending in semicolon (#2412) - [bugfix]
object-literal-key-quotes
: correctly stringify numbers when fixing (#2515) - [bugfix]
object-literal-key-quotes
: does no longer require quotes for property names containing digits (#2515) - [enhancement] Failures in extended config files now indicate which file (#2588)
- [enhancement]
align
: Don't report 'statements are not aligned' for empty statements (#2653) - [enhancement]
class-name
now also checks class expressions (#2553) - [enhancement]
optionExamples
: Allow to use an options array directly instead of a string representation. (#2527) - [enhancement]
rulesDirectory
can now be resolved with Nodes resolve logic, if the directory contains anindex.js
(#2163) (#2358) - [enhancement]
no-unused-expression
: narrow error location for comma separated expressions and conditional expressions (#2645) - [enhancement]
no-string-literal
now handles escaped strings (#2495) - [enhancement]
no-unnecessary-callback-wrapper
: Allowx => x(x)
(#2524) - [enhancement]
no-var-keyword
: Allow global var declarations (#2513)
Thanks to our contributors!
- Andy Hanson
- Alex Eagle
- Donald Pipowitch
- Klaus Meinhardt
- Gord P
- Andy
- Quentin
- Mitchell Wills
- Vito
- CSchulz
- Josh Goldberg
- Brian Olore
- Manuel Lopez
- James Clark
v5.1.0
- [new-rule]
no-invalid-template-strings
(#2332) - [new-rule]
no-sparse-arrays
(#2407) - [new-rule-option]
no-void-expression
: addsignore-arrow-function-shorthand
(#2445) - [api]
tslint:all
configuration (#2417) - [bugfix] In tslint:recommended move
no-reference-import
fromjsRules
torules
(#2441) - [bugfix]
no-unnecessary-callback-wrapper
: only check if callback is identifier, allow all other expressions (#2510) - [bugfix]
member-access
: Skip index signature, it can not have an access modifier (#2437) - [bugfix]
restrict-plus-operands
fixes regression where every assignment and comparison was checked (#2454) - [bugfix]
no-unnecessary-callback-wrapper
: allow async wrapper function (#2510) - [bugfix]
prefer-for-of
: No error ifdelete
is used (#2458) - [bugfix]
radix
: don't warn for missing radix on method calls (#2352) - [bugfix]
no-use-before-declare
: Handle symbol with empty declarations list. (#2436) - [bugfix]
strict-type-predicates
: Check for construct signatures inisFunction
. (#2479) - [enhancement]
strict-boolean-expressions
: When--strictNullChecks
is turned off,allow-null-union
andallow-undefined-union
turn off "always truthy" errors. (#2373) - [enhancement]
radix
: added check for global.parseInt and window.parseInt (#2352) - [enhancement]
arrow-return-shorthand
: Improve failure message when return expression is an object literal (#2466)
v5.0.0
NPM distribution note: tslint@next
is deprecated now that the standard tslint
package allows a peer dependency of typescript@next
. Please switch to tslint@latest
.
🔥 Breaking changes
- Minimum version of TypeScript is now 2.1.0 (#2425)
- The severity level of each rule is now configurable and defaults to severity "error". This affects the output of formatters:
- [formatter]
msbuild
was outputting all failures as "warning". - [formatter]
pmd
was outputting all failures as priority 1. Now, it uses priority 3 for "error" (default) and priority 4 for "warning"
- [formatter]
- [formatter]
json
changed thefix
property to now contain either one replacement or an array of replacements (#2403) tslint:recommended
configuration updated withtslint:latest
rules & options (#2424)- Removed
no-unused-new
rule, with logic moved intono-unused-expression
(#2269) no-trailing-whitespace
now checks template strings by default. Use the new optionsignore-template-strings
to restore the old behavior. (#2359)- Some rules that previously worked without the type checker now require it. This includes:
no-unused-variable
no-use-before-declare
API breaks for editor integration
LintResult.failureCount
is now separated intoLintResult.errorCount
andLintResult.warningCount
class Fix
is nowtype Fix = Replacement | Replacement[]
API breaks for custom rules
-
Removed method
skip
fromRuleWalker
(#2313) -
Removed all use of the TypeScript Language Service, use only Program APIs instead (#2235)
- This breaks custom rule compilation. If your rule was not using the
ts.LanguageService
APIs, the migration is quite simple:
- public applyWithProgram(srcFile: ts.SourceFile, langSvc: ts.LanguageService): Lint.RuleFailure[] { - return this.applyWithWalker(new Walker(srcFile, this.getOptions(), langSvc.getProgram())); + public applyWithProgram(srcFile: ts.SourceFile, program: ts.Program): Lint.RuleFailure[] { + return this.applyWithWalker(new Walker(srcFile, this.getOptions(), program));
- N.B. If you are refactoring your custom rules, consider these performance tips for writing custom rules.
- This breaks custom rule compilation. If your rule was not using the
-
Removed
createFix
. Replacements should be passed directly into addFailure. (#2403) -
Removed deprecated
scanAllTokens
andskippableTokenAwareRuleWalker
(#2370)
🎉 Notable features & enhancements
-
[feature] The severity level of each rule is now individually configurable. Default severity can also be configured for a config file. (#629, #345)
- Valid values for
severity
:default
|error | warn | warning | none | off
- Valid values for
defaultSeverity
:error | warn | warning | none | off
- Old style:
{ "extends": "tslint:latest", "rules": { "callable-types": true, "max-line-length": [true, 140] } }
- New style (in this example,
callable-types
outputs errors andmax-line-length
outputs warnings):
{ "extends": "tslint:latest", "defaultSeverity": "error", "rules": { "callable-types": true, "max-line-length": { "options": 140, "severity": "warning" } } }
- Valid values for
-
[new-rule]
prefer-template
(#2243) -
[new-rule]
return-undefined
(#2251) -
[new-rule]
no-reference-import
(#2273) -
[new-rule]
no-unnecessary-callback-wrapper
(#2249) -
[new-fixer]
linebreak-style
(#2394) -
[new-fixer]
eofline
(#2393)
Full list of changes
- [api] Added class
OptionallyTypedRule
, which allows rule authors to write a rule that applies when typing is either enabled or disabled (#2300) - [bugfix]
prefer-function-over-method
now ignores abstract methods (#2307) - [bugfix]
arrow-parens
with optionban-single-arg-parens
now correctly handles functions with return type annotation (#2265) - [bugfix]
prefer-function-over-method
exclude overload signatures (#2315) - [bugfix]
use-isnan
now applies only to comparison operators (#2317) - [bugfix]
file-header-rule
now handles single-line comments correctly (#2320) - [bugfix]
newline-before-return
: fix handling of blank lines between comments (#2321) - [bugfix]
trailing-comma
No longer enforce trailing commas in type parameters and tuple types (#2236) - [bugfix]
align
don't fix if it would remove code (#2379) - [bugfix]
unified-signatures
now recognizes rest parameters (#2342) - [bugfix]
no-inferrable-types
don't warn for inferrable type on readonly property (#2312) - [bugfix]
trailing-comma
no longer crashes on new without parentheses (e.g.new Foo
) (#2389) - [bugfix]
semicolon
Ignore comments when checking for unnecessary semicolon (#2240) - [bugfix]
semicolon
Don't report unnecessary semicolon when followed by regex literal (#2240) - [bugfix] CLI: exit with 0 on type check errors when
--force
is specified (#2322) - [bugfix] CLI:
--test
now correctly strips single quotes from patterns on windows (#2322) - [bugfix]
prefer-const
only fix initialized variables (#2219) - [bugfix]
prefer-const
correctly handle variables shadowed by parameters and catched exceptions (#2219) - [bugfix]
prefer-const
don't warn if one variable in a for loop initializer can not be const (#2219) - [bugfix]
prefer-const
handle more cases in destructuring (#2219) - [bugfix]
no-unused-expression
allow comma separated assignments (#2269) - [chore] removed update-notifier dependency (#2262)
- [development] allow rule tests to specify version requirement for typescript (#2323)
- [enhancement]
ignore-properties
option ofno-inferrable-types
now also ignores parameter properties (#2312) - [enhancement]
unified-signatures
now displays line number of the overload to unify if there are more than 2 overloads (#2270) - [enhancement]
trailing-comma
New checks for CallSignature and NamedExports (#2236) - [enhancement]
semicolon
New check for export statements, function overloads and shorthand module declaration (#2240) - [enhancement]
semicolon
Report unnecessary semicolons in classes and in statement position (for option "always" too) (#2240) - [enhancement]
semicolon
check for semicolon after method overload (#2240) - [enhancement]
array-type
now considerobject
,undefined
andnever
as simple types, allowingobject
,undefined[]
andnever[]
(#1843)(#2353) - [enhancement]
align
check statement alignment for all blocks (#2379) - [enhancement]
align
check parameter alignment for all signatures (#2379) - [enhancement]
--test
can handle multiple paths at once (#2322) - [enhancement]
only-arrow-functions
allow functions that usethis
in the body (#2229) - [enhancement] CLI: print error when
--type-check
is used without--project
(#2322) - [enhancement] CLI: don't print stack trace on type check error (#2322)
- [enhancement] CLI: added
-p
as shorthand for--project
to be consistent withtsc
(#2322) - [enhancement]
prefer-const
show warnings forvar
(#2219) - [enhancement]
quotemark
fixer unescapes original quotemark (e.g.'\''
->"'"
) (#2359) - [enhancement]
no-unused-expression
allow indirect eval(0, eval)("");
(#2269) - [enhancement]
no-unused-expression
checking for unused new can now use optionallow-fast-null-checks
(#2269) - [enhancement]
no-unused-expression
find unused comma separated expressions in all locations of the code (#2269) - [enhancement]
no-unused-expression
find unused expressions inside void expression (#2269) - [new-config-option] Adds
defaultSeverity
with optionserror
,warning
, andoff
. (#2416) - [new-formatter] TAP formatter (#2325)
- [new-rule-option]
no-unused-expression
adds optionallow-tagged-template
to allow tagged templates for side effects (#2269) - [new-rule-option]
no-unused-expression
adds optionallow-new
to allownew
without using the new object (#2269) - [new-rule-option]
member-access
addsno-public
option (#2247) - [new-rule-option]
curly
added optionignore-same-line
(#2334) - [new-rule-option]
{destructuring: "all"}
to only warn if all variables in a destructuring can be const (#2219) - [new-rule-option] added
ignore-template-strings
tono-trailing-whitespace
(#2359) - [rule-update]
array-type
now considerundefined
andnever
as simple types, allowingundefined[]
andnever[]
(#1843)
Thanks to our contributors!
- Brian Olore
- Andy Hanson
- @andy-ms
- Chris Barr
- Klaus Meinhardt
- @bumbleblym
- Josh Goldberg
- James Clark
- @vilic
- Aleksandr Filatov
- Matt Banz
- Karol Janyst
- Mike Deverell
- Alexander James Phillips
- Irfan Hudda
v5.0.0-dev.0
Include the current (incomplete) set of changes for v5.0.0:
-
BREAKING CHANGES
- The severity level of rules is now configurable and defaults to severity "error"
- The following formatters have changed their outputs:
- msbuildFormatter - default was "warning"; it is now "error"
- pmdFormatter - default was priority 1; it is now "error" (priority 3). If set to "warning", it will output priority 4
-
[enhancement] Enable WARN with new config file format (#629, #345)
- Valid values for
severity
:error | warn | warning | none | off
- Old style:
{ "extends": "tslint:latest", "rules": { "callable-types": true } }
- New style, with
interface-name
generating warnings, and passing options tomax-line-length
:
{ "extends": "tslint:latest", "rules": { "callable-types": true, "interface-name": { "severity": "warn" }, "max-line-length": { "options": 140, "severity": "warning" } } }
- Valid values for
v4.5.1-dev.0
Includes changes from v4.5.1 on next
dist-tag.
v4.5.1
v4.5.0
- [new-rule]
no-import-side-effect
(#2155) - [new-rule]
match-default-export-name
(#2117) - [new-rule]
no-non-null-assertion
(#2221) - [new-rule]
ban-types
(#2175) - [new-rule]
no-duplicate-super
(#2038) - [new-rule]
newline-before-return
(#2173) - [new-rule-option]
completed-docs
adds options for location, type, and privacy. Also adds interfaces, enums, types (#2095) - [new-rule-option]
no-inferrable-types
adds optionignore-properties
(#2178) - [new-rule-option]
typedef
adds optionsobject-destructuring
andarray-destructuring
options (#2146) - [new-rule-option]
member-ordering
adds optionalphabetize
(#2101) - [new-rule-option]
no-trailing-whitespace
adds optionignore-jsdoc
(#2177) - [new-rule-option]
no-trailing-whitespace
adds optionignore-comments
option (#2153) - [new-fixer]
no-inferrable-types
automatically remove inferrable type annotations (#2178) - [new-fixer]
no-any
(#2165) - [new-fixer]
noConsecutiveBlankLines
(#2201) - [new-fixer]
object-literal-shorthand
(#2165) - [bugfix]
no-switch-case-fallthrough
handle break, throw, continue and return nested in block, if-else and switch (#2218) - [bugfix]
no-switch-case-fallthrough
allow empty case clauses before default clause (#2218) - [bugfix]
no-mergeable-namespace
ignore property types that can't be merged (#2105) - [bugfix]
object-literal-key-quotes
no need to quote a float if its .toString() is the same. (#2144) - [bugfix]
no-consecutive-blank-lines
Correctly apply fixes at EOF (#2239) - [bugfix]: Fixes installation issue with node 7.5 (#2212)
- [bugfix]:
quotemark
now handles escaped chars (#2224) - [enhancement] Don't exit when a rule requires type checking but type checking is not enabled (#2188)
- [enhancement]
no-switch-case-fallthrough
allow single line comment// falls through
(#2218) - [enhancement]
no-unbound-method
allows property access and binary expressions (#2143) - [api] Introduce
AbstractWalker
for performance (#2093)- see performance and migration docs