Skip to content
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

How do you use Standard with modules? #634

Closed
izolate opened this issue Sep 19, 2016 · 3 comments

Comments

@izolate
Copy link

commented Sep 19, 2016

I'm stuck in a catch 22 situation trying to verify all internal code adheres to Standard. For example:

📄 app.js

const external = require('some-npm-module')
const internal = require('./some/local/module')
// ...

Standard checks app.js, but not ./some/local/module.js.

Solution? Perhaps by using Browserify/Gulp:

📄 gulpfile.js

const gulp = require('gulp')
const standard = require('gulp-standard')

gulp.task('scripts', function () {
  return browserify('/path/to/app.js')
    .transform(require('babelify'))
    .bundle()
    .pipe(require('vinyl-source-stream')('app.compiled.js'))
    .pipe(require('vinyl-buffer')())
    .pipe(standard())
    .pipe(standard.reporter('default', opts)
    .pipe(gulp.dest('/path/to/dest'))
})

Now this task executes standard on the complete bundle, which (rightfully) includes the internal module, but also (wrongly) includes the external npm module too. If any npm module NOT written in standard (most) is included in the bundle, the task will fail.

Any solutions around this?

@dcousens

This comment has been minimized.

Copy link
Member

commented Sep 19, 2016

$ mkdir test
$ cd test/
$ mkdir some
$ mkdir some/local
$ echo "var a, b;" > some/local/module.js
$ standard
standard: Use JavaScript Standard Style (http://standardjs.com)
standard: Run `standard --fix` to automatically fix some problems.
  ./test/some/local/module.js:1:5: 'a' is defined but never used.
  ./test/some/local/module.js:1:8: 'b' is defined but never used.
  ./test/some/local/module.js:1:9: Extra semicolon.

Whats up?

edit: didn't mean to close yet

@dcousens dcousens closed this Sep 19, 2016

@dcousens dcousens reopened this Sep 19, 2016

@dcousens dcousens added the question label Sep 19, 2016

@izolate

This comment has been minimized.

Copy link
Author

commented Sep 19, 2016

Okay, my bad. I was using standard as so:

standard app.js

Standard is recursive by default then? Cheers @dcousens

@izolate izolate closed this Sep 19, 2016

@dcousens

This comment has been minimized.

Copy link
Member

commented Sep 19, 2016

Indeed, with some smarts to avoid node_modules and other things by default too.

@lock lock bot locked as resolved and limited conversation to collaborators May 10, 2018

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
2 participants
You can’t perform that action at this time.