Skip to content

Commit

Permalink
feature: eslint-plugin-putout: add-newline-between-types: improve
Browse files Browse the repository at this point in the history
  • Loading branch information
coderaiser committed Dec 11, 2024
1 parent b2c34de commit 948f1a2
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ type a = string | number | object | boolean;
## ✅ Example of correct code

```js
type a = string
type a =
| string
| number
| object
| boolean;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
type a = string
type a =
| string
| boolean
| object
| number;

0 comments on commit 948f1a2

Please sign in to comment.