diff --git a/.eslintrc.json b/.eslintrc.json new file mode 100644 index 0000000..5cb8bb2 --- /dev/null +++ b/.eslintrc.json @@ -0,0 +1,30 @@ +{ + "env": { + "browser": true, + "es2021": true + }, + "extends": "eslint:recommended", + "globals": { + "OV": "writable", + "$": "readonly", + "THREE": "readonly", + "rhino3dm": "readonly", + "IfcAPI": "readonly" + }, + "parserOptions": { + "ecmaVersion": 12 + }, + "rules": { + "no-var": "error", + "guard-for-in": "error", + "no-use-before-define": "error", + "no-new": "error", + "quotes": ["error", "single"], + "block-scoped-var": "error", + "no-loop-func": "error", + "no-undef": "error", + "no-extend-native": "error", + "eqeqeq": "error", + "no-unused-vars": "off" + } +} diff --git a/.jshintrc b/.jshintrc deleted file mode 100644 index ce8e65b..0000000 --- a/.jshintrc +++ /dev/null @@ -1,42 +0,0 @@ -{ - "esversion" : 6, - "curly" : true, - "forin" : true, - "latedef" : true, - "nonew" : true, - "quotmark" : true, - "funcscope" : true, - "lastsemic" : true, - "loopfunc" : true, - "shadow" : false, - "undef" : true, - "unused" : false, - "bitwise" : false, - "freeze" : true, - "leanswitch" : true, - "eqeqeq" : true, - "futurehostile" : true, - "regexpu" : true, - "varstmt" : true, - "globals" : { - "OV" : true, - "THREE" : false, - "rhino3dm" : false, - "IfcAPI" : false, - "TextEncoder" : false, - "TextDecoder" : false, - "XMLHttpRequest" : false, - "FileReader" : false, - "Blob" : false, - "URL" : false, - "window" : false, - "document" : false, - "setTimeout" : false, - "requestAnimationFrame" : false, - "getComputedStyle" : false, - "alert" : false, - "atob" : false, - "console" : false, - "$" : false - } -} diff --git a/package.json b/package.json index 4fe8fd6..fdf471f 100644 --- a/package.json +++ b/package.json @@ -5,13 +5,13 @@ "repository": "github:kovacsv/Online3DViewer", "license": "MIT", "devDependencies": { - "http-server": "^0.12.3", + "eslint": "^7.30.0", "google-closure-compiler": "^20210302.0.0", - "jshint": "^2.12.0", + "http-server": "^0.12.3", "mocha": "^8.3.2", + "nyc": "^15.1.0", "rewire": "^5.0.0", - "svgo": "^2.2.2", - "nyc": "^15.1.0" + "svgo": "^2.2.2" }, "scripts": { "test": "mocha test", @@ -19,5 +19,6 @@ "build": "node tools/run_python.js tools/create_package.py", "update": "node tools/run_python.js tools/update_includes.py", "svg": "node tools/run_python.js tools/optimize_svg_files.py" - } + }, + "dependencies": {} } diff --git a/source/core/core.js b/source/core/core.js index 742ee50..17f93e9 100644 --- a/source/core/core.js +++ b/source/core/core.js @@ -10,12 +10,3 @@ OV.ValueOrDefault = function (val, def) } return val; }; - -OV.EnumerateKeyValuePairs = function (arr, proc) -{ - for (let key in arr) { - if (arr.hasOwnProperty (key)) { - proc (key, arr[key]); - } - } -}; diff --git a/source/external/ifcimporter.js b/source/external/ifcimporter.js index c166e12..685e41f 100644 --- a/source/external/ifcimporter.js +++ b/source/external/ifcimporter.js @@ -3,7 +3,7 @@ OV.ImporterIfc = class extends OV.ImporterBase constructor () { super (); - this.ifc = null; + this.ifc = null; } CanImportExtension (extension) @@ -14,7 +14,7 @@ OV.ImporterIfc = class extends OV.ImporterBase GetKnownFileFormats () { return { - 'ifc' : OV.FileFormat.Binary + 'ifc' : OV.FileFormat.Binary }; } diff --git a/source/external/rhinoimporter.js b/source/external/rhinoimporter.js index 12abaea..ede4a1d 100644 --- a/source/external/rhinoimporter.js +++ b/source/external/rhinoimporter.js @@ -14,7 +14,7 @@ OV.Importer3dm = class extends OV.ImporterBase GetKnownFileFormats () { return { - '3dm' : OV.FileFormat.Binary + '3dm' : OV.FileFormat.Binary }; } diff --git a/source/import/importergltf.js b/source/import/importergltf.js index c604715..763d86c 100644 --- a/source/import/importergltf.js +++ b/source/import/importergltf.js @@ -510,7 +510,7 @@ OV.ImporterGltf = class extends OV.ImporterBase { let propertyGroup = new OV.PropertyGroup ('Asset properties'); for (let propertyName in gltf.asset) { - if (gltf.asset.hasOwnProperty (propertyName)) { + if (Object.prototype.hasOwnProperty.call (gltf.asset, propertyName)) { if (typeof gltf.asset[propertyName] === 'string') { const property = new OV.Property (OV.PropertyType.Text, propertyName, gltf.asset[propertyName]); propertyGroup.AddProperty (property); diff --git a/tools/create_package.py b/tools/create_package.py index 037833e..3014525 100644 --- a/tools/create_package.py +++ b/tools/create_package.py @@ -18,8 +18,8 @@ def GetVersion (rootDir): packageJson = json.load (packageJsonFile) return packageJson['version'] -def JSHintFolder (folder): - result = Tools.RunCommand ('jshint', [folder]) +def ESLintFolder (folder): + result = Tools.RunCommand ('eslint', [folder]) if result != 0: return False return True @@ -125,16 +125,16 @@ def Main (argv): with open ('config.json') as configJson: config = json.load (configJson) - PrintInfo ('JSHint importer sources.') - jsHintResult = JSHintFolder (os.path.join (rootDir, 'source')) - if not jsHintResult: - PrintError ('JSHint importer sources failed.') + PrintInfo ('ESLint importer sources.') + esLintResult = ESLintFolder (os.path.join (rootDir, 'source')) + if not esLintResult: + PrintError ('ESLint importer sources failed.') return 1 - PrintInfo ('JSHint website sources.') - jsHintResult = JSHintFolder (os.path.join (rootDir, 'website', 'o3dv')) - if not jsHintResult: - PrintError ('JSHint website sources failed.') + PrintInfo ('ESLint website sources.') + esLintResult = ESLintFolder (os.path.join (rootDir, 'website', 'o3dv')) + if not esLintResult: + PrintError ('ESLint website sources failed.') return 1 version = GetVersion (rootDir) diff --git a/website/o3dv/featureset.js b/website/o3dv/featureset.js index 01b03a5..0fdca74 100644 --- a/website/o3dv/featureset.js +++ b/website/o3dv/featureset.js @@ -1,4 +1,4 @@ OV.FeatureSet = { - SettingsPanel : false + SettingsPanel : true };