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

10597 fix package.json linting errors #13070

Merged
merged 38 commits into from
Jan 7, 2021
Merged
Show file tree
Hide file tree
Changes from 37 commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
bd3df53
Fix linting rule for ts-package-json-homepage
maorleger Jan 5, 2021
deead72
app-configuration package.json lint
maorleger Jan 5, 2021
972104a
ai-anomaly-detector lint
maorleger Jan 5, 2021
ba94b58
ai-form-recognizer fix
maorleger Jan 5, 2021
138ca62
search-documents fix
maorleger Jan 5, 2021
d72bf0d
communication-admin fix
maorleger Jan 5, 2021
5fab680
communication-chat fix
maorleger Jan 5, 2021
8d4e840
communication-common fix
maorleger Jan 5, 2021
161cb33
communication-sms fix
maorleger Jan 5, 2021
42959a1
core-client fix
maorleger Jan 5, 2021
02e55c0
core-https fix
maorleger Jan 5, 2021
ee02770
core-xml fix
maorleger Jan 5, 2021
8960d23
Partially fix cosmosdb
maorleger Jan 5, 2021
ffcc2f9
opentelemetry fix
maorleger Jan 5, 2021
5f2d147
eventhubs
maorleger Jan 5, 2021
76d46e0
eventhub-checkpoint-blob
maorleger Jan 5, 2021
4d3b9e1
event-processor-host
maorleger Jan 5, 2021
14de05b
schema-registry-avro
maorleger Jan 5, 2021
97b6d92
service-bus
maorleger Jan 5, 2021
6e432e4
fix up opentelemetry rollups
maorleger Jan 5, 2021
1803697
storage-internal-avro
maorleger Jan 5, 2021
ea33dfd
storage-blob
maorleger Jan 5, 2021
b79dafe
storage-blob-changefeed
maorleger Jan 5, 2021
9e33ca8
storage-file-share
maorleger Jan 5, 2021
81bf0bf
storage-file-datalake
maorleger Jan 5, 2021
b912d5b
storage-queue
maorleger Jan 5, 2021
f500569
data-tables
maorleger Jan 5, 2021
6a2db02
template
maorleger Jan 5, 2021
2a13174
test recorder
maorleger Jan 5, 2021
b55e871
perfstress
maorleger Jan 5, 2021
6f09ffc
digital twins core
maorleger Jan 5, 2021
e3f8ae7
Address feedback
maorleger Jan 5, 2021
06a1cb2
fix schema-registry link
maorleger Jan 5, 2021
5c61e09
Revert "Fix linting rule for ts-package-json-homepage"
maorleger Jan 6, 2021
97f6b78
Revert homepage rule
maorleger Jan 6, 2021
c23bbe5
standardize homepage paths
maorleger Jan 6, 2021
28984d1
Allow overriding node version in package.json
maorleger Jan 6, 2021
0823b12
ship src in communication-chat and set linter to warn
maorleger Jan 7, 2021
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
11 changes: 9 additions & 2 deletions common/config/rush/pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion common/tools/dev-tool/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
"bugs": {
"url": "https://github.com/azure/azure-sdk-for-js/issues"
},
"homepage": "https://github.com/azure/azure-sdk-for-js/tree/master/common/tools/dev-tool",
"homepage": "https://github.com/azure/azure-sdk-for-js/tree/master/common/tools/dev-tool/",
"sideEffects": false,
"private": true,
"prettier": "@azure/eslint-plugin-azure-sdk/prettier.json",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

Requires support for all Node LTS version.

Currently, this requires `engine` in `package.json` to be set to `">=8.0.0"`.
Currently, this requires `engines` in `package.json` to contain an entry for `node` set to `">=8.0.0"` unless a `nodeVersionOverride` value is present.

This rule is fixable using the `--fix` option.

Expand All @@ -12,23 +12,33 @@ This rule is fixable using the `--fix` option.

```json
{
"engine": ">=8.0.0"
"engines": {
"node": ">=8.0.0"
}
}
```

### Bad

````json
```json
{
"engine": ">=6.0.0"
"engine": {
"node": ">=8.0.0"
}
}
```'
```

```json
{
"engine": ">=10.0.0"
"engine": ">=6.0.0"
}
````
```

```json
{
"engine": ">=10.0.0"
}
```

```json
{}
Expand All @@ -38,6 +48,24 @@ This rule is fixable using the `--fix` option.

Only if the rule breaks.

## Options

This rule as an object option:

- `"nodeVersionOverride"`: allow providing a custom supported node version if an external dependency enforces it

### nodeVersionOverride

Example of **correct** code for this rule with the `{ "nodeVersionOverride": ">=10.0.0" }` option:

```json
{
"engines": {
"node": ">=10.0.0"
}
}
```

## [Source](https://azure.github.io/azure-sdk/typescript_implementation.html#ts-package-json-engine-is-present)

Also encompasses [ts-node-support](https://azure.github.io/azure-sdk/typescript_design.html#ts-node-support), as the rules are similar enough to not exist separately for linting purposes.
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ Requires `homepage` in `package.json` to be set to the library's readme.

```json
{
"homepage": "https://github.com/Azure/azure-sdk-for-js/blob/master/sdk/servicebus/service-bus"
"homepage": "https://github.com/Azure/azure-sdk-for-js/blob/master/sdk/servicebus/service-bus/"
}
```

Expand Down
4 changes: 3 additions & 1 deletion common/tools/eslint-plugin-azure-sdk/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
}
],
"license": "MIT",
"homepage": "https://github.com/Azure/azure-sdk-for-js/tree/master/common/tools/eslint-plugin-azure-sdk",
"homepage": "https://github.com/Azure/azure-sdk-for-js/tree/master/common/tools/eslint-plugin-azure-sdk/",
"repository": {
"type": "git",
"url": "https://github.com/Azure/azure-sdk-for-js.git",
Expand Down Expand Up @@ -72,12 +72,14 @@
"@types/estree": "^0.0.45",
"eslint-config-prettier": "^7.0.0",
"glob": "^7.1.2",
"json-schema": "^0.3.0",
"typescript": "4.1.2",
"tslib": "^2.0.0"
},
"devDependencies": {
"@types/chai": "^4.1.6",
"@types/glob": "^7.1.1",
"@types/json-schema": "^7.0.6",
"@types/mocha": "^7.0.2",
"@types/node": "^8.0.0",
"@typescript-eslint/eslint-plugin": "^4.9.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,12 @@
import { Rule } from "eslint";
import { getRuleMetaData, getVerifiers, stripPath } from "../utils";

/**
* definition of LTS Node versions
* * needs updating as definitions change
*/
const LTS = ">=8.0.0";

//------------------------------------------------------------------------------
// Rule Definition
//------------------------------------------------------------------------------
Expand All @@ -17,19 +23,27 @@ export = {
meta: getRuleMetaData(
"ts-package-json-engine-is-present",
"force Node support for all LTS versions",
"code"
"code",
[
{
type: "object",
properties: {
nodeVersionOverride: {
type: "string",
default: LTS,
description: "Allows specifying a different node version than the current default"
}
}
}
]
),
create: (context: Rule.RuleContext): Rule.RuleListener => {
/**
* definition of LTS Node versions
* * needs updating as definitions change
*/
const LTS = ">=8.0.0";
const options = context.options[0] || {};

const verifiers = getVerifiers(context, {
outer: "engines",
inner: "node",
expected: LTS
expected: options.nodeVersionOverride || LTS
});
return stripPath(context.getFilename()) === "package.json"
? ({
Expand Down
6 changes: 4 additions & 2 deletions common/tools/eslint-plugin-azure-sdk/src/utils/metadata.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,13 @@
*/

import { Rule } from "eslint";
import { JSONSchema4 } from "json-schema";

export const getRuleMetaData = (
ruleName: string,
ruleDescription: string,
fix?: "code" | "whitespace"
fix?: "code" | "whitespace",
schema?: JSONSchema4 | JSONSchema4[]
): Rule.RuleMetaData => {
const required = {
type: "suggestion",
Expand All @@ -21,7 +23,7 @@ export const getRuleMetaData = (
recommended: true,
url: `https://github.com/Azure/azure-sdk-for-js/tree/master/common/tools/eslint-plugin-azure-sdk/docs/rules/${ruleName}.md`
},
schema: []
schema: schema || []
};
return (fix !== undefined ? { ...required, fixable: fix } : required) as Rule.RuleMetaData;
};
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,16 @@ ruleTester.run("ts-package-json-engine-is-present", rule, {
// incorrect format but in a file we don't care about
code: '{"engines": { "node": ">=6.0.0" }}',
filename: "not_package.json"
},
{
// different than the default but with an override
code: '{"engines": { "node": ">=8.5.0" }}',
filename: "package.json",
options: [
{
nodeVersionOverride: ">=8.5.0"
}
]
}
],
invalid: [
Expand Down Expand Up @@ -322,6 +332,22 @@ ruleTester.run("ts-package-json-engine-is-present", rule, {
}
],
output: examplePackageGood
},
{
// override was provided but the version does not match
code: '{"engines": { "node": ">=8.0.0" }}',
filename: "package.json",
errors: [
{
message: "engines.node is set to >=8.0.0 when it should be set to >=6.5.0"
}
],
options: [
{
nodeVersionOverride: ">=6.5.0"
}
],
output: '{"engines": { "node": ">=6.5.0" }}'
}
]
});
13 changes: 7 additions & 6 deletions sdk/appconfiguration/app-configuration/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,15 @@
"azure",
"typescript",
"browser",
"isomorphic"
"isomorphic",
"cloud"
],
"license": "MIT",
"main": "./dist/index.js",
"module": "./dist-esm/src/index.js",
"types": "./types/app-configuration.d.ts",
"homepage": "https://github.com/Azure/azure-sdk-for-js/tree/master/sdk/appconfiguration/app-configuration",
"repository": {
"type": "git",
"url": "https://github.com/Azure/azure-sdk-for-js.git"
},
"homepage": "https://github.com/Azure/azure-sdk-for-js/tree/master/sdk/appconfiguration/app-configuration/",
"repository": "github:Azure/azure-sdk-for-js",
"bugs": {
"url": "https://github.com/Azure/azure-sdk-for-js/issues"
},
Expand Down Expand Up @@ -70,6 +68,9 @@
"unit-test": "npm run unit-test:node && npm run unit-test:browser",
"docs": "typedoc --excludePrivate --excludeNotExported --excludeExternals --mode file --out ./dist/docs ./src"
},
"engines": {
"node": ">=8.0.0"
},
"sideEffects": false,
"autoPublish": false,
"//metadata": {
Expand Down
6 changes: 5 additions & 1 deletion sdk/communication/communication-administration/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
"LICENSE"
],
"keywords": [
"Azure",
"azure",
"cloud",
"communication"
],
Expand All @@ -60,6 +60,10 @@
"node": ">=8.0.0"
},
"homepage": "https://github.com/Azure/azure-sdk-for-js/tree/master/sdk/communication/communication-administration/",
"repository": "github:Azure/azure-sdk-for-js",
"bugs": {
"url": "https://github.com/Azure/azure-sdk-for-js/issues"
},
"sideEffects": false,
"prettier": "@azure/eslint-plugin-azure-sdk/prettier.json",
"dependencies": {
Expand Down
3 changes: 1 addition & 2 deletions sdk/communication/communication-chat/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,7 @@
"dist-esm/src/",
"types/",
"README.md",
"LICENSE",
"src"
"LICENSE"
maorleger marked this conversation as resolved.
Show resolved Hide resolved
],
"browser": {
"./dist-esm/src/signaling/signalingClient.js": "./dist-esm/src/signaling/signalingClient.browser.js"
Expand Down
3 changes: 1 addition & 2 deletions sdk/core/core-xml/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,7 @@
"repository": "github:Azure/azure-sdk-for-js",
"keywords": [
"azure",
"cloud",
"Azure"
"cloud"
],
"author": "Microsoft Corporation",
"license": "MIT",
Expand Down
2 changes: 2 additions & 0 deletions sdk/cosmosdb/cosmos/.eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
"@typescript-eslint/no-extraneous-class": "error",
"dot-notation": "off",
"some-rule": "off",
"@azure/azure-sdk/ts-package-json-module": "warn",
"@azure/azure-sdk/ts-package-json-types": "warn",
"@typescript-eslint/tslint/config": [
maorleger marked this conversation as resolved.
Show resolved Hide resolved
"error",
{
Expand Down
7 changes: 5 additions & 2 deletions sdk/cosmosdb/cosmos/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
"README.md",
"LICENSE"
],
"homepage": "https://github.com/Azure/azure-sdk-for-js/tree/master/sdk/cosmosdb/cosmos#readme",
"homepage": "https://github.com/Azure/azure-sdk-for-js/tree/master/sdk/cosmosdb/cosmos/",
"sideEffects": false,
"types": "./dist/types/latest/index.d.ts",
"typesVersions": {
Expand All @@ -42,7 +42,7 @@
]
}
},
"engine": {
"engines": {
"node": ">=8.0.0"
},
"scripts": {
Expand Down Expand Up @@ -79,6 +79,9 @@
},
"repository": "github:Azure/azure-sdk-for-js",
"license": "MIT",
"bugs": {
"url": "https://github.com/Azure/azure-sdk-for-js/issues"
},
"tsdoc": {
"tsdocFlavor": "AEDoc"
},
Expand Down
2 changes: 1 addition & 1 deletion sdk/digitaltwins/digital-twins-core/api-extractor.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"dtsRollup": {
"enabled": true,
"untrimmedFilePath": "",
"publicTrimmedFilePath": "./types/digitalTwinsClient.d.ts"
"publicTrimmedFilePath": "./types/digital-twins-core.d.ts"
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Calling out this change - wasn't sure the impact so I'd like to have someone 👍 or 👎 this

},
"messages": {
"tsdocMessageReporting": {
Expand Down
Loading