klei / gulp-angular-filesort

Automatically sort AngularJS app files depending on module definitions and usage
MIT License
132 stars 46 forks source link

arrow functions failing to be parsed correctly #49

Open end-user opened 8 years ago

end-user commented 8 years ago

If I use an arrow function in my js file, gulp-angular-filesort is throwing an error (e.g. "Error in parsing: "expert\controllers\ExpertViewController.js", Line 14: Unexpected token =>")

cathrinevaage commented 8 years ago

Hardly any ES6 is supported I believe. A workaround is to run the stream through babel before sorting it.

Make sure you have babel-preset-es2015 installed, and pipe the stream to gulp-babel like so

.pipe(babel({ presets: ['es2015'] }))
.pipe(angularFilesort())
caffed commented 8 years ago

I believe it's the outdated version of ng-dependencies@0.3.0 it's using.

gulp
  .src('./**/*.js')
  .pipe(angularFilesort())
  .on('error', gutil.log)

[DATESTAMP] { [Error: Error in parsing: "FILE", Line NUMBER: Unexpected token =>]
  message: 'Error in parsing: "FILE", Line NUMBER: Unexpected token =>',
  showStack: false,
  showProperties: true,
  plugin: 'gulp-angular-filesort',
  __safety: { toString: [Function: bound ] } }

This error is not present if I change the ng-dependencies version in ./node_modules/gulp-angular-filesort/package.json to 0.5.0.

Seems like overkill to babelify when it really only needs to parse the angular.module('name', [deps]) portion.

Were there any changes to ng-dependencies@0.5.0 in regard to AST building?

voltuer commented 6 years ago

this project is definitely abandoned, time for a fork i guess

bbspearo12 commented 6 years ago

So is streaming through babel the only work around for now?