putout v22.2.0
Improved support of typescript-eslint
If night and day were to approach the Sun, Both would disappear.
In the same way, their duality would vanish
If their essential unity were seen(c) Jnaneshvara "Amritanubhav"
More TypeScript nodes supported 💪
Thanks for an issue reported by @brunoparga , typescrit-eslint support improved drastically 🎉 .
It's AST has couple differences with @babel/parser that should be handled.
To the point! When you use .eslintrc.json:
{
"parser": "@typescript-eslint/parser",
"plugins": [
"putout",
"@typescript-eslint"
],
"extends": [
"plugin:putout/recommended",
"plugin:@typescript-eslint/recommended"
]
}With help of estree-to-babel, such constructs:
// TSClassImplements
class A implements B {
}
// TSInterfaceHeritage
interface x extends y.z.m {
}
// TSAbstractMethodDefinition
class Base {
abstract getName(): string;
}
// PrivateIdentifier
class ClassWithPrivateField implements B{
#privateField;
pubplicField = 5;
constructor() {
this.#privateField = 5;
}
}Will work as expected, and will be parsed without a problem.
here is a circle of transformations: TypeScript AST -> ESTree -> Babel. But that's not a problem for estree-to-babel.
Improved support of comments
When using both typescript-eslint and eslint-plugin-putout there was an issue with comments:
/**
* Copyright (c) 2016 The xterm.js authors. All rights reserved.
* @license MIT
*/
import { ICircularList } from 'common/Types';
/**
* Represents a circular list; a list with a maximum size that wraps around when push is called,
* overriding values at the start of the list.
*/
export class CircularList<T> implements ICircularList<T> {
get maxLength() {
if (2) // <-- should be removed with remove-constant-conditions
alert();
return this._maxLength;
}
}After applying fixes all comments go on top:
/**
* Copyright (c) 2016 The xterm.js authors. All rights reserved.
* @license MIT
*/
/**
* Represents a circular list; a list with a maximum size that wraps around when push is called,
* overriding values at the start of the list.
*/
import { ICircularList } from 'common/Types';
export class CircularList<T> implements ICircularList<T> {
get maxLength() {
alert();
return this._maxLength;
}
}Which is very bad and has no sense. Starting from eslint-plugin-putout v11.18.0 it's fixed, and comments placed in the way they should:
/**
* Copyright (c) 2016 The xterm.js authors. All rights reserved.
* @license MIT
*/
import { ICircularList } from 'common/Types';
/**
* Represents a circular list; a list with a maximum size that wraps around when push is called,
* overriding values at the start of the list.
*/
export class CircularList<T> implements ICircularList<T> {
get maxLength() {
alert();
return this._maxLength;
}
}That's all folks 🎈.
Have a nice day!
If you got any problems, create an issue!
🐞 fix
- (@putout/plugin-remove-unused-variables) OptionalMemberExpression: computed property
- (eslint-plugin-putout) array-element-newline: minimum elements: 4 -> 5
- (eslint-plugin-putout) add-newlinew-before-function-call: trimed whitespaces on empty line
- (eslint-plugin-putout) add-newline-before-function-call: add support of comments
- (eslint-plugin-putout) add-newline-before-function-call: continue -> return
🔥 feature
- (package) @putout/plugin-remove-constant-conditions) v3.0.0
- (@putout/plugin-remove-constant-conditions) drop support of node < 14
- (@putout/plugin-remove-constant-conditions) add support of consequent not body
- (eslint-plugin-putout) safe: disable remove-unreachable-code
- (@putout/plugin-remove-unused-variables improve support of OptionalMemberExpression
- (eslint-plugin-putout) add-newline-before-function-call: add support of ArrayExpression and ObjectExpression
- (eslint-plugin-putout) add add-newline-after-function-call
- (@putout/eslint-config) padding-line-between-statements: add support of while
- (eslint-plugin-putout) add add-newline-before-function-call
- (@putout/eslint-config) add func-call-spacing
- (eslint-plugin-putout) tape-remove-newline-before-t-end: add support of trimed newline
- (eslint-plugin-putout) add add-newline-before-t-end
- (@putout/plugin-declare-undefined-variables add maybeEmptyArray
- (eslint-plugin-putout) array-element-newline: add support of Identifier
- (@putout/eslint-config) padding-line-between-statements: add newline between for and return
- (@putout/plugin-remove-useless-spread) add support of logical expressions
