diff --git a/.eslintrc.json b/.eslintrc.json new file mode 100644 index 0000000..eff21c6 --- /dev/null +++ b/.eslintrc.json @@ -0,0 +1,22 @@ +{ + "parserOptions": { + "ecmaVersion": "latest", + "sourceType": "module" + }, + + "env": { + "node": true, + "browser": true, + "es6": true + }, + "rules": { + "no-unsafe-finally": "off", + "no-unused-vars": "off", + "no-use-before-define": [2, { "functions": false , "classes": false, "variables": false}], + "no-console": "off" + }, + "globals": { + "globalThis": true + }, + "extends": "eslint:recommended" +} diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 4db4cef..ff6e4c7 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -15,5 +15,6 @@ jobs: - name: test run: | + eslint src test node test/run.js node test/self_hosted_test.js diff --git a/src/editor/editor.js b/src/editor/editor.js index e31efbc..b4c0257 100644 --- a/src/editor/editor.js +++ b/src/editor/editor.js @@ -80,7 +80,7 @@ export class Editor { this.markers = {} this.sessions = {} - this.ace_editor = ace.edit(this.editor_container) + this.ace_editor = globalThis.ace.edit(this.editor_container) this.ace_editor.setOptions({ behavioursEnabled: false, @@ -141,7 +141,7 @@ export class Editor { ensure_session(file, code) { let session = this.sessions[file] if(session == null) { - session = ace.createEditSession(code) + session = globalThis.ace.createEditSession(code) this.sessions[file] = session session.setUseWorker(false) session.setOptions({ @@ -389,7 +389,7 @@ export class Editor { const from_pos = session.doc.indexToPosition(from) const to_pos = session.doc.indexToPosition(to) const markerId = session.addMarker( - new ace.Range(from_pos.row,from_pos.column,to_pos.row,to_pos.column), + new globalThis.ace.Range(from_pos.row,from_pos.column,to_pos.row,to_pos.column), className ) if(this.markers[file] == null){ diff --git a/src/editor/value_explorer.js b/src/editor/value_explorer.js index ba64201..60ecd6d 100644 --- a/src/editor/value_explorer.js +++ b/src/editor/value_explorer.js @@ -136,7 +136,6 @@ export const header = object => { } else { return object.toString() } - return header } const get_path = (o, path) => { diff --git a/src/filesystem.js b/src/filesystem.js index 80707c6..be8e69f 100644 --- a/src/filesystem.js +++ b/src/filesystem.js @@ -23,7 +23,7 @@ globalThis.clear_directory_handle = () => { let dir_handle const request_directory_handle = async () => { - dir_handle = await showDirectoryPicker() + dir_handle = await globalThis.showDirectoryPicker() await send_message({type: 'SET', data: dir_handle}) return dir_handle } diff --git a/src/find_definitions.js b/src/find_definitions.js index 11714bd..0e3f924 100644 --- a/src/find_definitions.js +++ b/src/find_definitions.js @@ -180,7 +180,6 @@ const concat_path = (base, i) => { } else { return result } - return result } export const topsort_modules = (modules) => { diff --git a/src/parse_js.js b/src/parse_js.js index fa99f9a..265d50a 100644 --- a/src/parse_js.js +++ b/src/parse_js.js @@ -83,7 +83,7 @@ const tokenize_js = (str) => { {name: 'comment' , re: '//[^\n]*'}, {name: 'comment' , re: '\\/\\*[\\s\\S]*?\\*\\/'}, - {name: 'newline' , re: '[\r\n\]+'}, + {name: 'newline' , re: '[\r\n]+'}, // whitespace except newline @@ -1423,11 +1423,6 @@ const update_children_not_rec = (node, children = node.children) => { } } else if(node.type == 'call_args') { return node - } else if(node.type == 'member_access') { - return {...node, - object: children[0], - property: children[1], - } } else if(node.type == 'spread') { return {...node, expr: children[0], diff --git a/src/runtime.js b/src/runtime.js index 27c8442..6c8168c 100644 --- a/src/runtime.js +++ b/src/runtime.js @@ -46,7 +46,6 @@ const do_run = function*(module_fns, cxt, io_cache){ io_cache_resolver_is_set: false, // Map of (index in io_cache) -> resolve io_cache_resolvers: new Map(), - io_cache_is_replay_aborted: false, io_cache_index: 0, }