Skip to content

Commit

Permalink
fixing linting
Browse files Browse the repository at this point in the history
  • Loading branch information
DaanV2 committed Nov 9, 2024
1 parent 4f56b37 commit 60af6c4
Show file tree
Hide file tree
Showing 11 changed files with 29 additions and 123 deletions.
50 changes: 0 additions & 50 deletions .github/workflows/format-json-files.yml

This file was deleted.

2 changes: 1 addition & 1 deletion src/main.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import path = require("path");
import * as path from "path";

export namespace DummyFiles {
export function TestFolder(): string {
Expand Down
31 changes: 0 additions & 31 deletions test/files/correct/data_bp/features/scatter_feature.json

This file was deleted.

24 changes: 15 additions & 9 deletions test/files/correct/data_bp/trading/master_block.trades.json
Original file line number Diff line number Diff line change
@@ -1,18 +1,24 @@
{
"tiers": [
{
"trades": [
"total_exp_required": 5,
"groups": [
{
"wants": [
"num_to_select": 2,
"trades": [
{
"item": "minecraft:wheat",
"quantity": {
"min": 18,
"max": 22
}
"wants": [
{
"item": "minecraft:wheat",
"quantity": {
"min": 18,
"max": 22
}
}
],
"gives": [{ "item": "minecraft:emerald" }]
}
],
"gives": [{ "item": "minecraft:emerald" }]
]
}
]
}
Expand Down
2 changes: 1 addition & 1 deletion test/files/incorrect/data2_bp/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

"header": {
"name": "Hell Cave Carver Features",
"uuid": "459909b9-fdb8-4eb3-9b8d-55d09545b89d",
"uuid": "459909b9-fdb8-4eb3-9b8d-55d09545b89h",
"description": "Tests hell cave carver features",
"version": [0, 0, 1],
"min_engine_version": [1, 17, 0]
Expand Down
1 change: 0 additions & 1 deletion test/src/files/correct.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { Github } from "../github";
import { Schema } from "../schema-tester";
import { Files } from "../utillity";

Expand Down
1 change: 0 additions & 1 deletion test/src/files/incorrect.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { Github } from "../github";
import { Schema } from "../schema-tester";
import { Files } from "../utillity";

Expand Down
2 changes: 1 addition & 1 deletion test/src/github.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export interface ErrorAnnotation {
export namespace Github {
export function createError(message: string, error: ErrorAnnotation = {}): void {
const data = Object.entries(error)
.filter(([key, value]) => value !== undefined)
.filter(([, value]) => value !== undefined)
.map(([key, value]) => `${key}=${value}`)
.join(",");

Expand Down
22 changes: 4 additions & 18 deletions test/src/schema-tester.ts
Original file line number Diff line number Diff line change
@@ -1,19 +1,9 @@
import { existsSync, readFileSync } from "fs";
import * as path from "path";
import * as url from "url";
import {
Diagnostic,
getLanguageService,
JSONDocument,
LanguageService,
LanguageSettings,
SchemaConfiguration,
SchemaRequestService,
TextDocument,
Thenable,
} from "vscode-json-languageservice";
import { Diagnostic, getLanguageService, JSONDocument, LanguageService, LanguageSettings, SchemaConfiguration, TextDocument, Thenable } from "vscode-json-languageservice";
import * as data from "../../vscode-settings.json";
import { Files } from "./utillity";
import path = require("path");

export namespace Schema {
const workspaceContext = {
Expand All @@ -40,7 +30,7 @@ export namespace Schema {

export async function getSchema(uri: string): Promise<string> {
const rootfolder = Files.RootFolder();
const filepath = path.normalize(uri.replace("https://raw.githubusercontent.com/Blockception/Minecraft-bedrock-json-schemas/main/", rootfolder));
const filepath = uri.replace("https://raw.githubusercontent.com/Blockception/Minecraft-bedrock-json-schemas/main", rootfolder);

if (!existsSync(filepath)) {
throw new Error("file doesn't exist: " + filepath);
Expand All @@ -55,22 +45,18 @@ export namespace Schema {
schemas: schemas,
};
let rootfolder = Files.RootFolder();
console.log("grabbing files from", rootfolder);

if (!rootfolder.endsWith("/")) rootfolder += "/";
rootfolder = path.normalize(rootfolder);

data["json.schemas"].forEach((m) => {
if (m) {
const schema = path.normalize(m.url.replace("https://raw.githubusercontent.com/Blockception/Minecraft-bedrock-json-schemas/main/", rootfolder));

let matches = m.fileMatch;
if (typeof matches === "string") {
matches = [matches];
}
const u = schema.replace(/\\/g, "/");

schemas.push({ uri: u, fileMatch: matches });
schemas.push({ uri: m.url, fileMatch: matches });
}
});

Expand Down
4 changes: 2 additions & 2 deletions test/src/utillity.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import FastGlob = require("fast-glob");
import path = require("path");
import * as FastGlob from "fast-glob";
import * as path from "path";

export namespace Files {
export function TestFolder(): string {
Expand Down
13 changes: 5 additions & 8 deletions test/src/validator.test.ts
Original file line number Diff line number Diff line change
@@ -1,20 +1,17 @@
import path = require("path");
import { Files } from "./utillity";
import * as fs from "fs";
import * as JSONC from "comment-json";
import * as fs from "fs";
import * as path from "path";
import { ErrorAnnotation, Github } from "./github";
import { Files } from "./utillity";

describe("Validate", function () {
const folder = path.join(Files.TestFolder(), "..", "source");
const files = Files.GetFiles(folder);
expect(files.length).toBeGreaterThan(0);

test.each(files)("Validating schema parts: %s", (filepath) => {
let object: JsonSchema | undefined = undefined;
let data: string;

data = fs.readFileSync(filepath, "utf8");
object = JSONC.parse(data) as JsonSchema;
const data = fs.readFileSync(filepath, "utf8");
const object = JSONC.parse(data) as JsonSchema;
expect(object).toBeDefined();
if (!object) {
return;
Expand Down

0 comments on commit 60af6c4

Please sign in to comment.