-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Linter] Update linter rule to check if sdk-type exists in package.js…
…on (#18597) This fixes #13214. This PR is an update from a past PR, #18565. What's new? - I updated ```ts-package-json-sdktype.ts``` to enforce the existence of```sdk-type``` and that it is either ```client``` or ```mgmt```. If it does not, then the linter will throw an error. - I added/updated appropriate tests and verified the entire repository using ```rush lint``` - I also put the rules in the correct files (```src/configs/index.ts, src/rules/index.ts```, and ```tests/plugin.ts```) - I have written a docs file to put in ```docs/rules``` which are now included in the commit! - I do need to still update the actual ```README.md``` file, but I'm not sure what the actual version is (hopefully this isn't too much trouble)
- Loading branch information
Showing
8 changed files
with
569 additions
and
38 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
67 changes: 67 additions & 0 deletions
67
common/tools/eslint-plugin-azure-sdk/docs/rules/ts-package-json-sdktype.md
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 |
---|---|---|
@@ -0,0 +1,67 @@ | ||
# ts-package-json-sdktype | ||
|
||
Requires the existence of the `sdk-type` field and be either 'client', 'mgmt', or 'utility'. | ||
|
||
## Examples | ||
|
||
### Good | ||
|
||
```json | ||
{ | ||
"sdk-type": "client" | ||
} | ||
``` | ||
|
||
```json | ||
{ | ||
"sdk-type": "mgmt" | ||
} | ||
``` | ||
|
||
```json | ||
{ | ||
"sdk-type": "utility" | ||
} | ||
``` | ||
|
||
### Bad | ||
|
||
```json | ||
{ | ||
"sdk-type": "invalid" | ||
} | ||
``` | ||
|
||
```json | ||
{ | ||
"sdk-type": 1 | ||
} | ||
``` | ||
|
||
```json | ||
{ | ||
"sdk-type": true | ||
} | ||
``` | ||
|
||
```json | ||
{ | ||
"not-sdk-type": "client" | ||
} | ||
``` | ||
|
||
```json | ||
{ | ||
"outer": { | ||
"sdk-type": "client" | ||
} | ||
} | ||
``` | ||
|
||
```json | ||
{} | ||
``` | ||
|
||
## When to turn off | ||
|
||
Only if the rule breaks. |
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
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
Oops, something went wrong.