Skip to content
This repository has been archived by the owner on Aug 30, 2021. It is now read-only.

fix(eslint): Inconsistent spacing before function parentheses #1844

Merged
merged 1 commit into from
Aug 14, 2017

Conversation

simison
Copy link
Member

@simison simison commented Aug 14, 2017

Defines space-before-function-paren eslint rule and changes files accordingly.

Resolves #1605

@simison simison self-assigned this Aug 14, 2017
@simison simison force-pushed the eslint-space-before-function-paren branch from d49b4ce to 208f723 Compare August 14, 2017 08:37
Defines `space-before-function-paren` eslint rule and changes files accordingly.
Copy link
Member

@mleanos mleanos left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Thanks @simison. I tried using eslint --fix locally, and ran into issues. Must be an environment issue on my end.

@mleanos
Copy link
Member

mleanos commented Aug 14, 2017

Coverage increased.. smh 😃

@simison
Copy link
Member Author

simison commented Aug 14, 2017

Yeah I was lazy to figure out how to configure eslint -fix to catch correct config files and read correct directories/files, but I wrote a quick gulp task instead. ;-) Essentially just fix:true option in our eslint task + some small fiddling to get it save changes over old files.

@simison simison merged commit f44c9bc into meanjs:master Aug 14, 2017
@simison simison deleted the eslint-space-before-function-paren branch August 14, 2017 20:50
@mleanos
Copy link
Member

mleanos commented Aug 14, 2017

Would you like to share you Gulp task? I thought about doing the same yesterday :)

@simison
Copy link
Member Author

simison commented Aug 14, 2017

@mleanos sure :-)

gulp.task('eslint-and-fix', function () {

  var gulpIf = require('gulp-if');
  var fs = require('fs');

  function saveFixedFile(file) {
    // Has ESLint fixed the file contents?
    if (file.eslint != null && file.eslint.fixed) {
      // Write file over with new fixed contents
      fs.writeFile(file.eslint.filePath, file.eslint.output, function(err) {
        if (err) {
          return console.log(err);
        }
      });
    }
  }

  var assets = _.union(
    defaultAssets.server.gulpConfig,
    defaultAssets.server.allJS,
    defaultAssets.client.js,
    testAssets.tests.server,
    testAssets.tests.client,
    testAssets.tests.e2e
  );

  return gulp.src(assets)
    .pipe(plugins.eslint({
      fix: true
    }))
    .pipe(plugins.eslint.format())
    // if fixed, write the file to dest
    .pipe(gulpIf(saveFixedFile, gulp.dest('./data/fixed')));
});

It's uggly, as I didn't figure out why gulp.dest didn't work (it would just spat files all over, now I just dump them to ./data/fixed which is gitignored). But whatever, it was just for one time use.

Remember to npm i gulp-if

Here's the original https://github.com/adametry/gulp-eslint/blob/master/example/fix.js

cicorias pushed a commit to JavaScriptExpert/mean that referenced this pull request Sep 12, 2017
…#1844)

Defines `space-before-function-paren` eslint rule and changes files accordingly.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants