From a54720ac4cea49b16c2ad29e2ce10dcf04951f19 Mon Sep 17 00:00:00 2001 From: Enzo Innocenzi Date: Thu, 7 Apr 2022 14:05:07 +0200 Subject: [PATCH 1/2] feat: add `eslint` formatter --- src/Formatters/EslintFormatter.php | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 src/Formatters/EslintFormatter.php diff --git a/src/Formatters/EslintFormatter.php b/src/Formatters/EslintFormatter.php new file mode 100644 index 0000000..02b14a3 --- /dev/null +++ b/src/Formatters/EslintFormatter.php @@ -0,0 +1,20 @@ +run(); + + if (! $process->isSuccessful()) { + throw new ProcessFailedException($process); + } + } +} From de8cb0caba4c48e14d299f72211177906df12b4f Mon Sep 17 00:00:00 2001 From: Enzo Innocenzi Date: Thu, 7 Apr 2022 14:11:49 +0200 Subject: [PATCH 2/2] docs: mention both eslint and prettier --- docs/laravel/executing-the-transform-command.md | 2 +- docs/laravel/installation-and-setup.md | 6 +++--- docs/usage/formatters.md | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/docs/laravel/executing-the-transform-command.md b/docs/laravel/executing-the-transform-command.md index 207bfb7..5ce42d8 100755 --- a/docs/laravel/executing-the-transform-command.md +++ b/docs/laravel/executing-the-transform-command.md @@ -25,7 +25,7 @@ php artisan typescript:transform --output=types.d.ts This file will be stored in the resource's path of your Laravel application. -It is also possible to automatically format the generated TypeScript with prettier: +It is also possible to automatically format the generated TypeScript with Prettier, ESLint, or a custom formatter: ```bash php artisan typescript:transform --format diff --git a/docs/laravel/installation-and-setup.md b/docs/laravel/installation-and-setup.md index 7f1e574..df224ee 100755 --- a/docs/laravel/installation-and-setup.md +++ b/docs/laravel/installation-and-setup.md @@ -83,9 +83,9 @@ return [ 'writer' => Spatie\TypeScriptTransformer\Writers\TypeDefinitionWriter::class, /* - * The generated TypeScript file can be formatted. We ship a Prettier formatter - * out of the box: `PrettierFormatter` but you can also implement your own one. - * The generated TypeScript will not be formatted when no formatter was set. + * The generated TypeScript file can be formatted. We ship two formatters by + * default: a Prettier and an ESLint one. You can also implement your own. + * The generated TypeScript will not be formatted if none is configured. */ 'formatter' => null, diff --git a/docs/usage/formatters.md b/docs/usage/formatters.md index 8a0230f..aeda7cb 100644 --- a/docs/usage/formatters.md +++ b/docs/usage/formatters.md @@ -3,7 +3,7 @@ title: Formatters weight: 7 --- -This output file with all the transformed types can be formatted using tools like Prettier. We ship a Prettier formatter by default with the package, which will run Prettier after the output file is generated. you can configure it as such: +This output file with all the transformed types can be formatted using tools like Prettier. We ship an ESLint and a Prettier formatter, which will run after the output file is generated. For instance, you can configure the Prettier formatter as such: ```php $config = TypeScriptTransformerConfig::create()