Giter VIP home page Giter VIP logo

Comments (8)

jprichardson avatar jprichardson commented on May 21, 2024

The solution is to just do this:

/* global beforeEach, describe, it */

See this for an example: https://github.com/jprichardson/node-cfs/blob/master/test.js

from standard.

brandonhorst avatar brandonhorst commented on May 21, 2024

I understand that. As I mentioned, /*eslint-env mocha */ does the same thing. I just don't want to have to put that directive.

My enhancement request for standard to handle it automatically.

from standard.

yoshuawuyts avatar yoshuawuyts commented on May 21, 2024

With mocha you can't do:

$ node test.js

To me it feels that standard should catch this and warn about non standard globals being used.

from standard.

dcousens avatar dcousens commented on May 21, 2024

My enhancement request for standard to handle it automatically.

How would you recommend we do that?

To me it feels that standard should catch this and warn about non standard globals being used.

There is no difference between a non-standard global and a undefined variable.

from standard.

brandonhorst avatar brandonhorst commented on May 21, 2024

Here is some weird pseudocode.

var info = findup package.json
var environment = 'node browser'
if dependencies contains 'mocha' { environment += ' mocha'}
if dependencies contains 'jasmine' { environment += ' jasmine'}
for file in (info.directories.test || './test' exists || './spec' exists) {
    lint with environment
}
for other files {lint with environment = 'node browser'}

findup

I fully understand that these globals are nonstandard/undefined (and it's kind of weird that mocha/jasmine /etc are implemented this way, frankly). But standard could be smart enough to handle them.

from standard.

jprichardson avatar jprichardson commented on May 21, 2024

You're right, it could. But I think it's more a question of "should". The
thing is, that in the context of style (standard), when looking at a source
file, you shouldn't have to depend upon another file like package.json to
communicate additional information. Also, It opens up a gray area... where
does one draw the line? Yeah, mocha and jasmine are popular now, but what
if another tool comes along and introduces its own set of globals? When
looking at a source file, if one just declares their globals in a comment,
that's good enough, as all of the information is contained in that one
single file.

On Wednesday, February 4, 2015, Brandon Horst [email protected]
wrote:

Here is some weird pseudocode.

var info = findup package.json
var environment = 'node browser'
if dependencies contains 'mocha' { environment += ' mocha'}
if dependencies contains 'jasmine' { environment += ' jasmine'}
for file in (info.directories.test || './test' exists || './spec' exists) {
lint with environment
}
for other files {lint with environment = 'node browser'}

findup https://www.npmjs.com/package/findup

I fully understand that these globals are nonstandard/undefined (and it's
kind of weird that mocha/jasmine /etc are implemented this way, frankly).
But standard could be smart enough to handle them.


Reply to this email directly or view it on GitHub
#18 (comment).

Simple & Secure Bitcoin Wallet: https://www.coinbolt.com
Bitcoin / JavaScript: http://cryptocoinjs.com
Follow me on Twitter: http://twitter.com/jprichardson

from standard.

 avatar commented on May 21, 2024

@jprichardson couldn't agree more.

from standard.

feross avatar feross commented on May 21, 2024

Closing this for now, as the consensus seems to be that it's simplest to have mocha users just define globals in a comment.

from standard.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.