From 0a32371f0cdd26c5becff35837fcef09cda15f48 Mon Sep 17 00:00:00 2001 From: Kushagra Gour Date: Thu, 9 Jun 2016 13:52:31 +0530 Subject: [PATCH 1/4] add eslint. --- .eslintrc.json | 253 +++++++++++++++++++++++++++++++++++++++++++++++ src/eventPage.js | 7 +- src/script.js | 23 ++--- 3 files changed, 270 insertions(+), 13 deletions(-) create mode 100644 .eslintrc.json diff --git a/.eslintrc.json b/.eslintrc.json new file mode 100644 index 0000000..6ee0f4c --- /dev/null +++ b/.eslintrc.json @@ -0,0 +1,253 @@ +{ + "env": { + "browser": true + }, + "extends": "eslint:recommended", + "rules": { + "accessor-pairs": "error", + "array-bracket-spacing": "off", + "array-callback-return": "error", + "arrow-body-style": "error", + "arrow-parens": "error", + "arrow-spacing": "error", + "block-scoped-var": "error", + "block-spacing": [ + "error", + "always" + ], + "brace-style": "off", + "callback-return": "error", + "camelcase": "error", + "comma-spacing": "off", + "comma-style": "off", + "complexity": "error", + "computed-property-spacing": [ + "error", + "never" + ], + "consistent-return": "error", + "consistent-this": "off", + "curly": "error", + "default-case": "error", + "dot-location": [ + "error", + "property" + ], + "dot-notation": "error", + "eol-last": "off", + "eqeqeq": "error", + "func-names": "off", + "func-style": [ + "error", + "declaration" + ], + "generator-star-spacing": "error", + "global-require": "error", + "guard-for-in": "error", + "handle-callback-err": "error", + "id-blacklist": "error", + "id-length": "off", + "id-match": "error", + "indent": [ "error", "tab" ], + "init-declarations": "off", + "jsx-quotes": "error", + "key-spacing": [ + "error", + { "afterColon": true } + ], + "keyword-spacing": [ + "error", + { + "after": true, + "before": true + } + ], + "linebreak-style": [ + "error", + "unix" + ], + "lines-around-comment": "error", + "max-depth": "error", + "max-len": "off", + "max-nested-callbacks": "error", + "max-params": "error", + "max-statements": "off", + "max-statements-per-line": "off", + "new-parens": "error", + "newline-after-var": "off", + "newline-before-return": "off", + "newline-per-chained-call": "error", + "no-alert": "error", + "no-array-constructor": "error", + "no-bitwise": "error", + "no-caller": "error", + "no-console": "off", + "no-catch-shadow": "error", + "no-confusing-arrow": "error", + "no-continue": "error", + "no-div-regex": "error", + "no-duplicate-imports": "error", + "no-else-return": "error", + "no-empty-function": "off", + "no-eq-null": "error", + "no-eval": "error", + "no-extend-native": "error", + "no-extra-bind": "error", + "no-extra-label": "error", + "no-extra-parens": "off", + "no-floating-decimal": "error", + "no-implicit-coercion": "error", + "no-implicit-globals": "off", + "no-implied-eval": "error", + "no-inline-comments": "error", + "no-inner-declarations": [ + "error", + "functions" + ], + "no-invalid-this": "error", + "no-iterator": "error", + "no-label-var": "error", + "no-labels": "error", + "no-lone-blocks": "error", + "no-lonely-if": "error", + "no-loop-func": "error", + "no-magic-numbers": "off", + "no-mixed-requires": "error", + "no-multi-spaces": "error", + "no-multi-str": "error", + "no-multiple-empty-lines": "error", + "no-native-reassign": "error", + "no-negated-condition": "off", + "no-nested-ternary": "error", + "no-new": "error", + "no-new-func": "error", + "no-new-object": "error", + "no-new-require": "error", + "no-new-wrappers": "error", + "no-octal-escape": "error", + "no-param-reassign": [ + "error", + { + "props": false + } + ], + "no-path-concat": "error", + "no-plusplus": [ + "error", + { + "allowForLoopAfterthoughts": true + } + ], + "no-process-env": "error", + "no-process-exit": "error", + "no-proto": "error", + "no-prototype-builtins": "error", + "no-restricted-globals": "error", + "no-restricted-imports": "error", + "no-restricted-modules": "error", + "no-restricted-syntax": "error", + "no-return-assign": "error", + "no-script-url": "error", + "no-self-compare": "error", + "no-sequences": "error", + "no-shadow": "error", + "no-shadow-restricted-names": "error", + "no-spaced-func": "error", + "no-sync": "error", + "no-ternary": "off", + "no-throw-literal": "error", + "no-trailing-spaces": "error", + "no-undef-init": "error", + "no-undefined": "error", + "no-underscore-dangle": "error", + "no-unmodified-loop-condition": "error", + "no-unneeded-ternary": "error", + "no-unsafe-finally": "error", + "no-unused-expressions": "error", + "no-use-before-define": "error", + "no-useless-call": "error", + "no-useless-computed-key": "error", + "no-useless-concat": "off", + "no-useless-constructor": "error", + "no-useless-escape": "error", + "no-useless-rename": "error", + "no-var": "off", + "no-void": "error", + "no-warning-comments": "error", + "no-whitespace-before-property": "error", + "no-with": "error", + "object-curly-spacing": [ + "error", + "never" + ], + "object-property-newline": "error", + "object-shorthand": "off", + "one-var": "off", + "one-var-declaration-per-line": "error", + "operator-assignment": [ + "error", + "always" + ], + "operator-linebreak": [ + "error", + "before" + ], + "padded-blocks": "off", + "prefer-arrow-callback": "off", + "prefer-const": "error", + "prefer-reflect": "error", + "prefer-rest-params": "off", + "prefer-spread": "error", + "prefer-template": "off", + "quote-props": "off", + "quotes": "off", + "radix": "error", + "require-jsdoc": "off", + "require-yield": "error", + "semi": "off", + "semi-spacing": [ + "error", + { + "after": true, + "before": false + } + ], + "sort-imports": "error", + "sort-vars": "off", + "space-before-blocks": "off", + "space-before-function-paren": "off", + "space-in-parens": [ + "error", + "never" + ], + "space-infix-ops": "error", + "space-unary-ops": "error", + "spaced-comment": [ + "error", + "always" + ], + "strict": [ + "error", + "never" + ], + "template-curly-spacing": "error", + "unicode-bom": [ + "error", + "never" + ], + "valid-jsdoc": "error", + "vars-on-top": "off", + "wrap-regex": "error", + "yield-star-spacing": "error", + "yoda": [ + "error", + "never" + ] + }, + "globals": { + "chrome": true, + "CodeMirror": true, + "Split": true, + "emmetCodeMirror": true + } +} \ No newline at end of file diff --git a/src/eventPage.js b/src/eventPage.js index 5108413..672761e 100644 --- a/src/eventPage.js +++ b/src/eventPage.js @@ -1,3 +1,6 @@ -chrome.browserAction.onClicked.addListener(function(activeTab) { - chrome.tabs.create({ url: chrome.extension.getURL('index.html'), selected: true }); +chrome.browserAction.onClicked.addListener(function(){ + chrome.tabs.create({ + url: chrome.extension.getURL('index.html'), + selected: true + }); }); \ No newline at end of file diff --git a/src/script.js b/src/script.js index 3305c33..e6ee36d 100644 --- a/src/script.js +++ b/src/script.js @@ -1,6 +1,8 @@ +/* eslint-disable no-extra-semi */ ;(function () { - editur = window.editur || {}; +/* eslint-enable no-extra-semi */ + var editur = window.editur || {}; var $ = document.querySelector.bind(document); var $all = document.querySelectorAll.bind(document); @@ -10,7 +12,7 @@ , currentLayoutMode , frame = $('#demo-frame') , htmlCode = $('#js-html-code') - ,cssCode = $('#js-css-code') + , cssCode = $('#js-css-code') , jsCode = $('#js-js-code') , layoutBtn1 = $('#js-layout-btn-1') , layoutBtn2 = $('#js-layout-btn-2') @@ -44,7 +46,7 @@ direction: (currentLayoutMode === 2 ? 'vertical' : 'horizontal') }); } - window.toggleLayout = function (mode) { + function toggleLayout(mode) { currentLayoutMode = mode; $('#js-layout-btn-1').classList.remove('selected'); $('#js-layout-btn-2').classList.remove('selected'); @@ -58,12 +60,12 @@ resetSplitting(); } - window.saveSetting = function saveSetting(setting, value) { + function saveSetting(setting, value) { var obj = {}; obj[setting] = value; chrome.storage.local.set(obj, function() { }); - }; + } function saveCode() { var code = { @@ -79,7 +81,6 @@ }; editur.setPreviewContent = function () { - var self = this; var html = editur.cm.html.getValue(); var css = editur.cm.css.getValue(); var js = editur.cm.js.getValue(); @@ -89,7 +90,7 @@ var fileWritten = false; - var blob = new Blob([ html ], {type : "text/plain;charset=UTF-8"}); + var blob = new Blob([ html ], {type: "text/plain;charset=UTF-8"}); function errorHandler() { console.log(arguments); } @@ -120,7 +121,7 @@ lineWrapping: true, autofocus: options.autofocus || false, autoCloseBrackets: true, - matchBrackets: true, + matchBrackets: true, tabMode: 'indent', keyMap: 'sublime', theme: 'monokai', @@ -176,7 +177,7 @@ e.preventDefault(); }); - saveHtmlBtn.addEventListener('click', function (e) { + saveHtmlBtn.addEventListener('click', function () { var html = editur.cm.html.getValue(); var css = editur.cm.css.getValue(); var js = editur.cm.js.getValue(); @@ -190,7 +191,7 @@ fileName += '.html'; var a = document.createElement('a'); - var blob = new Blob([ fileContent ], {type : "text/html;charset=UTF-8"}); + var blob = new Blob([ fileContent ], {type: "text/html;charset=UTF-8"}); a.href = window.URL.createObjectURL(blob); a.download = fileName; a.style.display = 'none'; @@ -205,7 +206,7 @@ } }); - settingsBtn.addEventListener('click', function(e) { + settingsBtn.addEventListener('click', function() { if (!chrome.runtime.openOptionsPage) { // New way to open options pages, if supported (Chrome 42+). // Bug: https://bugs.chromium.org/p/chromium/issues/detail?id=601997 From 89e5c5dc7585d9ed9173ac64d79422124ef2db36 Mon Sep 17 00:00:00 2001 From: Kushagra Gour Date: Thu, 9 Jun 2016 13:58:18 +0530 Subject: [PATCH 2/4] add travis. --- .travis.yml | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 .travis.yml diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..ad20d55 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,7 @@ +language: node_js +node_js: + - '4.0' +install: + - npm install -g eslint +script: + - eslint src/*.js \ No newline at end of file From 594d17fa9ce85d1590ed2aafb0043bcbb4ee1f83 Mon Sep 17 00:00:00 2001 From: Kushagra Gour Date: Thu, 9 Jun 2016 14:05:23 +0530 Subject: [PATCH 3/4] change review link and copy. --- src/index.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/index.html b/src/index.html index 7c2e89d..29ef3d2 100644 --- a/src/index.html +++ b/src/index.html @@ -302,7 +302,7 @@

Made by Kushagra Gour

Tweet out your feature requests, comments & suggestions to @chinchang457.

-

If you like this extension, support it by writing a review here.

+

Like this extension? Please rate it here.

Awesome libraries used

From d3fa20fb4c094913cbf64e973608f186505370c3 Mon Sep 17 00:00:00 2001 From: Kushagra Gour Date: Thu, 9 Jun 2016 14:11:28 +0530 Subject: [PATCH 4/4] change license to mit and add gh link. --- src/index.html | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/index.html b/src/index.html index 29ef3d2..46c56c5 100644 --- a/src/index.html +++ b/src/index.html @@ -303,6 +303,7 @@

Made by Kushagra Gour

Tweet out your feature requests, comments & suggestions to @chinchang457.

Like this extension? Please rate it here.

+

Contribute on Github.

Awesome libraries used

@@ -316,7 +317,7 @@

License

- "Web Maker" is licensed under Creative Commons Attribution-NonCommercial-NoDerivs 3.0 Unported License + "Web Maker" is open-source under the MIT License.