File tree Expand file tree Collapse file tree 3 files changed +6
-7
lines changed Expand file tree Collapse file tree 3 files changed +6
-7
lines changed Original file line number Diff line number Diff line change @@ -17,6 +17,7 @@ This change log adheres to standards from [Keep a CHANGELOG](https://keepachange
1717- [ Docs] [ ` no-duplicates ` ] : fix example schema ([ #2684 ] , thanks [ @simmo ] )
1818- [ Docs] [ ` group-exports ` ] : fix syntax highlighting ([ #2699 ] , thanks [ @devinrhode2 ] )
1919- [ Docs] [ ` extensions ` ] : reference node ESM behavior ([ #2748 ] , thanks [ @xM8WVqaG ] )
20+ - [ Refactor] [ ` exports-last ` ] : use ` array.prototype.findlastindex ` (thanks [ @ljharb ] )
2021
2122## [ 2.27.5] - 2023-01-16
2223
Original file line number Diff line number Diff line change 102102 },
103103 "dependencies" : {
104104 "array-includes" : " ^3.1.6" ,
105+ "array.prototype.findlastindex" : " ^1.2.2" ,
105106 "array.prototype.flat" : " ^1.3.1" ,
106107 "array.prototype.flatmap" : " ^1.3.1" ,
107108 "debug" : " ^3.2.7" ,
Original file line number Diff line number Diff line change 1+ import findLastIndex from 'array.prototype.findlastindex' ;
2+
13import docsUrl from '../docsUrl' ;
24
35function isNonExportStatement ( { type } ) {
@@ -20,15 +22,10 @@ module.exports = {
2022 create ( context ) {
2123 return {
2224 Program ( { body } ) {
23- const lastNonExportStatementIndex = body . reduce ( function findLastIndex ( acc , item , index ) {
24- if ( isNonExportStatement ( item ) ) {
25- return index ;
26- }
27- return acc ;
28- } , - 1 ) ;
25+ const lastNonExportStatementIndex = findLastIndex ( body , isNonExportStatement ) ;
2926
3027 if ( lastNonExportStatementIndex !== - 1 ) {
31- body . slice ( 0 , lastNonExportStatementIndex ) . forEach ( function checkNonExport ( node ) {
28+ body . slice ( 0 , lastNonExportStatementIndex ) . forEach ( ( node ) => {
3229 if ( ! isNonExportStatement ( node ) ) {
3330 context . report ( {
3431 node,
You can’t perform that action at this time.
0 commit comments