Skip to content

Commit

Permalink
- Fix eslint issues
Browse files Browse the repository at this point in the history
  • Loading branch information
svenkatreddy committed Nov 18, 2016
1 parent 530c698 commit 87aa296
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 46 deletions.
13 changes: 3 additions & 10 deletions .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,6 @@
"expect": true
},
"rules": {

Error: Parse error on line 9:
...}, "rules": { // Ignore Rules
---------------------^
Expecting 'STRING', '}'
// Ignore Rules
"strict": 0,
"no-underscore-dangle": 0,
"no-mixed-requires": 0,
Expand All @@ -31,11 +25,10 @@ Expecting 'STRING', '}'
// Errors
"no-undef": 2,
"no-dupe-keys": 2,
"no-empty-class": 2,
"no-empty-character-class": 2,
"no-self-compare": 2,
"valid-typeof": 2,
"no-unused-vars": 2,
"handle-callback-err": 2,
"no-shadow-restricted-names": 2,
"radix": 2,
"no-new-require": 2,
Expand All @@ -44,8 +37,8 @@ Expecting 'STRING', '}'
// stylistic errors
"new-cap": 2,
"no-spaced-func": 2,
"no-space-before-semi": 2,
"space-unary-word-ops": 2,
"semi-spacing": 2,
"space-unary-ops": 2,
"quotes": [2, "single"]
}
}
55 changes: 20 additions & 35 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@ var allLanguages = require('./data/languages.json');
var getSymbol = require('currency-symbol-map');


const searchObjectforString = (searchterm, data, property1, property2) => {
const searchItem = searchterm.toLowerCase();
let found = false;
var searchObjectforString = function (searchterm, data, property1, property2) {
var searchItem = searchterm.toLowerCase();
var found = false;
_.each(data, function (item) {
const match1 = item[property1] ? item[property1].toLowerCase() : '';
const match2 = item[property2] ? item[property2].toLowerCase() : '';
const statusCode = item.status || '';
var match1 = item[property1] ? item[property1].toLowerCase() : '';
var match2 = item[property2] ? item[property2].toLowerCase() : '';
var statusCode = item.status || '';

if( ((searchItem === match1) || (searchItem === match2)) && statusCode !== "deleted") {
if( ((searchItem === match1) || (searchItem === match2)) && statusCode !== 'deleted') {
found = item;
return false;
}
Expand All @@ -38,21 +38,6 @@ _.each(allCurrencies, function (currency) {
//exports.currencies[currency.code] = currency;
});

// Note that for the languages there are several entries with the same alpha3 -
// eg Dutch and Flemish. Not sure how to best deal with that - here whichever
// comes last wins.
_.each(allLanguages, function (language) {
//exports.languages[language.alpha2] = language;
//exports.languages[language.bibliographic] = language;
//exports.languages[language.alpha3] = language;
});

/*exports.lookup = lookup({
countries: allCountries,
currencies: allCurrencies,
languages: allLanguages
});*/

var callingCountries = {all: []};

var allCallingCodes = _.reduce(allCountries, function (codes, country) {
Expand All @@ -74,7 +59,7 @@ var allCallingCodes = _.reduce(allCountries, function (codes, country) {
delete callingCountries['']; // remove empty alpha3s

allCallingCodes.sort(function (a, b) {
var parse = function (str) { return parseInt(str) };
var parse = function (str) { return parseInt(str, 10) };
var splitA = _.map(a.split(' '), parse);
var splitB = _.map(b.split(' '), parse);

Expand All @@ -98,51 +83,51 @@ allCallingCodes.sort(function (a, b) {
}
});

const getAllCountries = () => {
var getAllCountries = function () {
return allCountries;
};

const getAllCurrencies = () => {
var getAllCurrencies = function () {
return allCurrencies;
};

const getAllLanguages = () => {
var getAllLanguages = function () {
return allLanguages;
};

const getAllCallingCodes = () => {
var getAllCallingCodes = function () {
return allCallingCodes;
};

const getAllCallingCountries = () => {
var getAllCallingCountries = function () {
return callingCountries;
};

const getAllRegions = () => {
var getAllRegions = function () {
return regions;
};

const getAllContinents = () => {
var getAllContinents = function () {
return continents;
};

const getCountryInfoByCode = (code) => {
var getCountryInfoByCode = function (code) {
return searchObjectforString(code, allCountries, 'alpha2', 'alpha3');
};

const getCountryInfoByName = (name) => {
var getCountryInfoByName = function (name) {
return searchObjectforString(name, allCountries, 'name');
};

const getCurrencyInfoByCode = (code) => {
var getCurrencyInfoByCode = function (code) {
return searchObjectforString(code, allCurrencies, 'code');
};

const getLanguageInfoByCode = (code) => {
var getLanguageInfoByCode = function (code) {
return searchObjectforString(code, allLanguages, 'alpha2', 'alpha3');
};

const getLanguageInfoByBibliographic = (code) => {
var getLanguageInfoByBibliographic = function (code) {
return searchObjectforString(code, allLanguages, 'bibliographic');
};

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
},
"main": "index.js",
"scripts": {
"test": "mocha test/*.js"
"test": "mocha"
},
"repository": {
"type": "git",
Expand Down

0 comments on commit 87aa296

Please sign in to comment.