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

Add prettier check #443

Open
wants to merge 8 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
3 changes: 3 additions & 0 deletions .azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ jobs:

- script: 'node common/scripts/install-run-rush.js regen-ruleindex'
displayName: 'rush regen rule index'

- script: 'node common/scripts/install-run-rush.js prettier-check'
displayName: 'prettier'

- script: node common/scripts/install-run-rush.js change -v
condition: and(succeeded(), not(or(startsWith(variables['System.PullRequest.SourceBranch'], 'publish/'), startsWith(variables['System.PullRequest.SourceBranch'], 'backmerge/'))))
Expand Down
2 changes: 1 addition & 1 deletion .prettierrc
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"semi": false,
"printWidth": 140
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"changes": [
{
"packageName": "@microsoft.azure/openapi-validator-rulesets",
"comment": "bugfix for 4 rules",
"type": "patch"
}
],
"packageName": "@microsoft.azure/openapi-validator-rulesets"
}
14 changes: 13 additions & 1 deletion common/config/rush/command-line.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,18 @@
"name": "lint",
"summary": "Lint projects. Runs `npm run lint` on all projects.",
"enableParallelism": true
},
{
"commandKind": "bulk",
"name": "prettier",
"summary": "Using prettier to format code.",
"enableParallelism": true
},
{
"commandKind": "bulk",
"name": "prettier-check",
"summary": "Using prettier to check code style.",
"enableParallelism": true
}
]
}
}
29 changes: 29 additions & 0 deletions docs/missing-default-response.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# MissingDefaultResponse

## Category

Management Plane Error

## Applies to

Management Plane OpenAPI specs

## Output Message

Operation is missing a default response.

## Description

All operations should have a default (error) response.

## CreatedAt

January 30, 2023

## LastModifiedAt

January 30, 2023

## How to fix the violation

Add a default response for the operation.
14 changes: 8 additions & 6 deletions docs/rules.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ Please refer to [api-version-enum.md](./api-version-enum.md) for details.

### ApiVersionParameterRequired

This rule applies when the 'api-version' parameter is missing in any operations.
Operation is missing the 'api-version' parameter.

Please refer to [api-version-parameter-required.md](./api-version-parameter-required.md) for details.

Expand All @@ -59,10 +59,6 @@ Please refer to [api-version-parameter-required.md](./api-version-parameter-requ
The API Version parameter MUST be in the Year-Month-Date format (i.e. 2016-07-04.) NOTE that this is the en-US ordering of month and date.
The date MAY optionally be followed by one of:
* -preview - Indicates the API version is in (public) preview
* -alpha
* -beta
* -rc (release candidate)
* -privatepreview

Please refer to [api-version-pattern.md](./api-version-pattern.md) for details.

Expand Down Expand Up @@ -484,6 +480,12 @@ The long running operation with final-state-via:original-uri should have a sibli

Please refer to [lro-with-original-url-as-final-state.md](./lro-with-original-url-as-final-state.md) for details.

### MissingDefaultResponse

All operations should have a default (error) response.

Please refer to [missing-default-response.md](./missing-default-response.md) for details.

### MissingTypeObject

The rule should apply to any schema with "properties" or "additionalProperties". It is to ensure a schema with "properties" or "additionalProperties" must have explicit "type:object" statement, which means a schema is an object.
Expand Down Expand Up @@ -763,7 +765,7 @@ Please refer to [path-parameter-schema.md](./path-parameter-schema.md) for detai

### PathResourceProviderMatchNamespace

Verifies whether the last resource provider matches namespace or not. E.g the path /providers/Microsoft.Compute/virtualMachines/{vmName}/providers/Microsoft.Insights/extResource/{extType}' is allowed only if Microsoft.Insights matches the namespace (Microsoft.Insights).
Verifies whether the resource provider namespace in the last segment of the path matches the namespace to which the specification file belongs. E.g the path /providers/Microsoft.Compute/virtualMachines/{vmName}/providers/Microsoft.Insights/extResource/{extType}' is allowed only if the segment /Microsoft.Insights matches the namespace name to which the specification file belongs (Microsoft.Insights).

Please refer to [path-resource-provider-match-namespace.md](./path-resource-provider-match-namespace.md) for details.

Expand Down
2 changes: 1 addition & 1 deletion packages/azure-openapi-validator/autorest/.eslintrc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ parser: "@typescript-eslint/parser"
extends:
- "../../../.eslintrc.yaml"
rules:
no-console: off
no-console: off
2 changes: 1 addition & 1 deletion packages/azure-openapi-validator/autorest/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
This log was last generated on Thu, 24 Nov 2022 04:00:42 GMT and should not be manually modified.

## 2.0.0

Thu, 24 Nov 2022 04:00:42 GMT

_Initial release_

4 changes: 3 additions & 1 deletion packages/azure-openapi-validator/autorest/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@
"build": "tsc",
"test": "tsc",
"lint:fix": "eslint ./src --fix --ext .ts",
"lint": "eslint ./src --ext .ts --max-warnings=0"
"lint": "eslint ./src --ext .ts --max-warnings=0",
"prettier": "prettier -w .",
"prettier-check": "prettier -c ."
},
"repository": {
"type": "git",
Expand Down
10 changes: 5 additions & 5 deletions packages/azure-openapi-validator/autorest/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,21 @@ Azure OpenAPI validator (Typescript)

## Validation

``` yaml $(azure-validator) && $(v3)
```yaml $(azure-validator) && $(v3)
pipeline:
swagger-document/openapi-validator:
input: swagger-document/loader-swagger
scope: azure-validator-individual
scope: azure-validator-individual
```

``` yaml $(spectral) && $(v3)
```yaml $(spectral) && $(v3)
pipeline:
swagger-document/spectral:
input: swagger-document/loader-swagger
scope: azure-validator-individual
scope: azure-validator-individual
```

``` yaml $(azure-validator) || $(spectral) || $(v3)
```yaml $(azure-validator) || $(spectral) || $(v3)
azure-validator-composed:
merge-state: composed
azure-validator-individual:
Expand Down
Loading