Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.
Sign upAdd "env" config to package.json #371
Comments
gsklee
changed the title
Add
Add "env" confit to package.json
Jan 6, 2016
gsklee
changed the title
Add "env" confit to package.json
Add "env" config to package.json
Jan 6, 2016
This comment has been minimized.
This comment has been minimized.
|
IMHO, if |
This comment has been minimized.
This comment has been minimized.
|
bad, mocha. one of the reasons I don't use mocha anymore. :p |
dcousens
added
feature request
question
labels
Jan 8, 2016
This comment has been minimized.
This comment has been minimized.
dmitriz
commented
Jan 15, 2016
|
@rstacruz What is better than mocha? |
This comment has been minimized.
This comment has been minimized.
|
I personally prefer tape, but that's just me. Anyway, IMHO this is most certainly doable. Eslint itself has support for environments defined here: http://eslint.org/docs/user-guide/configuring#specifying-environments. These look particularly useful:
|
This comment has been minimized.
This comment has been minimized.
|
Also, @feross, this might be worth documenting: /* eslint-env mocha */...will consider describe/it/beforeEach/etc as predefined globals. |
This comment has been minimized.
This comment has been minimized.
|
I guess if it is basically just a direct pass-through for a common eslint feature, then I'm not against it. |
This comment has been minimized.
This comment has been minimized.
|
Though, IMHO Make the lame things hard, and the bad things impossible |
This comment has been minimized.
This comment has been minimized.
|
yes, i agree. there's also the possibility of this: {
"scripts": {
"lint": "standard 'lib/*.js'; standard 'test/**/*.js' --env mocha"
}
} |
This comment has been minimized.
This comment has been minimized.
|
@rstacruz that I would agree with a lot more than the blanket suggestion. |
This comment has been minimized.
This comment has been minimized.
dmitriz
commented
Jan 15, 2016
|
@rstacruz Seems like they require to write this in every single test file:
Grows old very fast, imo. |
This comment has been minimized.
This comment has been minimized.
|
@dmitriz: i know this is off tangent in the conversation now, but that's precisely why I like it. It means you have write your test files in idiomatic JavaScript—no fancy test runners. In practice, it means your tests are runnable on their own ( node test.js # run in node.js
hihat test.js # run in electron (hihat is browserify-aware)
budo test.js # run in browser (budo is, too)
browserify test.js | smokestack -b firefox # run in headless browser |
This comment has been minimized.
This comment has been minimized.
dmitriz
commented
Jan 15, 2016
|
@rstacruz I see, interesting, have you seen ava - that looks similar! |
This comment has been minimized.
This comment has been minimized.
|
@rstacruz Interesting info ;-) |
This comment has been minimized.
This comment has been minimized.
|
@rstacruz +1 to It's not worth saving one line if you break compatibility with everything. All tooling has to add custom support for mocha and know about the exact list of globals that mocha assumes. Not a good tradeoff. |
This comment has been minimized.
This comment has been minimized.
|
That said, we'll support passing through this option to |
This comment has been minimized.
This comment has been minimized.
|
PR to Works in {
"standard": {
"env": {
"mocha": true
}
}
}And the command line:
This will be released in standard v6. |
gsklee commentedJan 6, 2016
As a continuation of #18, can we add this?
{ "standard": { "env": "mocha" } }IMHO it's better than either adding
/* eslint-env mocha */to all test files, or adding:{ "standard": { "globals": ["beforeEach", "describe", "it", ...] } }