Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve prettier troubleshooting doc: add npx tsc. #23867

Merged
merged 1 commit into from
May 9, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 25 additions & 4 deletions documentation/ci-fix.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,46 @@

Here are guides to fix some of the CI failure.

## Prerequisites

Most guides here require for you to have `npm` installed, which you can get by installing [Node.js](https://nodejs.org/en/download).

## Spell check

Please add your words to `./custom-words.txt` if you think you have the correct spell.

If your problem is some existing error name that is not a word and need to supress the error in that file (and don't want to add to custom-words.txt), you can add it to `./cSpell.txt`.
If your problem is some existing error name that is not a word and need to suppress the error in that file (and don't want to add to custom-words.txt), you can add it to `./cSpell.txt`.

## Prettier check

First, ensure you have fulfilled `Prerequisites` as explained above.

To update all the spec files for a given service run the following:

```
# To fix a particular service swagger cd to that directory like
# To fix all the files in the repo run from the root of the repo
cd <local_repo_clone_root>

# OPTIONAL STEP: To fix a particular service swagger cd to that directory like
cd specification/contosowidgetmanager
# to fix all the files in the repo run from the root of the repo

# Install the dependencies to the local 'node_modules' folder.
npm install
npx prettier -w **/*.json

# Compile TypeScript. Compilation will fail, this is expected. But it will compile 'scripts/prettier-swagger-plugin', which is what we need.
npx tsc

# Run 'prettier --list-different' to understand what is the problem.
npx prettier --list-different **/*.json

# Run 'prettier --write' to fix the problem.
npx prettier --write **/*.json
```

Then please commit and push changes made by prettier.

Reference: [prettier](https://www.npmjs.com/package/prettier).

## Model Validation

Run Model Validation locally:
Expand All @@ -35,6 +55,7 @@ Refer to [Semantic and Model Violations Reference](https://github.com/Azure/azur
Refer to [Swagger-Example-Generation](https://dev.azure.com/azure-sdk/internal/_wiki/wikis/internal.wiki/393/Swagger-Example-Generation) for example automatic generation.

## Semantic Validation

Run Semantic Validation locally:
```
npm install -g oav
Expand Down