Skip to content

Commit

Permalink
Lint cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
nicjansma committed Sep 9, 2017
1 parent 570a568 commit 53eb84d
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 117 deletions.
103 changes: 2 additions & 101 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -1,102 +1,3 @@
{
"env": {
"browser": true,
"node": true,
"amd": true
},
"rules": {
//
// v1.0 rules
//
"camelcase": 2,
"comma-spacing": 2,
"consistent-return": 2,
"curly": [2, "all"],
"dot-notation": [2, { "allowKeywords": true }],
"eol-last": 2,
"eqeqeq": 2,
"key-spacing": [2, { "beforeColon": false, "afterColon": true }],
"new-cap": 2,
"new-parens": 2,
"no-alert": 2,
"no-array-constructor": 2,
"no-caller": 2,
"no-catch-shadow": 2,
"no-eval": 2,
"no-extend-native": 2,
"no-extra-bind": 2,
"no-extra-parens": [2, "functions"],
"no-implied-eval": 2,
"no-iterator": 2,
"no-label-var": 2,
"no-labels": 2,
"no-lone-blocks": 2,
"no-multi-spaces": 2,
"no-multi-str": 2,
"no-native-reassign": 2,
"no-new": 2,
"no-new-func": 2,
"no-new-object": 2,
"no-new-wrappers": 2,
"no-octal-escape": 2,
"no-process-exit": 2,
"no-proto": 2,
"no-return-assign": 2,
"no-script-url": 2,
"no-sequences": 2,
"no-shadow": 2,
"no-shadow-restricted-names": 2,
"no-spaced-func": 2,
"no-trailing-spaces": 2,
"no-undef-init": 2,
"no-underscore-dangle": 2,
"no-unused-expressions": 2,
"no-use-before-define": 2,
"no-with": 2,
"quotes": [2, "double"],
"semi": 2,
"semi-spacing": [2, {"before": false, "after": true}],
"space-infix-ops": 2,
"keyword-spacing": 2,
"space-unary-ops": [2, { "words": true, "nonwords": false }],
"strict": [2, "function"],
"yoda": [2, "never"],

//
// Enabled over default
//
"valid-jsdoc": [1, {
"requireReturn": false,
"prefer": {
"return": "returns"
}
}],
"guard-for-in": 2,
"no-div-regex": 2,
"no-eq-null": 2,
"no-floating-decimal": 2,
"no-self-compare": 2,
"no-void": 2,
"radix": 2,
"wrap-iife": 2,
"no-mixed-requires": 2,
"no-new-require": 2,
"no-path-concat": 2,
"brace-style": [2, "1tbs", { "allowSingleLine": false }],
"comma-style": [2, "last"],
"consistent-this": [2, "that"],
"no-inline-comments": 2,
"no-multiple-empty-lines": [1, {"max": 1}],
"no-nested-ternary": 2,
"space-before-function-paren": [2, "never"],
"space-before-blocks": 1,
"space-in-parens": 1,
"spaced-comment": 1,
"max-len": [1, 120, 4],
"no-loop-func": 2

//
// Disabled
//
}
}
"extends": "nicjansma"
}
6 changes: 3 additions & 3 deletions gulpfile.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
(function(root) {
/* eslint-env node */
(function() {
"use strict";

//
Expand All @@ -9,7 +10,6 @@
var eslint = require("gulp-eslint");
var uglify = require("gulp-uglify");
var mocha = require("gulp-spawn-mocha");
var rename = require("gulp-rename");
var Server = require("karma").Server;
var path = require("path");
var bower = require("gulp-bower");
Expand Down Expand Up @@ -44,7 +44,7 @@
.pipe(eslint.format("checkstyle", fs.createWriteStream("eslint.xml")));
});

gulp.task("merge-json", function(cb) {
gulp.task("merge-json", function() {
return es.merge(
gulp.src("data/headers.json")
.pipe(mergeJson("headers.js", false, [], false, "var CdnDetectorHeaders"))
Expand Down
1 change: 1 addition & 0 deletions index.js
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
/* eslint-env commonjs */
module.exports = require("./src/cdn-detector");
1 change: 1 addition & 0 deletions karma.config.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-env commonjs */
module.exports = function(config) {
"use strict";

Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
"homepage": "https://github.com/nicjansma/cdn-detector.js/",
"devDependencies": {
"chai": "^3.5.0",
"eslint-config-nicjansma": "^1.0.2",
"event-stream": "^3.3.4",
"gulp": "^3.9.1",
"gulp-bower": "0.0.13",
Expand Down
27 changes: 15 additions & 12 deletions src/cdn-detector.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
//
// https://github.com/nicjansma/cdn-detector.js
//
/* eslint-env commonjs, browser, amd */
(function(window) {
"use strict";

Expand Down Expand Up @@ -157,19 +158,21 @@

// convert all incoming headers to lower case first
var lowerHeaders = {};
for (var header in headers) {
if (headers.hasOwnProperty(header)) {
lowerHeaders[header.toLowerCase()] = headers[header];
for (var headerName in headers) {
if (headers.hasOwnProperty(headerName)) {
lowerHeaders[headerName.toLowerCase()] = headers[headerName];
}
}

var i, data, cdn, match, matches;

// find any matching headers in our data
for (var i = 0; i < headersData.length; i++) {
var data = headersData[i];
for (i = 0; i < headersData.length; i++) {
data = headersData[i];

var header = data[0];
var match = data[1];
var cdn = data[2];
match = data[1];
cdn = data[2];

if (typeof lowerHeaders[header] === "string") {
// if there is no match string, we're good
Expand All @@ -183,18 +186,18 @@
}

// find any multi headers (multiple headers need to match)
for (var i = 0; i < multiHeadersData.length; i++) {
var data = multiHeadersData[i];
for (i = 0; i < multiHeadersData.length; i++) {
data = multiHeadersData[i];

var cdn = data[0];
var matches = data[1];
cdn = data[0];
matches = data[1];

var matchesAll = true;
var matchEvidence = [];

// loop through, looking to see if this request matches
// all headers in the set
for (var match in matches) {
for (match in matches) {
if (matches.hasOwnProperty(match)) {
var matchValue = matches[match];

Expand Down
2 changes: 1 addition & 1 deletion test/test.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* eslint-env node, mocha */
/* eslint-env node, mocha, browser */
(function(root) {
"use strict";

Expand Down

0 comments on commit 53eb84d

Please sign in to comment.