Comments (8)
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.
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.
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.
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.
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'}
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.
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.
@jprichardson couldn't agree more.
from standard.
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)
- Fix "promise-function-async" will cause an error
- Formatting code will make it unreadable
- Expanding Rostislav and I's contribution, into core
- TS-Standart Changed My Code and Throwing Error
- Create a tutorial to use Standard together with Husky
- Eslint v9 support HOT 2
- Add a lock file HOT 3
- Could you please paste the result of the `npm ls eslint` command? HOT 1
- Remove the lock-threads workflow
- Comments bring issues/PRs onto the project board HOT 1
- tittle
- space-unary-ops errors on `new Class()` syntax HOT 4
- Maintenance & Governance of standard HOT 47
- Format using a formatter instead of ESLint formatting rules HOT 15
- inline link with @ in Super to have link inline or below not above HOT 1
- Tags isn't exported with Export .md or HTML HOT 1
- Ctrl+Shift+E to open/close tag page isn't working HOT 2
- `standard.lintFiles()` doesn't use `process.cwd()` HOT 5
- RFC: eslint-config-standard-with-typescript to depart from standard HOT 19
- Rule suggestion: no-constant-binary-expression
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from standard.