Skip to content

Commit

Permalink
fix: language definition for PrismJS (#138)
Browse files Browse the repository at this point in the history
* fix: language definition for PrismJS

* chore(deps): upgrade dependencies

* fix: fix validation message & formatting
  • Loading branch information
rhamzeh authored Jul 19, 2023
1 parent 4ab32d7 commit 7ee1341
Show file tree
Hide file tree
Showing 9 changed files with 944 additions and 1,015 deletions.
1 change: 1 addition & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ module.exports = {
"unix"
],
"@typescript-eslint/ban-ts-comment": "off",
"@typescript-eslint/no-explicit-any": "warn",
"quotes": [
"error",
"double"
Expand Down
1,919 changes: 922 additions & 997 deletions package-lock.json

Large diffs are not rendered by default.

22 changes: 11 additions & 11 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,27 +32,27 @@
],
"author": "OpenFGA",
"dependencies": {
"@openfga/sdk": "^0.2.5",
"@openfga/sdk": "^0.2.6",
"assert-never": "^1.2.1",
"nearley": "^2.20.1",
"yargs": "^17.7.2"
},
"devDependencies": {
"@types/jest": "^29.5.1",
"@types/lodash": "^4.14.194",
"@types/jest": "^29.5.3",
"@types/lodash": "^4.14.195",
"@types/nearley": "^2.11.2",
"@types/node": "^18.15.13",
"@types/node": "^20.4.2",
"@types/prismjs": "^1.26.0",
"@typescript-eslint/eslint-plugin": "^5.59.0",
"@typescript-eslint/parser": "^5.59.0",
"eslint": "^8.38.0",
"@typescript-eslint/eslint-plugin": "^6.1.0",
"@typescript-eslint/parser": "^6.1.0",
"eslint": "^8.45.0",
"eslint-config-prettier": "^8.8.0",
"eslint-plugin-import": "^2.27.5",
"jest": "^29.5.0",
"jest": "^29.6.1",
"monaco-editor": "0.37.1",
"prettier": "^2.8.7",
"ts-jest": "^29.1.0",
"typescript": "^5.0.4"
"prettier": "^3.0.0",
"ts-jest": "^29.1.1",
"typescript": "^5.1.6"
},
"files": [
"README.md",
Expand Down
3 changes: 1 addition & 2 deletions src/syntax-highlighters/monaco/providers/code-actions.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type * as MonacoEditor from "monaco-editor";
import type { CancellationToken, editor, languages } from "monaco-editor";
import type { editor, languages } from "monaco-editor";

import { Keyword } from "../../../constants/keyword";
import { Marker } from "../../../validator/reporters";
Expand Down Expand Up @@ -113,7 +113,6 @@ export const provideCodeActions =
model: editor.ITextModel,
range: MonacoEditor.Range,
context: languages.CodeActionContext & { markers: Marker[] },
token: CancellationToken,
): languages.ProviderResult<languages.CodeActionList> => {
const codeActions: languages.CodeAction[] = [];

Expand Down
4 changes: 3 additions & 1 deletion src/syntax-highlighters/prism/language-definition.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,12 @@ export const languageDefinition = {
[OpenFgaDslThemeTokenType.TYPE]: {
pattern: /(\btype\s+)\w+/i,
lookbehind: true,
greedy: true,
},
[OpenFgaDslThemeTokenType.RELATION]: {
pattern: /(\bdefine\s+)\w+/i,
lookbehind: true,
greedy: true,
},
[OpenFgaDslThemeTokenType.DIRECTLY_ASSIGNABLE]: /\[.*\]/,
[OpenFgaDslThemeTokenType.DIRECTLY_ASSIGNABLE]: /\[.*]|self/,
};
1 change: 0 additions & 1 deletion src/transformer/api-to-friendly.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { TypeDefinition, WriteAuthorizationModelRequest, Userset, Metadata } from "@openfga/sdk";
import { Keyword } from "../constants/keyword";
import { DEFAULT_SCHEMA_VERSION } from "../constants";

const readFrom = (obj: Userset, define: string[], schemaVersion: string | undefined, allowedType: string) => {
const childKeys = Object.keys(obj);
Expand Down
5 changes: 4 additions & 1 deletion src/utilities/graphs/model-graph.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@ import { GraphDefinition, GraphEdgeGroup, GraphNodeGroup } from "./graph.typings
export class AuthorizationModelGraphBuilder {
private _graph: GraphDefinition = { nodes: [], edges: [] };

constructor(private authorizationModel: AuthorizationModel, private store?: { name?: string }) {
constructor(
private authorizationModel: AuthorizationModel,
private store?: { name?: string },
) {
this.buildGraph();
}

Expand Down
2 changes: 1 addition & 1 deletion src/validator/validation-error.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export enum ValidationError {
InvalidName = "invalid-name",
MissingDefinition = "missing-definition",
InvalidRelationType = "invalid-relation-type",
InvalidType = "invalid-relation-type",
InvalidType = "invalid-type",
RelationNoEntrypoint = "relation-no-entry-point",
TuplesetNotDirect = "tupleuset-not-direct",
DuplicatedError = "duplicated-error",
Expand Down
2 changes: 1 addition & 1 deletion tests/data/model-validation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,7 @@ type group
endLineNumber: 6,
message: "`unknown` is not a valid type.",
extraInformation: {
error: "invalid-relation-type",
error: "invalid-type",
typeName: "unknown",
},
severity: 8,
Expand Down

0 comments on commit 7ee1341

Please sign in to comment.