diff --git a/packages/eslint-plugin-putout/lib/add-newlines-between-types-in-union/README.md b/packages/eslint-plugin-putout/lib/add-newlines-between-types-in-union/README.md index e53dfcffd..001361ff7 100644 --- a/packages/eslint-plugin-putout/lib/add-newlines-between-types-in-union/README.md +++ b/packages/eslint-plugin-putout/lib/add-newlines-between-types-in-union/README.md @@ -11,7 +11,8 @@ type a = string | number | object | boolean; ## ✅ Example of correct code ```js -type a = string +type a = + | string | number | object | boolean; diff --git a/packages/eslint-plugin-putout/lib/add-newlines-between-types-in-union/index.js b/packages/eslint-plugin-putout/lib/add-newlines-between-types-in-union/index.js index 069626ebb..ac672333b 100644 --- a/packages/eslint-plugin-putout/lib/add-newlines-between-types-in-union/index.js +++ b/packages/eslint-plugin-putout/lib/add-newlines-between-types-in-union/index.js @@ -21,9 +21,7 @@ module.exports.filter = ({text, node}) => { return regExp.test(text); }; -module.exports.fix = ({text}) => { - return text.replace(/\s\|/g, '\n |'); -}; +module.exports.fix = ({text}) => '\n | ' + text.replace(/\s\|/g, '\n |'); module.exports.include = () => [ 'TSUnionType', diff --git a/packages/eslint-plugin-putout/lib/add-newlines-between-types-in-union/index.spec.js b/packages/eslint-plugin-putout/lib/add-newlines-between-types-in-union/index.spec.js index 5e31b88b8..fd7cd8a79 100644 --- a/packages/eslint-plugin-putout/lib/add-newlines-between-types-in-union/index.spec.js +++ b/packages/eslint-plugin-putout/lib/add-newlines-between-types-in-union/index.spec.js @@ -46,7 +46,8 @@ ruleTester.run('add-newlines-between-types-in-union', rule, { type a = string | boolean | number | object; `, output: montag` - type a = string + type a = + | string | boolean | number | object; diff --git a/packages/eslint-plugin-putout/test/fixture/add-newlines-between-types-in-union-fix.ts b/packages/eslint-plugin-putout/test/fixture/add-newlines-between-types-in-union-fix.ts index 62316395f..2f18eb205 100644 --- a/packages/eslint-plugin-putout/test/fixture/add-newlines-between-types-in-union-fix.ts +++ b/packages/eslint-plugin-putout/test/fixture/add-newlines-between-types-in-union-fix.ts @@ -1,4 +1,5 @@ -type a = string +type a = + | string | boolean | object | number;