Skip to content

Commit

Permalink
[eslint-plugin] upgrade eslint dependencies
Browse files Browse the repository at this point in the history
  - eslint to ^8.0.0
  - @types/eslint to ~8.4.0
  - @typescript-eslint plugins to ~5.22.0

* Fix broken test because of class property node type changes. Improve test a bit
to also verifying error line and column numbers

* Disable @typescript-eslint/no-invalid-this

After upgrading this rule reports more false positives. The following comment on the
github issue suggests that it doesn't work for some callbacks because it is just
a simple rule that doesn't do type analysis.

typescript-eslint/typescript-eslint#3620 (comment)

* Fix linter issues after upgrading the plugins in eslint-plugin-azure-sdk. Also upgrade eslint version in the impacted packages
  • Loading branch information
jeremymeng authored May 5, 2022
1 parent 23f10d4 commit 7e7868c
Show file tree
Hide file tree
Showing 19 changed files with 351 additions and 170 deletions.
333 changes: 248 additions & 85 deletions common/config/rush/pnpm-lock.yaml

Large diffs are not rendered by default.

20 changes: 10 additions & 10 deletions common/tools/eslint-plugin-azure-sdk/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,19 +59,19 @@
},
"prettier": "./prettier.json",
"peerDependencies": {
"@typescript-eslint/eslint-plugin": "~4.19.0",
"@typescript-eslint/parser": "~4.19.0",
"eslint": "^7.15.0",
"@typescript-eslint/eslint-plugin": "~5.22.0",
"@typescript-eslint/parser": "~5.22.0",
"eslint": "^8.0.0",
"eslint-plugin-import": "^2.22.1",
"eslint-plugin-no-only-tests": "^2.4.0",
"eslint-plugin-promise": "^6.0.0",
"eslint-plugin-tsdoc": "^0.2.10"
},
"dependencies": {
"@typescript-eslint/typescript-estree": "~4.19.0",
"@types/eslint": "~7.2.7",
"@typescript-eslint/typescript-estree": "~5.22.0",
"@types/eslint": "~8.4.0",
"@types/estree": "~0.0.46",
"eslint-config-prettier": "^7.0.0",
"eslint-config-prettier": "^8.0.0",
"glob": "^7.1.2",
"json-schema": "^0.4.0",
"typescript": "~4.2.0",
Expand All @@ -83,11 +83,11 @@
"@types/json-schema": "^7.0.6",
"@types/mocha": "^7.0.2",
"@types/node": "^12.0.0",
"@typescript-eslint/eslint-plugin": "~4.19.0",
"@typescript-eslint/experimental-utils": "~4.19.0",
"@typescript-eslint/parser": "~4.19.0",
"@typescript-eslint/eslint-plugin": "~5.22.0",
"@typescript-eslint/experimental-utils": "~5.22.0",
"@typescript-eslint/parser": "~5.22.0",
"chai": "^4.2.0",
"eslint": "^7.15.0",
"eslint": "^8.0.0",
"mocha": "^7.1.1",
"prettier": "^2.5.1",
"rimraf": "^3.0.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export default {
extends: [
"plugin:@typescript-eslint/recommended",
"plugin:@typescript-eslint/eslint-recommended",
"prettier/@typescript-eslint",
"prettier",
"plugin:@azure/azure-sdk/recommended",
],
rules: {
Expand All @@ -52,7 +52,7 @@ export default {
"no-invalid-this": "off",
"no-empty": "error",
"no-fallthrough": "error",
"@typescript-eslint/no-invalid-this": "error",
"@typescript-eslint/no-invalid-this": "off",
"@typescript-eslint/no-require-imports": "error",
"no-restricted-imports": ["error", { paths: ["rhea", "rhea/.*"] }],
"no-return-await": "error",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ export = {
const converter = parserServices.esTreeNodeToTSNodeMap;

return {
":matches(ClassProperty, MethodDefinition, TSMethodSignature, TSPropertySignature, TSIndexSignature, TSParameterProperty)":
":matches(ClassProperty, PropertyDefinition, MethodDefinition, TSMethodSignature, TSPropertySignature, TSIndexSignature, TSParameterProperty)":
(node: Node): void => reportInternal(node, context, converter),
};
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,66 +112,94 @@ ruleTester.run("ts-doc-internal-private-member", rule, {
invalid: [
{
code: `
/**
* Class documentation
*/
class ExampleClass {
/**
* Class Property
* @internal
*/
private x = 0;
/**
* Property Signature
* @internal
*/
private y: number;
/**
* Index signature
* @internal
*/
private [s: string]: boolean | ((s: string) => boolean);
/**
* Parameter Property
* @internal
*/
private testMethod(private x: number, private y: number) {}
/**
* Method Definition
* @internal
*/
private get getter(): number { return 0 }
/**
* Method Signature
* @internal
*/
private method1(): any;
}`,
/**
* Class documentation
*/
class ExampleClass {
/**
* Property Definition
* @internal
*/
private x = 0;
/**
* Property Signature
* @internal
*/
private y: number;
/**
* Method Definition
* @internal
*/
private testMethod() { }
/**
* Method Definition
* @internal
*/
private get getter(): number { return 0 }
/**
* Method Signature
* @internal
*/
private method1(): any;
/**
* constructor
* @internal
*/
constructor(
/**
* param x
* @internal
*/
private param_x: number,
/**
* param y
* @internal
*/
private param_y: number) { }
}
`,
filename: "src/test.ts",
errors: [
{
message: "private class members should not include an @internal tag",
line: 10,
column: 3,
},
{
message: "private class members should not include an @internal tag",
line: 16,
column: 3,
},
{
message: "private class members should not include an @internal tag",
line: 22,
column: 3,
},
{
message: "private class members should not include an @internal tag",
line: 28,
column: 3,
},
{
message: "private class members should not include an @internal tag",
line: 34,
column: 3,
},
{
message: "private class members should not include an @internal tag",
line: 46,
column: 5,
},
{
message: "private class members should not include an @internal tag",
line: 51,
column: 5,
},
],
},
Expand Down
12 changes: 1 addition & 11 deletions sdk/appconfiguration/app-configuration/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -102,20 +102,14 @@
"@azure-tools/test-recorder": "^1.0.0",
"@azure/test-utils": "^1.0.0",
"@microsoft/api-extractor": "7.18.11",
"@rollup/plugin-commonjs": "^21.0.1",
"@rollup/plugin-inject": "^4.0.0",
"@rollup/plugin-json": "^4.0.0",
"@rollup/plugin-multi-entry": "^3.0.0",
"@rollup/plugin-node-resolve": "^13.0.6",
"@rollup/plugin-replace": "^2.2.0",
"@types/chai": "^4.1.6",
"@types/mocha": "^7.0.2",
"@types/node": "^12.0.0",
"@types/sinon": "^9.0.4",
"@types/uuid": "^8.3.4",
"chai": "^4.2.0",
"dotenv": "^8.2.0",
"eslint": "^7.15.0",
"eslint": "^8.0.0",
"esm": "^3.2.18",
"karma": "^6.2.0",
"karma-chrome-launcher": "^3.0.0",
Expand All @@ -134,10 +128,6 @@
"nyc": "^15.0.0",
"prettier": "^2.5.1",
"rimraf": "^3.0.0",
"rollup": "^2.0.0",
"rollup-plugin-shim": "^1.0.0",
"rollup-plugin-sourcemaps": "^0.6.3",
"rollup-plugin-terser": "^5.1.1",
"sinon": "^9.0.2",
"ts-node": "^10.0.0",
"typescript": "~4.6.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export function isDefined<T>(thing: T | undefined | null): thing is T {
* @param properties - The name of the properties that should appear in the object.
* @internal
*/
export function isObjectWithProperties<Thing extends unknown, PropertyName extends string>(
export function isObjectWithProperties<Thing, PropertyName extends string>(
thing: Thing,
properties: PropertyName[]
): thing is Thing & Record<PropertyName, unknown> {
Expand All @@ -39,7 +39,7 @@ export function isObjectWithProperties<Thing extends unknown, PropertyName exten
* @param property - The name of the property that should appear in the object.
* @internal
*/
function objectHasProperty<Thing extends unknown, PropertyName extends string>(
function objectHasProperty<Thing, PropertyName extends string>(
thing: Thing,
property: PropertyName
): thing is Thing & Record<PropertyName, unknown> {
Expand Down
2 changes: 1 addition & 1 deletion sdk/core/core-amqp/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@
"cross-env": "^7.0.2",
"debug": "^4.1.1",
"downlevel-dts": "^0.8.0",
"eslint": "^7.15.0",
"eslint": "^8.0.0",
"karma": "^6.2.0",
"karma-chrome-launcher": "^3.0.0",
"karma-mocha": "^2.0.1",
Expand Down
4 changes: 2 additions & 2 deletions sdk/core/core-amqp/src/util/typeGuards.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export function isDefined<T>(thing: T | undefined | null): thing is T {
* @param properties - The name of the properties that should appear in the object.
* @internal
*/
export function isObjectWithProperties<Thing extends unknown, PropertyName extends string>(
export function isObjectWithProperties<Thing, PropertyName extends string>(
thing: Thing,
properties: PropertyName[]
): thing is Thing & Record<PropertyName, unknown> {
Expand All @@ -43,7 +43,7 @@ export function isObjectWithProperties<Thing extends unknown, PropertyName exten
* @param property - The name of the property that should appear in the object.
* @internal
*/
export function objectHasProperty<Thing extends unknown, PropertyName extends string>(
export function objectHasProperty<Thing, PropertyName extends string>(
thing: Thing,
property: PropertyName
): thing is Thing & Record<PropertyName, unknown> {
Expand Down
2 changes: 1 addition & 1 deletion sdk/core/core-auth/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@
"chai": "^4.2.0",
"cross-env": "^7.0.2",
"downlevel-dts": "^0.8.0",
"eslint": "^7.15.0",
"eslint": "^8.0.0",
"inherits": "^2.0.3",
"mocha": "^7.1.1",
"mocha-junit-reporter": "^2.0.0",
Expand Down
4 changes: 2 additions & 2 deletions sdk/core/core-auth/src/typeguards.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ function isDefined<T>(thing: T | undefined | null): thing is T {
* @param properties - The name of the properties that should appear in the object.
* @internal
*/
export function isObjectWithProperties<Thing extends unknown, PropertyName extends string>(
export function isObjectWithProperties<Thing, PropertyName extends string>(
thing: Thing,
properties: PropertyName[]
): thing is Thing & Record<PropertyName, unknown> {
Expand All @@ -41,7 +41,7 @@ export function isObjectWithProperties<Thing extends unknown, PropertyName exten
* @param property - The name of the property that should appear in the object.
* @internal
*/
function objectHasProperty<Thing extends unknown, PropertyName extends string>(
function objectHasProperty<Thing, PropertyName extends string>(
thing: Thing,
property: PropertyName
): thing is Thing & Record<PropertyName, unknown> {
Expand Down
2 changes: 1 addition & 1 deletion sdk/core/core-client-rest/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@
"@types/sinon": "^9.0.4",
"chai": "^4.2.0",
"cross-env": "^7.0.2",
"eslint": "^7.15.0",
"eslint": "^8.0.0",
"inherits": "^2.0.3",
"karma-chrome-launcher": "^3.0.0",
"karma-coverage": "^2.0.0",
Expand Down
4 changes: 2 additions & 2 deletions sdk/core/core-client-rest/src/typeGuards.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export function isDefined<T>(thing: T | undefined | null): thing is T {
* @param properties - The name of the properties that should appear in the object.
* @internal
*/
export function isObjectWithProperties<Thing extends unknown, PropertyName extends string>(
export function isObjectWithProperties<Thing, PropertyName extends string>(
thing: Thing,
properties: PropertyName[]
): thing is Thing & Record<PropertyName, unknown> {
Expand All @@ -39,7 +39,7 @@ export function isObjectWithProperties<Thing extends unknown, PropertyName exten
* @param property - The name of the property that should appear in the object.
* @internal
*/
function objectHasProperty<Thing extends unknown, PropertyName extends string>(
function objectHasProperty<Thing, PropertyName extends string>(
thing: Thing,
property: PropertyName
): thing is Thing & Record<PropertyName, unknown> {
Expand Down
2 changes: 1 addition & 1 deletion sdk/eventhub/event-hubs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@
"debug": "^4.1.1",
"dotenv": "^8.2.0",
"downlevel-dts": "^0.8.0",
"eslint": "^7.15.0",
"eslint": "^8.0.0",
"esm": "^3.2.18",
"https-proxy-agent": "^5.0.0",
"karma": "^6.2.0",
Expand Down
4 changes: 2 additions & 2 deletions sdk/eventhub/event-hubs/src/util/typeGuards.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export function isDefined<T>(thing: T | undefined | null): thing is T {
* @param properties - The name of the properties that should appear in the object.
* @internal
*/
export function isObjectWithProperties<Thing extends unknown, PropertyName extends string>(
export function isObjectWithProperties<Thing, PropertyName extends string>(
thing: Thing,
properties: PropertyName[]
): thing is Thing & Record<PropertyName, unknown> {
Expand All @@ -48,7 +48,7 @@ export function isObjectWithProperties<Thing extends unknown, PropertyName exten
* @param property - The name of the property that should appear in the object.
* @internal
*/
export function objectHasProperty<Thing extends unknown, PropertyName extends string>(
export function objectHasProperty<Thing, PropertyName extends string>(
thing: Thing,
property: PropertyName
): thing is Thing & Record<PropertyName, unknown> {
Expand Down
2 changes: 1 addition & 1 deletion sdk/monitor/monitor-query/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@
"cross-env": "^7.0.2",
"dotenv": "^8.2.0",
"downlevel-dts": "^0.8.0",
"eslint": "^7.15.0",
"eslint": "^8.0.0",
"esm": "^3.2.18",
"inherits": "^2.0.3",
"karma-chrome-launcher": "^3.0.0",
Expand Down
4 changes: 2 additions & 2 deletions sdk/monitor/monitor-query/src/timespanConversion.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ export function convertIntervalToTimeIntervalObject(timespan: string): QueryTime
* @param property - The name of the property that should appear in the object.
* @internal
*/
export function objectHasProperty<Thing extends unknown, PropertyName extends string>(
export function objectHasProperty<Thing, PropertyName extends string>(
thing: Thing,
property: PropertyName
): thing is Thing & Record<PropertyName, unknown> {
Expand All @@ -67,7 +67,7 @@ export function isDefined<T>(thing: T | undefined | null): thing is T {
* @param properties - The name of the properties that should appear in the object.
* @internal
*/
export function isObjectWithProperties<Thing extends unknown, PropertyName extends string>(
export function isObjectWithProperties<Thing, PropertyName extends string>(
thing: Thing,
properties: PropertyName[]
): thing is Thing & Record<PropertyName, unknown> {
Expand Down
2 changes: 1 addition & 1 deletion sdk/servicebus/service-bus/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@
"debug": "^4.1.1",
"dotenv": "^8.2.0",
"downlevel-dts": "^0.8.0",
"eslint": "^7.15.0",
"eslint": "^8.0.0",
"esm": "^3.2.18",
"glob": "^7.1.2",
"https-proxy-agent": "^5.0.0",
Expand Down
Loading

0 comments on commit 7e7868c

Please sign in to comment.