-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Loïc Fürhoff
authored and
Loïc Fürhoff
committed
Jul 10, 2023
1 parent
850d169
commit 5bfdabe
Showing
4 changed files
with
17 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,16 @@ | ||
import { Pipe, PipeTransform } from '@angular/core'; | ||
import prettier from 'prettier'; | ||
import htmlParser from 'prettier/parser-html'; | ||
import babelParser from 'prettier/parser-babel'; | ||
import htmlParser from 'prettier/parser-html'; | ||
|
||
@Pipe({ | ||
name: 'formatCode' | ||
}) | ||
export class FormatCodePipe implements PipeTransform { | ||
|
||
transform(value: string, parser: prettier.BuiltInParserName | prettier.CustomParser = 'html'): string { | ||
if (!value || !value.length) { return value; } | ||
return prettier.format(value, { parser, plugins: [htmlParser, babelParser], htmlWhitespaceSensitivity: 'ignore' }); | ||
transform(value: string, parser: prettier.BuiltInParserName | prettier.CustomParser = 'html'): Promise<string> { | ||
if (!value || !value.length) { return Promise.resolve(value); } | ||
return prettier.format(value, { parser, plugins: [htmlParser as any, babelParser as any], htmlWhitespaceSensitivity: 'ignore' }); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,6 +21,7 @@ | |
"es2018", | ||
"dom" | ||
], | ||
"useDefineForClassFields": false | ||
"useDefineForClassFields": false, | ||
|
||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.