[beast: 36/70] EBEAST: use eslint 3.16.1 for linting of *.js files and JS snippets in *.html



commit b3689b1bb9b8f22888533073846ce2e2f8f34e69
Author: Tim Janik <timj gnu org>
Date:   Sun Mar 5 21:54:09 2017 +0100

    EBEAST: use eslint 3.16.1 for linting of *.js files and JS snippets in *.html
    
    Signed-off-by: Tim Janik <timj gnu org>

 ebeast/.eslintrc.js    |   28 ++++++++++++++++++++++++++++
 ebeast/.gitignore      |    4 +++-
 ebeast/Makefile.am     |   13 ++++++++++++-
 ebeast/main.js         |    6 +++---
 ebeast/package.json.in |    3 ++-
 5 files changed, 48 insertions(+), 6 deletions(-)
---
diff --git a/ebeast/.eslintrc.js b/ebeast/.eslintrc.js
new file mode 100644
index 0000000..a79325e
--- /dev/null
+++ b/ebeast/.eslintrc.js
@@ -0,0 +1,28 @@
+module.exports = {
+  "env": {
+    "browser": true,
+    "es6": true,
+    "jquery": true,
+    "node": true
+  },
+  "globals": {
+    "Electron": false,
+    "Mithril": false,
+    "Bse": false,
+    "module": true /* allow mods */
+  },
+  "rules": {
+    "no-unused-vars": [ "warn", { "argsIgnorePattern": "^_.*", "varsIgnorePattern": "^_.*" } ],
+    "no-unreachable": [ "warn" ],
+    "semi": [ "error", "always" ],
+    "no-extra-semi": [ "warn" ],
+    "no-console": [ "off" ],
+    "no-constant-condition": [ "warn" ],
+    "indent": [ "off", 2 ],
+    "linebreak-style": [ "error", "unix" ],
+    "no-mixed-spaces-and-tabs": [ "off" ],
+    "quotes": [ "off", "single" ]
+  },
+  "plugins": [ "html" ],
+  "extends": "eslint:recommended"
+};
diff --git a/ebeast/.gitignore b/ebeast/.gitignore
index 37e3ca1..5d7538e 100644
--- a/ebeast/.gitignore
+++ b/ebeast/.gitignore
@@ -1,3 +1,5 @@
 /package.json
 /config.log
-/node_modules/
\ No newline at end of file
+/node_modules/
+/xlint-html
+/xlint-js
diff --git a/ebeast/Makefile.am b/ebeast/Makefile.am
index 615f8fd..a2999a6 100644
--- a/ebeast/Makefile.am
+++ b/ebeast/Makefile.am
@@ -22,7 +22,7 @@ clean-local: clean-node_modules
 clean-node_modules: ; rm -rf node_modules/ package.json
 
 # == app ==
-app:   package.json xlint-html
+app:   package.json xlint-html xlint-js
        $(Q) $(MAKE) $(AM_MAKEFLAGS) -C v8bse v8bse.node
 
 # == run ==
@@ -48,3 +48,14 @@ xlint-html: $(HTML_LINT_FILES)
        $(Q) cat $@.log ; test ! -s $@.log
        $(Q) mv $@.log $@
 MOSTLYCLEANFILES += xlint-html xlint-html.log
+
+# == JS linting ==
+JS_LINT_FILES = *.js $(HTML_LINT_FILES)
+xlint-js: $(JS_LINT_FILES) package.json
+       $(AM_V_GEN)
+       $(Q) rm -f $@
+       $(Q) for file in $(JS_LINT_FILES) ; do \
+         ./node_modules/.bin/eslint -f unix $$file || exit $$? ; \
+       done
+       $(Q) touch $@
+MOSTLYCLEANFILES += xlint-js
diff --git a/ebeast/main.js b/ebeast/main.js
index 9bbe7e7..458ecd3 100644
--- a/ebeast/main.js
+++ b/ebeast/main.js
@@ -1,11 +1,11 @@
 // Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
-const {app, BrowserWindow, ipcMain} = require ('electron');
+const {app, BrowserWindow} = require ('electron');
 
 // create the main ebeast window
 var win;
 function create_window ()
 {
-  options = {
+  const options = {
     width: 1820, height: 1024, // calling win.maximize() flickers, using a big size not
     webPreferences: {
       defaultEncoding: 'UTF-8',
@@ -28,7 +28,7 @@ function create_window ()
   win.once ('ready-to-show', () => { win.show(); });
   win.loadURL ('file:///' + __dirname + '/index.html');
   // win.webContents.openDevTools();
-  win.on ('closed', () => { win = null });
+  win.on ('closed', () => { win = null; });
 }
 app.on ('ready', create_window); // create window once everything is loaded
 
diff --git a/ebeast/package.json.in b/ebeast/package.json.in
index d4e2f2c..6fbb88b 100644
--- a/ebeast/package.json.in
+++ b/ebeast/package.json.in
@@ -4,7 +4,8 @@
   "description":     "Beast - Music Synthesizer and Composer",
   "main":            "main.js",
   "dependencies":    { "electron": "^1.4.15" },
-  "devDependencies": { "node-gyp": "^3.5.0" },
+  "devDependencies": { "node-gyp": "^3.5.0",
+                      "eslint": "^3.16.1", "eslint-plugin-html": "^2.0.1" },
   "license":         "LGPL-3.0",
   "scripts": {
     "test": "echo \"Error: no test specified\" && exit 1"


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]