@@ -90,9 +90,7 @@ function getTestFilePatterns() {
90
90
testTemplatesPath = "tests/templates/" ,
91
91
testBinPath = "tests/bin/" ;
92
92
93
- return ls ( testLibPath ) . filter ( function ( pathToCheck ) {
94
- return test ( "-d" , testLibPath + pathToCheck ) ;
95
- } ) . reduce ( function ( initialValue , currentValues ) {
93
+ return ls ( testLibPath ) . filter ( pathToCheck => test ( "-d" , testLibPath + pathToCheck ) ) . reduce ( ( initialValue , currentValues ) => {
96
94
if ( currentValues !== "rules" ) {
97
95
initialValue . push ( `"${ testLibPath + currentValues } /**/*.js"` ) ;
98
96
}
@@ -135,7 +133,7 @@ function generateRulesIndex(basedir) {
135
133
136
134
output += " var rules = Object.create(null);\n" ;
137
135
138
- find ( `${ basedir } rules/` ) . filter ( fileType ( "js" ) ) . forEach ( function ( filename ) {
136
+ find ( `${ basedir } rules/` ) . filter ( fileType ( "js" ) ) . forEach ( filename => {
139
137
const basename = path . basename ( filename , ".js" ) ;
140
138
141
139
output += ` rules["${ basename } "] = require("./rules/${ basename } ");\n` ;
@@ -204,7 +202,7 @@ function generateRuleIndexPage(basedir) {
204
202
categoryList = "conf/category-list.json" ,
205
203
categoriesData = JSON . parse ( cat ( path . resolve ( categoryList ) ) ) ;
206
204
207
- find ( path . join ( basedir , "/lib/rules/" ) ) . filter ( fileType ( "js" ) ) . forEach ( function ( filename ) {
205
+ find ( path . join ( basedir , "/lib/rules/" ) ) . filter ( fileType ( "js" ) ) . forEach ( filename => {
208
206
const rule = require ( filename ) ;
209
207
const basename = path . basename ( filename , ".js" ) ;
210
208
@@ -324,7 +322,7 @@ function getTagOfFirstOccurrence(filePath) {
324
322
let tags = execSilent ( `git tag --contains ${ firstCommit } ` ) ;
325
323
326
324
tags = splitCommandResultToLines ( tags ) ;
327
- return tags . reduce ( function ( list , version ) {
325
+ return tags . reduce ( ( list , version ) => {
328
326
version = semver . valid ( version . trim ( ) ) ;
329
327
if ( version ) {
330
328
list . push ( version ) ;
@@ -363,12 +361,8 @@ function getFirstVersionOfDeletion(filePath) {
363
361
tags = execSilent ( `git tag --contains ${ deletionCommit } ` ) ;
364
362
365
363
return splitCommandResultToLines ( tags )
366
- . map ( function ( version ) {
367
- return semver . valid ( version . trim ( ) ) ;
368
- } )
369
- . filter ( function ( version ) {
370
- return version ;
371
- } )
364
+ . map ( version => semver . valid ( version . trim ( ) ) )
365
+ . filter ( version => version )
372
366
. sort ( semver . compare ) [ 0 ] ;
373
367
}
374
368
@@ -476,7 +470,7 @@ function getFormatterResults() {
476
470
] . join ( "\n" ) ,
477
471
rawMessages = cli . executeOnText ( codeString , "fullOfProblems.js" , true ) ;
478
472
479
- return formatterFiles . reduce ( function ( data , filename ) {
473
+ return formatterFiles . reduce ( ( data , filename ) => {
480
474
const fileExt = path . extname ( filename ) ,
481
475
name = path . basename ( filename , fileExt ) ;
482
476
@@ -594,9 +588,7 @@ target.gensite = function(prereleaseVersion) {
594
588
595
589
// append version
596
590
if ( prereleaseVersion ) {
597
- docFiles = docFiles . map ( function ( docFile ) {
598
- return `/${ prereleaseVersion } ${ docFile } ` ;
599
- } ) ;
591
+ docFiles = docFiles . map ( docFile => `/${ prereleaseVersion } ${ docFile } ` ) ;
600
592
}
601
593
602
594
// 1. create temp and build directory
@@ -605,7 +597,7 @@ target.gensite = function(prereleaseVersion) {
605
597
}
606
598
607
599
// 2. remove old files from the site
608
- docFiles . forEach ( function ( filePath ) {
600
+ docFiles . forEach ( filePath => {
609
601
const fullPath = path . join ( DOCS_DIR , filePath ) ,
610
602
htmlFullPath = fullPath . replace ( ".md" , ".html" ) ;
611
603
@@ -632,7 +624,7 @@ target.gensite = function(prereleaseVersion) {
632
624
}
633
625
634
626
// 4. Loop through all files in temporary directory
635
- find ( TEMP_DIR ) . forEach ( function ( filename ) {
627
+ find ( TEMP_DIR ) . forEach ( filename => {
636
628
if ( test ( "-f" , filename ) && path . extname ( filename ) === ".md" ) {
637
629
638
630
const rulesUrl = "https://github.com/eslint/eslint/tree/master/lib/rules/" ,
@@ -763,7 +755,7 @@ target.checkRuleFiles = function() {
763
755
const ruleFiles = find ( "lib/rules/" ) . filter ( fileType ( "js" ) ) ;
764
756
let errors = 0 ;
765
757
766
- ruleFiles . forEach ( function ( filename ) {
758
+ ruleFiles . forEach ( filename => {
767
759
const basename = path . basename ( filename , ".js" ) ;
768
760
const docFilename = `docs/rules/${ basename } .md` ;
769
761
@@ -838,35 +830,27 @@ target.checkLicenses = function() {
838
830
const licenses = dependency . licenses ;
839
831
840
832
if ( Array . isArray ( licenses ) ) {
841
- return licenses . some ( function ( license ) {
842
- return isPermissible ( {
843
- name : dependency . name ,
844
- licenses : license
845
- } ) ;
846
- } ) ;
833
+ return licenses . some ( license => isPermissible ( {
834
+ name : dependency . name ,
835
+ licenses : license
836
+ } ) ) ;
847
837
}
848
838
849
- return OPEN_SOURCE_LICENSES . some ( function ( license ) {
850
- return license . test ( licenses ) ;
851
- } ) ;
839
+ return OPEN_SOURCE_LICENSES . some ( license => license . test ( licenses ) ) ;
852
840
}
853
841
854
842
echo ( "Validating licenses" ) ;
855
843
856
844
checker . init ( {
857
845
start : __dirname
858
- } , function ( deps ) {
859
- const impermissible = Object . keys ( deps ) . map ( function ( dependency ) {
860
- return {
861
- name : dependency ,
862
- licenses : deps [ dependency ] . licenses
863
- } ;
864
- } ) . filter ( function ( dependency ) {
865
- return ! isPermissible ( dependency ) ;
866
- } ) ;
846
+ } , deps => {
847
+ const impermissible = Object . keys ( deps ) . map ( dependency => ( {
848
+ name : dependency ,
849
+ licenses : deps [ dependency ] . licenses
850
+ } ) ) . filter ( dependency => ! isPermissible ( dependency ) ) ;
867
851
868
852
if ( impermissible . length ) {
869
- impermissible . forEach ( function ( dependency ) {
853
+ impermissible . forEach ( dependency => {
870
854
console . error ( "%s license for %s is impermissible." ,
871
855
dependency . licenses ,
872
856
dependency . name
@@ -960,9 +944,7 @@ function createConfigForPerformanceTest() {
960
944
961
945
content . push . apply (
962
946
content ,
963
- ls ( "lib/rules" ) . map ( function ( fileName ) {
964
- return ` ${ path . basename ( fileName , ".js" ) } : 1` ;
965
- } )
947
+ ls ( "lib/rules" ) . map ( fileName => ` ${ path . basename ( fileName , ".js" ) } : 1` )
966
948
) ;
967
949
968
950
content . join ( "\n" ) . to ( PERF_ESLINTRC ) ;
@@ -981,7 +963,7 @@ function createConfigForPerformanceTest() {
981
963
function time ( cmd , runs , runNumber , results , cb ) {
982
964
const start = process . hrtime ( ) ;
983
965
984
- exec ( cmd , { silent : true } , function ( code , stdout , stderr ) {
966
+ exec ( cmd , { silent : true } , ( code , stdout , stderr ) => {
985
967
const diff = process . hrtime ( start ) ,
986
968
actual = ( diff [ 0 ] * 1e3 + diff [ 1 ] / 1e6 ) ; // ms
987
969
@@ -1026,14 +1008,12 @@ function runPerformanceTest(title, targets, multiplier, cb) {
1026
1008
echo ( title ) ;
1027
1009
echo ( " CPU Speed is %d with multiplier %d" , cpuSpeed , multiplier ) ;
1028
1010
1029
- time ( cmd , 5 , 1 , [ ] , function ( results ) {
1011
+ time ( cmd , 5 , 1 , [ ] , results => {
1030
1012
if ( ! results || results . length === 0 ) { // No results? Something is wrong.
1031
1013
throw new Error ( "Performance test failed." ) ;
1032
1014
}
1033
1015
1034
- results . sort ( function ( a , b ) {
1035
- return a - b ;
1036
- } ) ;
1016
+ results . sort ( ( a , b ) => a - b ) ;
1037
1017
1038
1018
const median = results [ ~ ~ ( results . length / 2 ) ] ;
1039
1019
@@ -1068,9 +1048,7 @@ function loadPerformance() {
1068
1048
results . push ( loadPerfData . loadTime ) ;
1069
1049
}
1070
1050
1071
- results . sort ( function ( a , b ) {
1072
- return a - b ;
1073
- } ) ;
1051
+ results . sort ( ( a , b ) => a - b ) ;
1074
1052
const median = results [ ~ ~ ( results . length / 2 ) ] ;
1075
1053
1076
1054
echo ( "" ) ;
@@ -1079,7 +1057,7 @@ function loadPerformance() {
1079
1057
}
1080
1058
1081
1059
target . perf = function ( ) {
1082
- downloadMultifilesTestTarget ( function ( ) {
1060
+ downloadMultifilesTestTarget ( ( ) => {
1083
1061
createConfigForPerformanceTest ( ) ;
1084
1062
1085
1063
loadPerformance ( ) ;
@@ -1088,7 +1066,7 @@ target.perf = function() {
1088
1066
"Single File:" ,
1089
1067
"tests/performance/jshint.js" ,
1090
1068
PERF_MULTIPLIER ,
1091
- function ( ) {
1069
+ ( ) => {
1092
1070
1093
1071
// Count test target files.
1094
1072
const count = glob . sync (
@@ -1101,7 +1079,7 @@ target.perf = function() {
1101
1079
`Multi Files (${ count } files):` ,
1102
1080
PERF_MULTIFILES_TARGETS ,
1103
1081
3 * PERF_MULTIPLIER ,
1104
- function ( ) { }
1082
+ ( ) => { }
1105
1083
) ;
1106
1084
}
1107
1085
) ;
0 commit comments