Skip to content

Commit

Permalink
Fixed all eslint issues with the web-new package, Modified the eslint…
Browse files Browse the repository at this point in the history
…rc.json file to a slightly newer version and to accept "module" scripts
  • Loading branch information
SergioCasCeb committed Mar 26, 2024
1 parent 65a7ea4 commit 9dfe5b2
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 28 deletions.
3 changes: 2 additions & 1 deletion .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
"jest": true
},
"parserOptions": {
"ecmaVersion": 8
"ecmaVersion": 2018,
"sourceType": "module"
},
"extends": ["eslint:recommended", "prettier"],
"ignorePatterns": ["dist", "node_modules", "bin"]
Expand Down
27 changes: 14 additions & 13 deletions packages/web-new/src/scripts/console.js
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ visualizationOptions.forEach(option => {
showConsoleError("This function is only allowed for Thing Descriptions!")
} else {
switch (option.id) {
case "open-api-tab":
case "open-api-tab": {

if (fileType === "yaml") {
openApiJsonBtn.disabled = false
Expand All @@ -159,8 +159,8 @@ visualizationOptions.forEach(option => {
enableAPIConversionWithProtocol(editorInstance)

break;

case "async-api-tab":
}
case "async-api-tab": {
if (fileType === "yaml") {
asyncApiJsonBtn.disabled = false
asyncApiYamlBtn.disabled = true
Expand All @@ -172,15 +172,15 @@ visualizationOptions.forEach(option => {
enableAPIConversionWithProtocol(editorInstance)

break;

case "aas-tab":
}
case "aas-tab": {

generateAAS(fileType, editorInstance)
AASView.classList.remove("hidden")

break;

case "defaults-tab":
}
case "defaults-tab": {
if (fileType === "yaml") {
defaultsJsonBtn.disabled = false
defaultsYamlBtn.disabled = true
Expand All @@ -194,21 +194,22 @@ visualizationOptions.forEach(option => {
defaultsView.classList.remove("hidden")

break;

case "visualize-tab":
}
case "visualize-tab": {
visualize(td)

break;

case "validation-tab":
}
case "validation-tab": {
validationView.classList.remove("hidden")
const editorData = getEditorData(editorInstance)
validate(editorData[1], editorValue)

break;

default:
}
default: {
break;
}
}

}
Expand Down
2 changes: 1 addition & 1 deletion packages/web-new/src/scripts/editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,7 @@ async function initEditor(ideNumber, editorValue, editorLanguage) {
setFontSize(editorInstance)
})

editorInstance.getModel().onDidChangeContent(_ => {
editorInstance.getModel().onDidChangeContent(() => {

try {
const editorValues = getEditorData(editorInstance)
Expand Down
8 changes: 4 additions & 4 deletions packages/web-new/src/scripts/jsonld-vis.js
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,7 @@ export function jsonldVis(jsonld, selector, config) {
const nodeEnter = node.enter()
.append('g')
.attr('class', 'node')
.attr('transform', function (d) { return 'translate(' + source.y0 + ',' + source.x0 + ')'; })
.attr('transform', function () { return 'translate(' + source.y0 + ',' + source.x0 + ')'; })
.on('click', click);

nodeEnter.append('circle')
Expand Down Expand Up @@ -389,7 +389,7 @@ export function jsonldVis(jsonld, selector, config) {
const nodeExit = node.exit().transition()
.duration(transitionDuration)
.ease(transitionEase)
.attr('transform', function (d) { return 'translate(' + source.y + ',' + source.x + ')'; })
.attr('transform', function () { return 'translate(' + source.y + ',' + source.x + ')'; })
.remove();

nodeExit.select('circle').attr('r', 0);
Expand All @@ -400,7 +400,7 @@ export function jsonldVis(jsonld, selector, config) {

link.enter().insert('path', 'g')
.attr('class', 'link')
.attr('d', function (d) {
.attr('d', function () {
const o = { x: source.x0, y: source.y0 };
return diagonal({ source: o, target: o });
});
Expand All @@ -413,7 +413,7 @@ export function jsonldVis(jsonld, selector, config) {
link.exit().transition()
.duration(transitionDuration)
.ease(transitionEase)
.attr('d', function (d) {
.attr('d', function () {
const o = { x: source.x, y: source.y };
return diagonal({ source: o, target: o });
})
Expand Down
15 changes: 8 additions & 7 deletions packages/web-new/src/scripts/save-menu.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ const downloadBtn = document.querySelector("#download-btn")
// const saveAsBtn = document.querySelector("#save-as-btn")
// const saveAsWarning = document.querySelector(".save-warning")
const saveMenuContainer = document.querySelector(".save-menu__container")
let fileHandle;
// let fileHandle;
openUrlTab.disabled = true
shareUrlContainer.value = ""

Expand Down Expand Up @@ -160,6 +160,8 @@ downloadBtn.addEventListener("click", () => {
openUrlTab.disabled = true
})


//TODO: Uncomment when https is implemented
/* Save as btn functionality */
// saveAsBtn.addEventListener("click", () => {
// saveAsFile()
Expand All @@ -169,13 +171,12 @@ downloadBtn.addEventListener("click", () => {
* Saves the td as a file in the file system
* @param {*} content
*/
async function saveFileInSystem(content) {
let stream = await fileHandle.createWritable()
await stream.write(content)
await stream.close()
}
// async function saveFileInSystem(content) {
// let stream = await fileHandle.createWritable()
// await stream.write(content)
// await stream.close()
// }

//TODO: Uncomment when https is implemented
/**
* Opens the file system allows the user to input a file
* name and save it as json , jsonld or yaml
Expand Down
4 changes: 2 additions & 2 deletions packages/web-new/tests/test.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -1007,7 +1007,7 @@ test.describe("OpenAPI view functionality", () => {
const openAPIContainer = openAPIEditor.getByRole('code').locator('div').filter({ hasText: '"openapi": "3.0.3",' }).nth(4)

await expect(openAPIEditor).toHaveAttribute('data-mode-id', "json")
await expect(openAPIContainer).toHaveText('\"openapi\": \"3.0.3\",')
await expect(openAPIContainer).toHaveText('"openapi": "3.0.3",')

const openAPIJsonBtn = page.locator('#open-api-json')

Expand Down Expand Up @@ -1160,7 +1160,7 @@ test.describe("OpenAPI view functionality", () => {
const openAPIContainer = openAPIEditor.getByRole('code').locator('div').filter({ hasText: '"openapi": "3.0.3",' }).nth(4)

await expect(openAPIEditor).toHaveAttribute('data-mode-id', "json")
await expect(openAPIContainer).toHaveText('\"openapi\": \"3.0.3\",')
await expect(openAPIContainer).toHaveText('"openapi": "3.0.3",')

const openAPIJsonBtn = page.locator('#open-api-json')
await expect(openAPIJsonBtn).toBeDisabled()
Expand Down

0 comments on commit 9dfe5b2

Please sign in to comment.