diff --git a/.eslintrc.json b/.eslintrc.json new file mode 100644 index 00000000000..cfa54ee8370 --- /dev/null +++ b/.eslintrc.json @@ -0,0 +1,46 @@ +{ + "extends": "airbnb-base", + "rules": { + "camelcase": 0, + "comma-dangle": 0, + "dot-notation": 0, + "func-names": 0, + "no-console": 0, + "no-extra-semi": 0, + "no-global-assign": ["error", { + "exceptions": ["Tabs"] + }], + "no-redeclare": 0, + "no-shadow": 0, + "no-undef": "error", + "no-unused-vars": 0, + "no-use-before-define": 0, + "no-var": 0, + "object-shorthand": 0, + "operator-linebreak": 0, + "prefer-arrow-callback": 0, + "prefer-destructuring": 0, + "prefer-template": 0, + "quotes": 0, + "radix": 0, + "space-before-function-paren": 0, + "vars-on-top": 0 + }, + "globals": { + "$": "readonly", + "accounting": "readonly", + "addVariantFromStockLocation": "writable", + "adjustShipmentItems": "writable", + "document": "readonly", + "error": "writable", + "flatpickr": "readonly", + "Handlebars": "readonly", + "json": "writable", + "message": "writable", + "shipments": "writable", + "Sortable": "readonly", + "Spree": "readonly", + "Turbolinks": "readonly", + "window": "readonly" + } +} diff --git a/.gitignore b/.gitignore index 8ce04a6e84e..fc2e5c0439f 100644 --- a/.gitignore +++ b/.gitignore @@ -27,3 +27,6 @@ tags .sass-cache .localeapp .yardoc +node_modules +yarn.lock +package-lock.json diff --git a/.hound.yml b/.hound.yml index f9c225ce3db..841bb99d784 100644 --- a/.hound.yml +++ b/.hound.yml @@ -4,5 +4,6 @@ erb_lint: enabled: true scss: enabled: false -javascript: - enabled: false +eslint: + enabled: true + config_file: .eslintrc.json diff --git a/backend/app/assets/javascripts/spree/backend/components/sortable_table.js b/backend/app/assets/javascripts/spree/backend/components/sortable_table.js index f3366d73a73..c67e6a673c7 100644 --- a/backend/app/assets/javascripts/spree/backend/components/sortable_table.js +++ b/backend/app/assets/javascripts/spree/backend/components/sortable_table.js @@ -1,4 +1,5 @@ //= require solidus_admin/Sortable +/* eslint no-unused-vars: "off" */ Spree.ready(function() { var sortable_tables = document.querySelectorAll('table.sortable'); diff --git a/backend/app/assets/javascripts/spree/backend/components/tabs.js b/backend/app/assets/javascripts/spree/backend/components/tabs.js index 03dd6a8f327..784f3a265b4 100644 --- a/backend/app/assets/javascripts/spree/backend/components/tabs.js +++ b/backend/app/assets/javascripts/spree/backend/components/tabs.js @@ -1,4 +1,5 @@ /* global Tabs */ +/* eslint no-redeclare: "off" */ Tabs = (function() { function Tabs(el) { diff --git a/backend/app/assets/javascripts/spree/backend/shipments.js b/backend/app/assets/javascripts/spree/backend/shipments.js index abc6e459488..38b88281076 100644 --- a/backend/app/assets/javascripts/spree/backend/shipments.js +++ b/backend/app/assets/javascripts/spree/backend/shipments.js @@ -1,4 +1,5 @@ // Shipments AJAX API +/* eslint no-extra-semi: "off", no-unused-vars: "off" */ var ShipmentAddVariantView = Backbone.View.extend({ events: { diff --git a/backend/app/assets/javascripts/spree/backend/translation.js b/backend/app/assets/javascripts/spree/backend/translation.js index 38bda76c561..2fd59f53649 100644 --- a/backend/app/assets/javascripts/spree/backend/translation.js +++ b/backend/app/assets/javascripts/spree/backend/translation.js @@ -1,3 +1,5 @@ +/* eslint no-console: "off" */ + (function() { // Resolves string keys with dots in a deeply nested object // http://stackoverflow.com/a/22129960/4405214 diff --git a/backend/app/assets/javascripts/spree/backend/turbolinks-integration.js b/backend/app/assets/javascripts/spree/backend/turbolinks-integration.js index d185c31ce81..5f10f70e524 100644 --- a/backend/app/assets/javascripts/spree/backend/turbolinks-integration.js +++ b/backend/app/assets/javascripts/spree/backend/turbolinks-integration.js @@ -1,6 +1,7 @@ // Require this file if you plan to use Turbolinks in the Solidus admin // It is necessary because extensions may use JS libs that make use of // jQuery.ready instead of Spree.ready +/* eslint no-console: "off" */ Spree.jQueryReady = $.fn.ready; diff --git a/package.json b/package.json new file mode 100644 index 00000000000..a3955e4ccd9 --- /dev/null +++ b/package.json @@ -0,0 +1,22 @@ +{ + "name": "solidus", + "author": "Solidus Team", + "homepage": "https://solidus.io/", + "version": "2.8.2", + "description": "A free, open-source e-commerce platform that gives you complete control over your store", + "repository": { + "type": "git", + "url": "git+https://github.com/solidusio/solidus.git" + }, + "bugs": "https://github.com/solidusio/solidus/issues", + "license": "BSD-3-Clause", + "scripts": { + "lint": "find . -path \"**\/app\/assets\/javascripts\/*.js\" | grep -f .gitignore | xargs eslint" + }, + "devDependencies": { + "eslint": "5.3.0", + "eslint-config-airbnb": "^17.1.0", + "eslint-config-airbnb-base": "13.1.0", + "eslint-plugin-import": "^2.14.0" + } +}