diff --git a/.jshintrc b/.jshintrc index 24d2c33e..e5c5749e 100644 --- a/.jshintrc +++ b/.jshintrc @@ -13,8 +13,10 @@ "nonbsp": true, "nonew": true, "plusplus": false, + "quotmark": "single", "undef": true, "unused": false, "maxparams": 4, - "maxdepth": 4 + "maxdepth": 4, + "maxlen": 140 } diff --git a/integration/analyzer_peliasHousenumber.js b/integration/analyzer_peliasHousenumber.js index 7c9fdc82..e07ad1b1 100644 --- a/integration/analyzer_peliasHousenumber.js +++ b/integration/analyzer_peliasHousenumber.js @@ -48,4 +48,4 @@ module.exports.all = function (tape, common) { for( var testCase in module.exports.tests ){ module.exports.tests[testCase](test, common); } -}; \ No newline at end of file +}; diff --git a/integration/analyzer_peliasIndexOneEdgeGram.js b/integration/analyzer_peliasIndexOneEdgeGram.js index 71e8e568..39fe87b5 100644 --- a/integration/analyzer_peliasIndexOneEdgeGram.js +++ b/integration/analyzer_peliasIndexOneEdgeGram.js @@ -172,17 +172,17 @@ module.exports.tests.unicode = function(test, common){ // Chambéry (both forms appear the same) var composed = "Chamb" + latin_small_letter_e_with_acute + "ry"; - var decomposed = "Chamb" + combining_acute_accent + latin_small_letter_e + "ry" + var decomposed = "Chamb" + combining_acute_accent + latin_small_letter_e + "ry"; assertAnalysis( 'composed', composed, ['c', 'ch', 'cha', 'cham', 'chamb', 'chambe', 'chamber', 'chambery'] ); assertAnalysis( 'decomposed', decomposed, ['c', 'ch', 'cha', 'cham', 'chamb', 'chambe', 'chamber', 'chambery'] ); // Één (both forms appear the same) - var composed = latin_large_letter_e_with_acute + latin_small_letter_e_with_acute + "n"; - var decomposed = combining_acute_accent + latin_large_letter_e + combining_acute_accent + latin_small_letter_e + "n" + var composed2 = latin_large_letter_e_with_acute + latin_small_letter_e_with_acute + "n"; + var decomposed2 = combining_acute_accent + latin_large_letter_e + combining_acute_accent + latin_small_letter_e + "n"; - assertAnalysis( 'composed', composed, ['e','ee','een'] ); - assertAnalysis( 'decomposed', decomposed, ['e','ee','een'] ); + assertAnalysis( 'composed', composed2, ['e','ee','een'] ); + assertAnalysis( 'decomposed', decomposed2, ['e','ee','een'] ); suite.run( t.end ); }); diff --git a/integration/analyzer_peliasPhrase.js b/integration/analyzer_peliasPhrase.js index 2e1d01d9..799080ce 100644 --- a/integration/analyzer_peliasPhrase.js +++ b/integration/analyzer_peliasPhrase.js @@ -301,17 +301,17 @@ module.exports.tests.unicode = function(test, common){ // Chambéry (both forms appear the same) var composed = "Chamb" + latin_small_letter_e_with_acute + "ry"; - var decomposed = "Chamb" + combining_acute_accent + latin_small_letter_e + "ry" + var decomposed = "Chamb" + combining_acute_accent + latin_small_letter_e + "ry"; assertAnalysis( 'composed', composed, ['chambery'] ); assertAnalysis( 'decomposed', decomposed, ['chambery'] ); // Één (both forms appear the same) - var composed = latin_large_letter_e_with_acute + latin_small_letter_e_with_acute + "n"; - var decomposed = combining_acute_accent + latin_large_letter_e + combining_acute_accent + latin_small_letter_e + "n" + var composed2 = latin_large_letter_e_with_acute + latin_small_letter_e_with_acute + "n"; + var decomposed2 = combining_acute_accent + latin_large_letter_e + combining_acute_accent + latin_small_letter_e + "n"; - assertAnalysis( 'composed', composed, ['een'] ); - assertAnalysis( 'decomposed', decomposed, ['een'] ); + assertAnalysis( 'composed', composed2, ['een'] ); + assertAnalysis( 'decomposed', decomposed2, ['een'] ); suite.run( t.end ); }); diff --git a/integration/analyzer_peliasQueryFullToken.js b/integration/analyzer_peliasQueryFullToken.js index 52c9853d..e9624543 100644 --- a/integration/analyzer_peliasQueryFullToken.js +++ b/integration/analyzer_peliasQueryFullToken.js @@ -214,18 +214,18 @@ module.exports.tests.unicode = function(test, common){ var latin_small_letter_e = String.fromCodePoint(0x0065); // Chambéry (both forms appear the same) - var composed = "Chamb" + latin_small_letter_e_with_acute + "ry"; - var decomposed = "Chamb" + combining_acute_accent + latin_small_letter_e + "ry" + var chambery_composed = "Chamb" + latin_small_letter_e_with_acute + "ry"; + var chambery_decomposed = "Chamb" + combining_acute_accent + latin_small_letter_e + "ry"; - assertAnalysis( 'composed', composed, ['chambery'] ); - assertAnalysis( 'decomposed', decomposed, ['chambery'] ); + assertAnalysis( 'composed', chambery_composed, ['chambery'] ); + assertAnalysis( 'decomposed', chambery_decomposed, ['chambery'] ); // Één (both forms appear the same) - var composed = latin_large_letter_e_with_acute + latin_small_letter_e_with_acute + "n"; - var decomposed = combining_acute_accent + latin_large_letter_e + combining_acute_accent + latin_small_letter_e + "n" + var een_composed = latin_large_letter_e_with_acute + latin_small_letter_e_with_acute + "n"; + var een_decomposed = combining_acute_accent + latin_large_letter_e + combining_acute_accent + latin_small_letter_e + "n"; - assertAnalysis( 'composed', composed, ['een'] ); - assertAnalysis( 'decomposed', decomposed, ['een'] ); + assertAnalysis( 'composed', een_composed, ['een'] ); + assertAnalysis( 'decomposed', een_decomposed, ['een'] ); suite.run( t.end ); }); diff --git a/integration/analyzer_peliasQueryPartialToken.js b/integration/analyzer_peliasQueryPartialToken.js index d5afd109..8438adcf 100644 --- a/integration/analyzer_peliasQueryPartialToken.js +++ b/integration/analyzer_peliasQueryPartialToken.js @@ -136,18 +136,18 @@ module.exports.tests.unicode = function(test, common){ var latin_small_letter_e = String.fromCodePoint(0x0065); // Chambéry (both forms appear the same) - var composed = "Chamb" + latin_small_letter_e_with_acute + "ry"; - var decomposed = "Chamb" + combining_acute_accent + latin_small_letter_e + "ry" + var chambery_composed = "Chamb" + latin_small_letter_e_with_acute + "ry"; + var chambery_decomposed = "Chamb" + combining_acute_accent + latin_small_letter_e + "ry"; - assertAnalysis( 'composed', composed, ['chambery'] ); - assertAnalysis( 'decomposed', decomposed, ['chambery'] ); + assertAnalysis( 'composed', chambery_composed, ['chambery'] ); + assertAnalysis( 'decomposed', chambery_decomposed, ['chambery'] ); // Één (both forms appear the same) - var composed = latin_large_letter_e_with_acute + latin_small_letter_e_with_acute + "n"; - var decomposed = combining_acute_accent + latin_large_letter_e + combining_acute_accent + latin_small_letter_e + "n" + var een_composed = latin_large_letter_e_with_acute + latin_small_letter_e_with_acute + "n"; + var een_decomposed = combining_acute_accent + latin_large_letter_e + combining_acute_accent + latin_small_letter_e + "n"; - assertAnalysis( 'composed', composed, ['een'] ); - assertAnalysis( 'decomposed', decomposed, ['een'] ); + assertAnalysis( 'composed', een_composed, ['een'] ); + assertAnalysis( 'decomposed', een_decomposed, ['een'] ); suite.run( t.end ); }); diff --git a/integration/analyzer_peliasStreet.js b/integration/analyzer_peliasStreet.js index 1ab89f14..b5924b4f 100644 --- a/integration/analyzer_peliasStreet.js +++ b/integration/analyzer_peliasStreet.js @@ -179,18 +179,18 @@ module.exports.tests.unicode = function(test, common){ var latin_small_letter_e = String.fromCodePoint(0x0065); // Chambéry (both forms appear the same) - var composed = "Chamb" + latin_small_letter_e_with_acute + "ry"; - var decomposed = "Chamb" + combining_acute_accent + latin_small_letter_e + "ry" + var chambery_composed = "Chamb" + latin_small_letter_e_with_acute + "ry"; + var chambery_decomposed = "Chamb" + combining_acute_accent + latin_small_letter_e + "ry"; - assertAnalysis( 'composed', composed, ['chambery'] ); - assertAnalysis( 'decomposed', decomposed, ['chambery'] ); + assertAnalysis( 'composed', chambery_composed, ['chambery'] ); + assertAnalysis( 'decomposed', chambery_decomposed, ['chambery'] ); // Één (both forms appear the same) - var composed = latin_large_letter_e_with_acute + latin_small_letter_e_with_acute + "n"; - var decomposed = combining_acute_accent + latin_large_letter_e + combining_acute_accent + latin_small_letter_e + "n" + var een_composed = latin_large_letter_e_with_acute + latin_small_letter_e_with_acute + "n"; + var een_decomposed = combining_acute_accent + latin_large_letter_e + combining_acute_accent + latin_small_letter_e + "n"; - assertAnalysis( 'composed', composed, ['een'] ); - assertAnalysis( 'decomposed', decomposed, ['een'] ); + assertAnalysis( 'composed', een_composed, ['een'] ); + assertAnalysis( 'decomposed', een_decomposed, ['een'] ); suite.run( t.end ); }); diff --git a/scripts/check_plugins.js b/scripts/check_plugins.js index 3ce64a44..0f323e8c 100644 --- a/scripts/check_plugins.js +++ b/scripts/check_plugins.js @@ -58,7 +58,7 @@ client.nodes.info( null, function( err, res ){ // bool, is the plugin currently installed? const isInstalled = !!node.plugins.filter( function( installedPlugin ){ - return installedPlugin.name == plugin; + return installedPlugin.name === plugin; }).length; // output status to terminal @@ -87,7 +87,7 @@ client.nodes.info( null, function( err, res ){ }); }); console.error( colors.white("\nnote:") + "some plugins may require you to restart elasticsearch.\n"); - process.exit(1) + process.exit(1); } console.log(); diff --git a/scripts/cli.js b/scripts/cli.js index 086f10b7..a2016cf2 100644 --- a/scripts/cli.js +++ b/scripts/cli.js @@ -4,4 +4,4 @@ var util = require('util'); module.exports.header = function( text ){ var rule = new Array( text.length + 3 ).join("-"); console.log( util.format("\n\033[0;33m%s\n %s \n%s\033[0m\n", rule, text, rule ) ); -} +}; diff --git a/scripts/drop_index.js b/scripts/drop_index.js index b0dbd75b..2b88777d 100644 --- a/scripts/drop_index.js +++ b/scripts/drop_index.js @@ -7,8 +7,11 @@ var readline = require('readline'), schema = require('../schema'); // use -f or --force-yes to skip the prompt -if( isForced() ) drop(); -else prompt( drop, fail ); +if( isForced() ) { + drop(); +} else { + prompt( drop, fail ); +} function drop(){ client.indices.delete( { index: config.schema.indexName }, function( err, res ){ @@ -28,7 +31,9 @@ function warnIfNotLocal() { function prompt( yes, no ){ warnIfNotLocal(); rl.question( 'Are you sure you want to drop the ' + config.schema.indexName + ' index and delete ALL records? ', function( answer ){ - if( !answer.match(/^y(es)?$/i) ) return no(); + if( !answer.match(/^y(es)?$/i) ) { + return no(); + } return yes(); }); } diff --git a/test/document.js b/test/document.js index c904ea29..71aff90f 100644 --- a/test/document.js +++ b/test/document.js @@ -137,12 +137,12 @@ module.exports.tests.parent_analysis = function(test, common) { }); test('postalcode', function(t) { - t.equal(prop['postalcode'].type, 'string'); - t.equal(prop['postalcode'].analyzer, 'peliasZip'); - t.equal(prop['postalcode'+'_a'].type, 'string'); - t.equal(prop['postalcode'+'_a'].analyzer, 'peliasZip'); - t.equal(prop['postalcode'+'_id'].type, 'string'); - t.equal(prop['postalcode'+'_id'].index, 'not_analyzed'); + t.equal(prop.postalcode.type, 'string'); + t.equal(prop.postalcode.analyzer, 'peliasZip'); + t.equal(prop.postalcode_a.type, 'string'); + t.equal(prop.postalcode_a.analyzer, 'peliasZip'); + t.equal(prop.postalcode_id.type, 'string'); + t.equal(prop.postalcode_id.index, 'not_analyzed'); t.end(); }); diff --git a/test/settings.js b/test/settings.js index 70453019..a0108fec 100644 --- a/test/settings.js +++ b/test/settings.js @@ -443,17 +443,17 @@ module.exports.tests.overrides = function(test, common) { test('override defaults', function(t) { var s = settings(); - t.equal(s.index['number_of_replicas'], '0', 'unchanged'); + t.equal(s.index.number_of_replicas, '0', 'unchanged'); // set the PELIAS_CONFIG env var - process.env['PELIAS_CONFIG'] = path.resolve( __dirname + '/fixtures/config.json' ); + process.env.PELIAS_CONFIG = path.resolve( __dirname + '/fixtures/config.json' ); s = settings(); - t.equal(s.index['number_of_replicas'], '999', 'changed'); + t.equal(s.index.number_of_replicas, '999', 'changed'); t.end(); // unset the PELIAS_CONFIG env var - delete process.env['PELIAS_CONFIG']; + delete process.env.PELIAS_CONFIG; }); };