Skip to content

Indented multi-line arguments followed by indented chained function calls cause functions further down to be interpreted to end earlier than it should if those functions contain indented multi-line arguments #3866

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
cheapsteak opened this issue Feb 19, 2015 · 2 comments
Labels

Comments

@cheapsteak
Copy link

input:

gulp.task 'styles', ->
  styles = gulp
    .src paths.styles.source
    .pipe stylus
      'include css': true
    .on 'error', handleError

  styles = styles.pipe(CSSmin()) if production

desired output:

gulp.task('styles', function() {
  var styles;
  styles = gulp.src(paths.styles.source).pipe(sourcemaps.init()).pipe(stylus({
    'include css': true
  })).on('error', handleError);
  if (production) {
    return styles = styles.pipe(CSSmin());
  }
});

Adding this at the top of the file causes the function for the gulp task to end early:
input:

obj = _({})
  .extend thingWithReallyLongName,
    thingWithReallyLongName,
    thingWithReallyLongName
  .value()

gulp.task 'styles', ->
  styles = gulp
    .src paths.styles.source
    .pipe stylus
      'include css': true
    .on 'error', handleError

  styles = styles.pipe(CSSmin()) if production

output:

var obj, styles;

obj = _({}).extend(thingWithReallyLongName, thingWithReallyLongName, thingWithReallyLongName).value();

gulp.task('styles', function() {
  var styles;
  return styles = gulp.src(paths.styles.source).pipe(stylus({
    'include css': true
  })).on('error', handleError);
});

if (production) {
  styles = styles.pipe(CSSmin());
}

The if (production) block should be inside of the function above it.


Wrapping parens around either of the indented arguments fixes it.

e.g.

.pipe stylus('include css': true)

OR

obj = _({})
  .extend(thingWithReallyLongName,
    thingWithReallyLongName,
    thingWithReallyLongName)
  .value()

Both result in the desired output again.


It's also fixed if the last chained call after extend is not indented.

obj = _({})
  .extend thingWithReallyLongName,
    thingWithReallyLongName,
    thingWithReallyLongName
.value()

Removing the indentation before .value() also results in desired output.

@xixixao
Copy link
Contributor

xixixao commented May 1, 2017

This is most likely a dupe of #3484.

@GeoffreyBooth
Copy link
Collaborator

Looks like this is fixed in b28e398:

gulp.task('styles', function() {
  var styles;
  styles = gulp.src(paths.styles.source).pipe(stylus({
    'include css': true
  })).on('error', handleError);
  if (production) {
    return styles = styles.pipe(CSSmin());
  }
});

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants