Skip to content
This repository has been archived by the owner. It is now read-only.
Permalink
Browse files

eslint window globals

  • Loading branch information...
Prinzhorn committed Apr 12, 2018
1 parent 548f800 commit 4ad4f92b79ed42d4b4cd23470d2212943261e571
Showing with 80 additions and 32 deletions.
  1. +64 −3 .eslintrc.json
  2. +13 −26 dist/scrollmeister.js
  3. +1 −1 package.json
  4. +2 −2 src/behaviors/HashNavigationBehavior.js
@@ -3,8 +3,8 @@
"plugins": ["flowtype"],
"extends": ["plugin:flowtype/recommended", "eslint:recommended"],
"env": {
"browser": true,
"jest": true
"jest": true,
"browser": true
},
"parserOptions": {
"ecmaVersion": 8,
@@ -16,6 +16,67 @@
"rules": {
"radix": ["warn", "always"],
"no-unused-vars": ["error", { "argsIgnorePattern": "next" }],
"eqeqeq": ["error", "always", { "null": "ignore" }]
"eqeqeq": ["error", "always", { "null": "ignore" }],
"no-restricted-globals": [
"error",
"addEventListener",
"blur",
"close",
"closed",
"confirm",
"defaultStatus",
"defaultstatus",
"event",
"external",
"find",
"focus",
"frameElement",
"frames",
"history",
"innerHeight",
"innerWidth",
"length",
"location",
"locationbar",
"menubar",
"moveBy",
"moveTo",
"name",
"onblur",
"onerror",
"onfocus",
"onload",
"onresize",
"onunload",
"open",
"opener",
"opera",
"outerHeight",
"outerWidth",
"pageXOffset",
"pageYOffset",
"parent",
"print",
"removeEventListener",
"resizeBy",
"resizeTo",
"screen",
"screenLeft",
"screenTop",
"screenX",
"screenY",
"scroll",
"scrollbars",
"scrollBy",
"scrollTo",
"scrollX",
"scrollY",
"self",
"status",
"statusbar",
"stop",
"toolbar",
"top"
]
}
}
@@ -13038,12 +13038,12 @@ var HashNavigationBehavior = function (_Behavior) {
}

//The link points to something completely different.
if (link.hostname !== location.hostname) {
if (link.hostname !== window.location.hostname) {
return false;
}

//The link does not link to the same page/path.
if (link.pathname !== location.pathname) {
if (link.pathname !== window.location.pathname) {
return false;
}

},

attachBehaviors: function attachBehaviors(element, behaviorPropertiesMap) {
var attachedABehavior = void 0;
var hasKeys = void 0;
var behaviorOrder = this.getBehaviorOrder();

//We loop over all behaviors in unspecified order until we eventually resolve all dependencies (or not).
//TODO: use getBehaviorOrder
do {
hasKeys = false;
attachedABehavior = false;

for (var name in behaviorPropertiesMap) {
if (!behaviorPropertiesMap.hasOwnProperty(name)) {
continue;
}

hasKeys = true;
for (var i = 0; i < behaviorOrder.length; i++) {
var behaviorName = behaviorOrder[i];

if (this._checkBehaviorDependencies(element, name)) {
this.attachBehavior(element, name, behaviorPropertiesMap[name]);
attachedABehavior = true;

delete behaviorPropertiesMap[name];
}
if (!behaviorPropertiesMap.hasOwnProperty(behaviorName)) {
continue;
}

if (hasKeys && !attachedABehavior) {
if (!this._checkBehaviorDependencies(element, behaviorName)) {
throw new Error(
//TODO: better error message with the exact thing that is missing.
'Could not resolve dependencies for behaviors "' + Object.keys(behaviorPropertiesMap).join('", "') + '".');
//TODO: render this error inline as well (behaviors have this.error, maybe MeisterComponent.error() method?)
'The "' + behaviorName + '" behavior requires the "" behavior for. Make sure you add the attribute to the element.');
}
} while (hasKeys);

this.attachBehavior(element, behaviorName, behaviorPropertiesMap[behaviorName]);
}
},

attachBehavior: function attachBehavior(element, name, rawProperties) {
@@ -6,7 +6,7 @@
"scripts": {
"test": "npm run flow && npm run eslint && npm run jest",
"jest": "NODE_PATH='./src' jest",
"eslint": "eslint src/**/*.js",
"eslint": "eslint src/*.js src/**/*.js",
"flow": "flow check",
"server": "http-server",
"reload": "browser-sync start --proxy 'localhost:8080' --files 'examples/*.html, dist/scrollmeister.js'",
@@ -66,12 +66,12 @@ export default class HashNavigationBehavior extends Behavior {
}

//The link points to something completely different.
if (link.hostname !== location.hostname) {
if (link.hostname !== window.location.hostname) {
return false;
}

//The link does not link to the same page/path.
if (link.pathname !== location.pathname) {
if (link.pathname !== window.location.pathname) {
return false;
}

0 comments on commit 4ad4f92

Please sign in to comment.
You can’t perform that action at this time.