From 49f0ec981c1b29c527a9104a37e5054c1296111d Mon Sep 17 00:00:00 2001
From: Alexander Rose <alexander.rose@weirdbyte.de>
Date: Sat, 19 Sep 2020 11:13:13 -0700
Subject: [PATCH] check js files as well with eslint

- moved ts eslint config into overrides
---
 .eslintrc.json                 | 104 +++++++++++++++++++--------------
 package.json                   |   4 +-
 scripts/deploy.js              |  42 ++++++-------
 webpack.config.common.js       |  18 +++---
 webpack.config.js              |   2 +-
 webpack.config.production.js   |   2 +-
 webpack.config.viewer.debug.js |   2 +-
 webpack.config.viewer.js       |   2 +-
 8 files changed, 95 insertions(+), 81 deletions(-)

diff --git a/.eslintrc.json b/.eslintrc.json
index 77755ba44..e5b448d8a 100644
--- a/.eslintrc.json
+++ b/.eslintrc.json
@@ -3,60 +3,21 @@
         "browser": true,
         "node": true
     },
-    "parser": "@typescript-eslint/parser",
     "parserOptions": {
-        "project": ["tsconfig.json", "tsconfig.commonjs.json"],
-        "sourceType": "module"
+        "ecmaVersion": 2018,
+        "sourceType": "module",
+        "ecmaFeatures": {
+            "impliedStrict": true
+        }
     },
-    "plugins": [
-        "@typescript-eslint"
-    ],
     "rules": {
-        "@typescript-eslint/ban-types": "off",
-        "@typescript-eslint/class-name-casing": "off",
         "indent": "off",
-        "@typescript-eslint/indent": [
-            "error",
-            4
-        ],
-        "@typescript-eslint/member-delimiter-style": [
-            "off",
-            {
-                "multiline": {
-                    "delimiter": "none",
-                    "requireLast": true
-                },
-                "singleline": {
-                    "delimiter": "semi",
-                    "requireLast": false
-                }
-            }
-        ],
-        "@typescript-eslint/prefer-namespace-keyword": "warn",
-        "@typescript-eslint/quotes": [
-            "error",
-            "single",
-            {
-                "avoidEscape": true,
-                "allowTemplateLiterals": true
-            }
-        ],
-        "@typescript-eslint/semi": [
-            "off",
-            null
-        ],
-        "@typescript-eslint/type-annotation-spacing": "error",
         "arrow-parens": [
             "off",
             "as-needed"
         ],
         "brace-style": "off",
-        "@typescript-eslint/brace-style": [
-            "error",
-            "1tbs", { "allowSingleLine": true }
-        ],
         "comma-spacing": "off",
-        "@typescript-eslint/comma-spacing": "error",
         "space-infix-ops": "error",
         "comma-dangle": "off",
         "eqeqeq": [
@@ -71,5 +32,58 @@
         "no-var": "error",
         "spaced-comment": "error",
         "semi": "warn"
-    }
+    },
+    "overrides": [
+        {
+            "files": ["**/*.ts", "**/*.tsx"],
+            "parser": "@typescript-eslint/parser",
+            "parserOptions": {
+                "project": ["tsconfig.json", "tsconfig.commonjs.json"],
+                "sourceType": "module"
+            },
+            "plugins": [
+                "@typescript-eslint"
+            ],
+            "rules": {
+                "@typescript-eslint/ban-types": "off",
+                "@typescript-eslint/class-name-casing": "off",
+                "@typescript-eslint/indent": [
+                    "error",
+                    4
+                ],
+                "@typescript-eslint/member-delimiter-style": [
+                    "off",
+                    {
+                        "multiline": {
+                            "delimiter": "none",
+                            "requireLast": true
+                        },
+                        "singleline": {
+                            "delimiter": "semi",
+                            "requireLast": false
+                        }
+                    }
+                ],
+                "@typescript-eslint/prefer-namespace-keyword": "warn",
+                "@typescript-eslint/quotes": [
+                    "error",
+                    "single",
+                    {
+                        "avoidEscape": true,
+                        "allowTemplateLiterals": true
+                    }
+                ],
+                "@typescript-eslint/semi": [
+                    "off",
+                    null
+                ],
+                "@typescript-eslint/type-annotation-spacing": "error",
+                "@typescript-eslint/brace-style": [
+                    "error",
+                    "1tbs", { "allowSingleLine": true }
+                ],
+                "@typescript-eslint/comma-spacing": "error"
+            }
+        }
+    ]
 }
\ No newline at end of file
diff --git a/package.json b/package.json
index 26d1236b8..9d3a60251 100644
--- a/package.json
+++ b/package.json
@@ -11,8 +11,8 @@
     "url": "https://github.com/molstar/molstar/issues"
   },
   "scripts": {
-    "lint": "eslint ./**/*.{ts,tsx}",
-    "lint-fix": "eslint ./**/*.{ts,tsx} --fix",
+    "lint": "eslint .",
+    "lint-fix": "eslint . --fix",
     "test": "npm run lint && jest",
     "build": "npm run build-tsc && npm run build-extra && npm run build-webpack",
     "build-viewer": "npm run build-tsc && npm run build-extra && npm run build-webpack-viewer",
diff --git a/scripts/deploy.js b/scripts/deploy.js
index c1d4fc30f..176a4c437 100644
--- a/scripts/deploy.js
+++ b/scripts/deploy.js
@@ -4,40 +4,40 @@
  * @author Alexander Rose <alexander.rose@weirdbyte.de>
  */
 
-const git = require('simple-git')
-const path = require('path')
-const fs = require("fs")
-const fse = require("fs-extra")
+const git = require('simple-git');
+const path = require('path');
+const fs = require("fs");
+const fse = require("fs-extra");
 
-const remoteUrl = "https://github.com/molstar/molstar.github.io.git"
-const buildDir = path.resolve(__dirname, '../build/')
-const deployDir = path.resolve(buildDir, 'deploy/')
-const localPath = path.resolve(deployDir, 'molstar.github.io/')
+const remoteUrl = "https://github.com/molstar/molstar.github.io.git";
+const buildDir = path.resolve(__dirname, '../build/');
+const deployDir = path.resolve(buildDir, 'deploy/');
+const localPath = path.resolve(deployDir, 'molstar.github.io/');
 
 function log(command, stdout, stderr) {
     if (command) {
-        console.log('\n###', command)
-        stdout.pipe(process.stdout)
-        stderr.pipe(process.stderr)
+        console.log('\n###', command);
+        stdout.pipe(process.stdout);
+        stderr.pipe(process.stderr);
     }
 }
 
 function copyViewer() {
-    console.log('\n###', 'copy viewer files')
-    const viewerBuildPath = path.resolve(buildDir, '../build/viewer/')
-    const viewerDeployPath = path.resolve(localPath, 'viewer/')
-    fse.copySync(viewerBuildPath, viewerDeployPath, { overwrite: true })
+    console.log('\n###', 'copy viewer files');
+    const viewerBuildPath = path.resolve(buildDir, '../build/viewer/');
+    const viewerDeployPath = path.resolve(localPath, 'viewer/');
+    fse.copySync(viewerBuildPath, viewerDeployPath, { overwrite: true });
 }
 
 if (!fs.existsSync(localPath)) {
-    console.log('\n###', 'create localPath')
-    fs.mkdirSync(localPath, { recursive: true })
+    console.log('\n###', 'create localPath');
+    fs.mkdirSync(localPath, { recursive: true });
 }
 
 process.chdir(localPath);
 
 if (!fs.existsSync(path.resolve(localPath, '.git/'))) {
-    console.log('\n###', 'clone repository')
+    console.log('\n###', 'clone repository');
     git()
         .outputHandler(log)
         .clone(remoteUrl, localPath)
@@ -45,9 +45,9 @@ if (!fs.existsSync(path.resolve(localPath, '.git/'))) {
         .exec(copyViewer)
         .add(['-A'])
         .commit('updated viewer')
-        .push()
+        .push();
 } else {
-    console.log('\n###', 'update repository')
+    console.log('\n###', 'update repository');
     git()
         .outputHandler(log)
         .fetch(['--all'])
@@ -55,5 +55,5 @@ if (!fs.existsSync(path.resolve(localPath, '.git/'))) {
         .exec(copyViewer)
         .add(['-A'])
         .commit('updated viewer')
-        .push()
+        .push();
 }
\ No newline at end of file
diff --git a/webpack.config.common.js b/webpack.config.common.js
index ff2aba48d..f9c514b84 100644
--- a/webpack.config.common.js
+++ b/webpack.config.common.js
@@ -53,7 +53,7 @@ const sharedConfig = {
         aggregateTimeout: 750
     },
     devtool: ''
-}
+};
 
 function createEntry(src, outFolder, outFilename, isNode) {
     return {
@@ -62,7 +62,7 @@ function createEntry(src, outFolder, outFilename, isNode) {
         entry: path.resolve(__dirname, `lib/${src}.js`),
         output: { filename: `${outFilename}.js`, path: path.resolve(__dirname, `build/${outFolder}`) },
         ...sharedConfig
-    }
+    };
 }
 
 function createEntryPoint(name, dir, out, library) {
@@ -71,7 +71,7 @@ function createEntryPoint(name, dir, out, library) {
         entry: path.resolve(__dirname, `lib/${dir}/${name}.js`),
         output: { filename: `${library || name}.js`, path: path.resolve(__dirname, `build/${out}`), library: library || out, libraryTarget: 'umd' },
         ...sharedConfig
-    }
+    };
 }
 
 function createNodeEntryPoint(name, dir, out) {
@@ -86,13 +86,13 @@ function createNodeEntryPoint(name, dir, out) {
             xhr2: 'require("xhr2")',
         },
         ...sharedConfig
-    }
+    };
 }
 
-function createApp(name, library) { return createEntryPoint('index', `apps/${name}`, name, library) }
-function createExample(name) { return createEntry(`examples/${name}/index`, `examples/${name}`, 'index') }
-function createBrowserTest(name) { return createEntryPoint(name, 'tests/browser', 'tests') }
-function createNodeApp(name) { return createNodeEntryPoint('index', `apps/${name}`, name) }
+function createApp(name, library) { return createEntryPoint('index', `apps/${name}`, name, library); }
+function createExample(name) { return createEntry(`examples/${name}/index`, `examples/${name}`, 'index'); }
+function createBrowserTest(name) { return createEntryPoint(name, 'tests/browser', 'tests'); }
+function createNodeApp(name) { return createNodeEntryPoint('index', `apps/${name}`, name); }
 
 module.exports = {
     createApp,
@@ -101,4 +101,4 @@ module.exports = {
     createBrowserTest,
     createNodeEntryPoint,
     createNodeApp
-}
\ No newline at end of file
+};
\ No newline at end of file
diff --git a/webpack.config.js b/webpack.config.js
index 47813da69..16193375d 100644
--- a/webpack.config.js
+++ b/webpack.config.js
@@ -13,4 +13,4 @@ module.exports = [
     createApp('docking-viewer', 'molstar'),
     ...examples.map(createExample),
     ...tests.map(createBrowserTest)
-]
\ No newline at end of file
+];
\ No newline at end of file
diff --git a/webpack.config.production.js b/webpack.config.production.js
index 94952ee55..c5358cfe3 100644
--- a/webpack.config.production.js
+++ b/webpack.config.production.js
@@ -6,4 +6,4 @@ module.exports = [
     createApp('viewer', 'molstar'),
     createApp('docking-viewer', 'molstar'),
     ...examples.map(createExample)
-]
\ No newline at end of file
+];
\ No newline at end of file
diff --git a/webpack.config.viewer.debug.js b/webpack.config.viewer.debug.js
index cd4d373fb..f4c678a62 100644
--- a/webpack.config.viewer.debug.js
+++ b/webpack.config.viewer.debug.js
@@ -4,4 +4,4 @@ module.exports = [
         ...createViewer,
         devtool: 'eval'
     }
-]
\ No newline at end of file
+];
\ No newline at end of file
diff --git a/webpack.config.viewer.js b/webpack.config.viewer.js
index 9aa128f23..f70794904 100644
--- a/webpack.config.viewer.js
+++ b/webpack.config.viewer.js
@@ -2,4 +2,4 @@ const common = require('./webpack.config.common.js');
 const createApp = common.createApp;
 module.exports = [
     createApp('viewer', 'molstar')
-]
\ No newline at end of file
+];
\ No newline at end of file
-- 
GitLab