Closed ElPrudi closed 1 year ago
Could you please show me your .putout.json
?
I use eslint-plugin-putout
and this is the putout part of it:
{
"putout/putout": [
2,
{
"plugins": ["apply-shorthand-properties", "conditions", "simplify-ternary", "types"],
"rules": {
"apply-shorthand-properties": [
"on",
{
"ignore": []
}
],
"split-variable-declarations": "off",
"new/remove-useless": "off",
"remove-unused-variables": "off",
"remove-console": "off",
"convert-template-to-string": "off",
"remove-useless-array-constructor": "off",
"types/remove-double-negations": "off",
"promises/remove-useless-async": "off",
"convert-object-assign-to-merge-spread": "off",
"apply-destructuring/array": "off",
"apply-destructuring/object": "off",
"promises/add-missing-await": "off",
"typescript/remove-useless-parens": "off",
"remove-useless-arguments/method": "off",
"math/apply-exponentiation": [
"on",
{
"exclude": ["__a * __a", "__a * __a * __a", "__a * __a * __a * __a", "__a * __a * __a * __a * __a"]
}
]
}
}
],
"putout/align-spaces": 0,
"putout/remove-newline-from-empty-object": 0,
"putout/add-newline-after-function-call": 0,
"putout/add-newline-before-function-call": 0,
"putout/add-newline-before-return": 0,
"putout/add-newlines-between-specifiers": 0,
"putout/add-newlines-between-types-in-union": 0,
"putout/array-element-newline": 0,
"putout/function-declaration-paren-newline": 0,
"putout/keyword-spacing": 0,
"putout/long-properties-destructuring": 0,
"putout/multiple-properties-destructuring": 0,
"putout/newline-function-call-arguments": 0,
"putout/nonblock-statement-body-newline": 0,
"putout/nonblock-statement-body-position": 0,
"putout/object-property-newline": 0
}
I can't reproduce this with 1.ts
:
/**
* This is class X
*/
export default class X {
public a(b): string {
if (typeof b === 'number') return 'doStuff'
return 'stuff'
}
}
putout 1.ts --fix
Produces this result:
const isNumber = (a) => typeof a === 'number';
/**
* This is class X
*/
export default class X {
public a(b): string {
if (isNumber(b))
return 'doStuff';
return 'stuff';
}
}
Found it. It only duplicates it, if you also have imports before that. If the inserted function becomes the first line in the file, it doesn't duplicate it.
Fixed in v30.6.0
. Please re-install 🐊.
Is it works for you?
Yes, it works now. Thank you very much :)
Every time this rule is triggered and inserts a function into the file where a class is, the class comment gets duplicated.
For example:
X.ts
:gets transformed into