From 7e23c230d09ca93643b04bbc5fbb79814f018616 Mon Sep 17 00:00:00 2001 From: Rob Garrison Date: Tue, 13 Feb 2018 07:59:17 -0600 Subject: [PATCH] Meta: add rudimentary linting --- .editorconfig | 10 ++ .eslintrc | 29 ++++++ Gruntfile.js | 12 +-- js/jquery.keyboard.extension-altkeyspopup.js | 4 +- js/jquery.keyboard.extension-extender.js | 2 +- js/jquery.keyboard.extension-mobile.js | 4 +- js/jquery.keyboard.extension-navigation.js | 4 +- js/jquery.keyboard.js | 100 +++++++++---------- package.json | 3 +- 9 files changed, 102 insertions(+), 66 deletions(-) create mode 100644 .editorconfig create mode 100644 .eslintrc diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 00000000..b52ff414 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,10 @@ +# https://github.com/editorconfig/editorconfig/wiki/EditorConfig-Properties +root = true + +[*] +indent_style = tab +trim_trailing_whitespace = true +end_of_line = lf +charset = utf-8 +insert_final_newline = true +max_line_length = 100 diff --git a/.eslintrc b/.eslintrc new file mode 100644 index 00000000..ebdac20f --- /dev/null +++ b/.eslintrc @@ -0,0 +1,29 @@ +{ + "env": { + "browser": true, + "jquery": true + }, + "rules": { + "curly": 1, + "dot-location": [2, "property"], + "eqeqeq": 1, + "linebreak-style": [2, "unix"], + "no-else-return": 1, + "no-eval": 2, + "no-octal": 2, + "no-with": 2, + "radix": 2, + "brace-style": 0, + "camelcase": 0, + "indent": 0, + "no-array-constructor": 2, + "quotes": [2, "single", { + "allowTemplateLiterals": true, + "avoidEscape": true + }], + "spaced-comment": 0, + "arrow-spacing": 2, + "no-var": 0, + "no-unused-vars": 1 + } +} diff --git a/Gruntfile.js b/Gruntfile.js index ae8286e7..75831811 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -10,10 +10,10 @@ module.exports = function(grunt) { '█████▀ ▀████▀ ██ ██ ▀████▀ ██ ██ ██ ██ ▀████▀ █████▀ ██ ██ █████▀\n*/\n', hintOpts = { - "jquery": true, - "browser": true, - "sub": true, // used by layouts - "-W100": true // ignore "This character may get silently deleted by one or more browsers." + 'jquery': true, + 'browser': true, + 'sub': true, // used by layouts + '-W100': true // ignore "This character may get silently deleted by one or more browsers." }; // Project configuration. @@ -232,7 +232,7 @@ module.exports = function(grunt) { ]); function escapeRegExp(str) { - return str.replace(/[$()*+\-.\/?[\\\]^{|}]/g, "\\$&"); + return str.replace(/[$()*+\-.\/?[\\\]^{|}]/g, '\\$&'); } // update keyboard.jquery.json file version numbers to match the package.json version @@ -259,7 +259,7 @@ module.exports = function(grunt) { project = grunt.file.read('js/jquery.keyboard.js'); if ( new RegExp(escapeRegExp('/*! jQuery UI Virtual Keyboard v' + pkg.version)).test(project) && - new RegExp(escapeRegExp("base.version = '" + pkg.version)).test(project) + new RegExp(escapeRegExp('base.version = \'' + pkg.version)).test(project) ) { console.info('versions all match!'); } else { diff --git a/js/jquery.keyboard.extension-altkeyspopup.js b/js/jquery.keyboard.extension-altkeyspopup.js index 4916ba79..8a2cf7d1 100644 --- a/js/jquery.keyboard.extension-altkeyspopup.js +++ b/js/jquery.keyboard.extension-altkeyspopup.js @@ -299,7 +299,7 @@ base.options.ignoreEsc = true; $( document ) .unbind( base.altkeypopup_namespace ) - .bind( 'keydown' + base.altkeypopup_namespace, function( event ) { + .bind( 'keydown' + base.altkeypopup_namespace, function() { // keep home & end from scrolling the page return false; }) @@ -353,7 +353,7 @@ }); // adjust position as needed using popupPosition callback function - if ( typeof base.altkeypopup_options.popupPosition === "function" ) { + if ( typeof base.altkeypopup_options.popupPosition === 'function' ) { base.altkeypopup_options.popupPosition(base, data); } diff --git a/js/jquery.keyboard.extension-extender.js b/js/jquery.keyboard.extension-extender.js index 277cdde6..5aa003f7 100644 --- a/js/jquery.keyboard.extension-extender.js +++ b/js/jquery.keyboard.extension-extender.js @@ -34,7 +34,7 @@ }; // add {extender} keyaction - $keyboard.keyaction.extender = function( base, el ) { + $keyboard.keyaction.extender = function( base ) { base.extender_toggle(); return false; }; diff --git a/js/jquery.keyboard.extension-mobile.js b/js/jquery.keyboard.extension-mobile.js index e96be393..7a0fc1c9 100644 --- a/js/jquery.keyboard.extension-mobile.js +++ b/js/jquery.keyboard.extension-mobile.js @@ -176,8 +176,8 @@ $.fn.addMobile = function(options){ // Using this instead of the jQuery Mobile buttonMarkup because it is expecting 's instead of