Skip to content

Commit

Permalink
[eslint] switching to eslint and fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
ar2rsawseen committed Jan 17, 2019
1 parent 5e0badf commit 7d61684
Show file tree
Hide file tree
Showing 12 changed files with 389 additions and 119 deletions.
1 change: 1 addition & 0 deletions .eslintignore
@@ -0,0 +1 @@
lib/countly.min.js
291 changes: 291 additions & 0 deletions .eslintrc.js
@@ -0,0 +1,291 @@
module.exports = {
"env": {
"browser": true,
"amd": true,
"commonjs": true
},
"globals": {
"Countly": true
},
"extends": "eslint:recommended",
"parserOptions": {
"ecmaVersion": 5
},
"rules": {
"accessor-pairs": "error",
"array-bracket-newline": "off",
"array-bracket-spacing": [
"error",
"never"
],
"array-callback-return": "error",
"array-element-newline": "off",
"arrow-body-style": "error",
"arrow-parens": "error",
"arrow-spacing": "error",
"block-scoped-var": "off",
"block-spacing": "off",
"brace-style": "off",
"callback-return": "off",
"camelcase": "off",
"capitalized-comments": "off",
"class-methods-use-this": "error",
"comma-dangle": "error",
"comma-spacing": "off",
"comma-style": [
"error",
"last"
],
"complexity": "off",
"computed-property-spacing": [
"error",
"never"
],
"consistent-return": "off",
"consistent-this": "off",
"curly": "off",
"default-case": "off",
"dot-location": [
"error",
"property"
],
"dot-notation": "off",
"eol-last": "off",
"eqeqeq": "off",
"func-call-spacing": "error",
"func-name-matching": "error",
"func-names": "off",
"func-style": "off",
"function-paren-newline": "off",
"generator-star-spacing": "error",
"global-require": "off",
"guard-for-in": "off",
"handle-callback-err": "error",
"id-blacklist": "error",
"id-length": "off",
"id-match": "error",
"implicit-arrow-linebreak": "error",
"indent": "off",
"indent-legacy": "off",
"init-declarations": "off",
"jsx-quotes": "error",
"key-spacing": "off",
"keyword-spacing": "off",
"line-comment-position": "off",
"linebreak-style": [
"error",
"unix"
],
"lines-around-comment": "off",
"lines-around-directive": "off",
"lines-between-class-members": "error",
"max-classes-per-file": "error",
"max-depth": "off",
"max-len": "off",
"max-lines": "off",
"max-lines-per-function": "off",
"max-nested-callbacks": "error",
"max-params": "off",
"max-statements": "off",
"max-statements-per-line": "off",
"multiline-comment-style": "off",
"multiline-ternary": "off",
"new-parens": "off",
"newline-after-var": "off",
"newline-before-return": "off",
"newline-per-chained-call": "error",
"no-alert": "error",
"no-array-constructor": "error",
"no-async-promise-executor": "error",
"no-await-in-loop": "error",
"no-bitwise": "off",
"no-buffer-constructor": "error",
"no-caller": "off",
"no-catch-shadow": "off",
"no-confusing-arrow": "error",
"no-continue": "error",
"no-div-regex": "error",
"no-duplicate-imports": "error",
"no-else-return": "off",
"no-empty": [
"error",
{
"allowEmptyCatch": true
}
],
"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-globals": "off",
"no-implied-eval": "error",
"no-inline-comments": "off",
"no-inner-declarations": [
"error",
"functions"
],
"no-invalid-this": "error",
"no-iterator": "error",
"no-label-var": "off",
"no-labels": "off",
"no-lone-blocks": "error",
"no-lonely-if": "off",
"no-loop-func": "error",
"no-magic-numbers": "off",
"no-misleading-character-class": "error",
"no-mixed-operators": "off",
"no-mixed-requires": "error",
"no-multi-assign": "off",
"no-multi-spaces": "error",
"no-multi-str": "error",
"no-multiple-empty-lines": "off",
"no-native-reassign": "error",
"no-negated-condition": "off",
"no-negated-in-lhs": "error",
"no-nested-ternary": "off",
"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": "off",
"no-path-concat": "error",
"no-plusplus": "off",
"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-properties": "error",
"no-restricted-syntax": "error",
"no-return-assign": "error",
"no-return-await": "error",
"no-script-url": "error",
"no-self-compare": "error",
"no-sequences": "off",
"no-shadow": "off",
"no-shadow-restricted-names": "error",
"no-spaced-func": "error",
"no-sync": "error",
"no-tabs": "error",
"no-template-curly-in-string": "error",
"no-ternary": "off",
"no-throw-literal": "error",
"no-trailing-spaces": "off",
"no-undef-init": "error",
"no-undefined": "error",
"no-underscore-dangle": "off",
"no-unmodified-loop-condition": "error",
"no-unneeded-ternary": "off",
"no-unused-expressions": "off",
"no-use-before-define": "off",
"no-useless-call": "error",
"no-useless-computed-key": "error",
"no-useless-concat": "error",
"no-useless-constructor": "error",
"no-useless-escape": "off",
"no-useless-rename": "error",
"no-useless-return": "error",
"no-var": "off",
"no-void": "error",
"no-warning-comments": "error",
"no-whitespace-before-property": "error",
"no-with": "error",
"nonblock-statement-body-position": [
"error",
"any"
],
"object-curly-newline": "error",
"object-curly-spacing": "off",
"object-property-newline": "off",
"object-shorthand": "off",
"one-var": "off",
"one-var-declaration-per-line": "off",
"operator-assignment": [
"error",
"always"
],
"operator-linebreak": [
"error",
"after"
],
"padded-blocks": "off",
"padding-line-between-statements": "error",
"prefer-arrow-callback": "off",
"prefer-const": "error",
"prefer-destructuring": "off",
"prefer-numeric-literals": "error",
"prefer-object-spread": "error",
"prefer-promise-reject-errors": "error",
"prefer-reflect": "off",
"prefer-rest-params": "off",
"prefer-spread": "off",
"prefer-template": "off",
"quote-props": "off",
"quotes": "off",
"radix": [
"error",
"as-needed"
],
"require-atomic-updates": "error",
"require-await": "error",
"require-jsdoc": "off",
"require-unicode-regexp": "off",
"rest-spread-spacing": "error",
"semi": "off",
"semi-spacing": "off",
"semi-style": [
"error",
"last"
],
"sort-imports": "error",
"sort-keys": "off",
"sort-vars": "off",
"space-before-blocks": "off",
"space-before-function-paren": "off",
"space-in-parens": "off",
"space-infix-ops": "off",
"space-unary-ops": "error",
"spaced-comment": "off",
"strict": "off",
"switch-colon-spacing": "error",
"symbol-description": "error",
"template-curly-spacing": "error",
"template-tag-spacing": "error",
"unicode-bom": [
"error",
"never"
],
"valid-jsdoc": "off",
"vars-on-top": "off",
"wrap-iife": [
"error",
"any"
],
"wrap-regex": "off",
"yield-star-spacing": "error",
"yoda": "off"
},
"overrides": [
{
"files": [
"test/**/*.js",
"webpack.config.js"
],
"env": {
"es6": true,
"node": true
},
"globals": {
"casper": true
}
}
]
};
12 changes: 0 additions & 12 deletions .travis.yml
Expand Up @@ -8,18 +8,6 @@ branches:
env:
global:
- secure: ONfNUHKLNXeG+mqPucbNhXnw7VRmpYKJDXLxyyO1ZxyoSZLytDH9QD3xXLLKwfqVP1DfEAI26xwipGAZejvaXB5Td+a4Q+b3B0Wx0q3kYSh+oQL/CK16HrJkeAbe68hXIYTdRMzQkbwTgDlRbmJiMoNOS6tos6H5dq7V/j5ND60=
before_script:
- npm install
- npm install -g casperjs
- npm install -g jshint
script:
- jshint lib/countly.js
- casperjs test test/tests_sync.js
- casperjs test test/tests_async.js
- casperjs test test/tests_helpers.js
- casperjs test test/tests_helpers_old_session.js
- casperjs test test/tests_gdpr.js
- casperjs test test/tests_persistancy.js
after_success:
- cd $TRAVIS_BUILD_DIR
- chmod +x generateDocs.sh
Expand Down
15 changes: 7 additions & 8 deletions lib/countly.js
Expand Up @@ -285,9 +285,7 @@
*/
Countly.group_features = function (features) {
if (features) {
var ob;
for (var i in features) {
ob = {};
if (!consents[i]) {
if (typeof features[i] === "string") {
consents[i] = { features: [features[i]] };
Expand Down Expand Up @@ -721,7 +719,7 @@
* @param {string|number} value - value to store under provided property
**/
set_once: function (key, value) {
change_custom_property(key, 1, "$setOnce");
change_custom_property(key, value, "$setOnce");
},
/**
* Increment value under the key of this user's custom properties by one
Expand Down Expand Up @@ -1003,7 +1001,8 @@
var segments = {
"name": page,
"visit": 1,
"domain": window.location.hostname
"domain": window.location.hostname,
"view": window.location.pathname
};

if (typeof document.referrer !== "undefined" && document.referrer.length) {
Expand Down Expand Up @@ -1084,11 +1083,11 @@
var shouldProcess = true;
var scrollY = 0;

function processScroll(event) {
function processScroll() {
scrollY = Math.max(scrollY, window.scrollY, document.body.scrollTop, document.documentElement.scrollTop);
}

function processScrollView(e) {
function processScrollView() {
if (shouldProcess) {
shouldProcess = false;
var height = getDocHeight();
Expand Down Expand Up @@ -1850,7 +1849,7 @@
if (arguments[1] && typeof arguments[1] == "object") {
arguments[1] = JSON.stringify(arguments[1]);
}

// eslint-disable-next-line no-console
console.log(Array.prototype.slice.call(arguments).join("\n"));
}
}
Expand Down Expand Up @@ -1954,7 +1953,7 @@
function sendXmlHttpRequest(url, params, callback) {
try {
log("Sending XML HTTP request");
var xhr = window.XMLHttpRequest ? new window.XMLHttpRequest() : window.ActiveXObject ? new ActiveXObject("Microsoft.XMLHTTP") : null;
var xhr = window.XMLHttpRequest ? new window.XMLHttpRequest() : window.ActiveXObject ? new window.ActiveXObject("Microsoft.XMLHTTP") : null;
params = params || {};
var data = prepareParams(params);
var method = "GET";
Expand Down

0 comments on commit 7d61684

Please sign in to comment.