-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
## Changes * Moving forward, we want to avoid having silent checks to make reasoning about auth easier. This PR makes it so that all AuthProviders must implement the `check` method. * Each check method must handle it's own Retry Loop, error handling and display. Since now checks are always interactive, we do not want calling code to manage the interactions. ## Tests * manual
- Loading branch information
1 parent
a2c3df0
commit 237e629
Showing
33 changed files
with
7,232 additions
and
84 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"plugins": ["eslint-plugin-local-rules"], | ||
"rules": { | ||
"local-rules/mutex-synchronised-decorator": "error" | ||
} | ||
} |
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,12 @@ | ||
/* eslint-disable */ | ||
require("ts-node").register({ | ||
transpileOnly: true, | ||
compilerOptions: { | ||
module: "commonjs", | ||
}, | ||
}); | ||
|
||
module.exports = { | ||
"mutex-synchronised-decorator": | ||
require("./rules/mutexSynchronisedDecorator").default, | ||
}; |
76 changes: 76 additions & 0 deletions
76
packages/databricks-vscode/eslint-local-rules/rules/mutexSynchronisedDecorator.ts
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,76 @@ | ||
/* eslint-disable no-console */ | ||
import {ESLintUtils, AST_NODE_TYPES} from "@typescript-eslint/utils"; | ||
|
||
const rule = ESLintUtils.RuleCreator.withoutDocs({ | ||
create(context) { | ||
return { | ||
// eslint-disable-next-line @typescript-eslint/naming-convention | ||
Decorator(node) { | ||
if ( | ||
node.expression.type === "CallExpression" && | ||
node.expression.callee.type === | ||
AST_NODE_TYPES.MemberExpression && | ||
node.expression.callee.object.type === | ||
AST_NODE_TYPES.Identifier && | ||
node.expression.callee.object.name === "Mutex" && | ||
node.expression.callee.property.type === | ||
AST_NODE_TYPES.Identifier && | ||
node.expression.callee.property.name === "synchronise" && | ||
node.expression.arguments.length > 0 | ||
) { | ||
const mutexName = | ||
node.expression.arguments[0].type === | ||
AST_NODE_TYPES.Literal | ||
? (node.expression.arguments[0].value as string) | ||
: ""; | ||
|
||
if (node.parent.parent?.type !== AST_NODE_TYPES.ClassBody) { | ||
return context.report({ | ||
node, | ||
messageId: "decoratorNotInClass", | ||
}); | ||
} | ||
|
||
const exists = node.parent.parent.body.some((element) => { | ||
return ( | ||
element.type === | ||
AST_NODE_TYPES.PropertyDefinition && | ||
element.key.type === AST_NODE_TYPES.Identifier && | ||
element.key.name === mutexName | ||
); | ||
}); | ||
|
||
const className = | ||
node.parent.parent.parent?.type === | ||
AST_NODE_TYPES.ClassDeclaration | ||
? node.parent.parent.parent.id?.name | ||
: undefined; | ||
|
||
if (!exists) { | ||
return context.report({ | ||
node, | ||
messageId: "synchronisedMutexNotInClass", | ||
data: { | ||
mutexName, | ||
className, | ||
}, | ||
}); | ||
} | ||
} | ||
}, | ||
}; | ||
}, | ||
meta: { | ||
type: "problem", | ||
schema: [], | ||
messages: { | ||
decoratorNotInClass: | ||
"Mutex.synchronized() should be used inside a class", | ||
synchronisedMutexNotInClass: | ||
'Mutex "{{mutexName}}" is not defined in class "{{className}}".', | ||
}, | ||
}, | ||
defaultOptions: [], | ||
}); | ||
|
||
export default rule; |
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,6 @@ | ||
{ | ||
"transpileOnly": true, | ||
"compilerOptions": { | ||
"module": "Node16" | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
/** | ||
* This script generates the BundleSchema.d.ts file from the bundle schema. | ||
* It MUST be run after a yarn package:cli:fetch | ||
*/ | ||
|
||
import * as cp from "child_process"; | ||
import * as fs from "fs"; | ||
import {compileFromFile} from "json-schema-to-typescript"; | ||
import {tmpdir} from "os"; | ||
import path from "path"; | ||
import {argv} from "process"; | ||
|
||
const output = cp.execFileSync(argv[2], ["bundle", "schema"]); | ||
|
||
const tmpFile = path.join(tmpdir(), "BundleSchema.json"); | ||
fs.writeFileSync(tmpFile, output); | ||
|
||
// eslint-disable-next-line no-console | ||
console.log("Bundle schema written to", tmpFile); | ||
|
||
// compile from file | ||
compileFromFile(tmpFile).then((ts) => fs.writeFileSync(argv[3], ts)); | ||
|
||
// eslint-disable-next-line no-console | ||
console.log("BundleSchema.d.ts written to", argv[3]); |
Oops, something went wrong.