Comments (7)
I guarantee that 90% of react devs are using Jest for testing. Also I think the discussion about these variables going non-global in Jest is not relevant, as status quo for this moment is that they are global and Lynt is supposed to be "Zero configuration by default" :)
from lynt.
Hmm suddenly it's working for me as well, I think it's because I've experimented with .lyntrc and made something like this and forgot about it:
{
"env": {
"jest": true
}
}
It seems such .lyntrc is incorrect overrides CLI flag (usually CLI flags have priority over configuration).
from lynt.
You can specify any amount of env
flags and pass valid ESLint environments with command line arguments or in your config file:
lynt --react --env jest
Doing the above would add support for both react as well as jest variables.
Or are you suggesting that --env jest
is provided by default without the need for passing in a flag? I am kind of 50-50 on this. On one hand, it seems like Jest is really ramping up on popularity so this might be a good idea, but on the other it might be a bad idea to always treat describe
, it
, etc as valid global variables when one isn't using Jest.
There has also been some discussion from people who actually want to import these variables rather than having them be global: jestjs/jest#4473
Curious to hear your/others thoughts on this.
from lynt.
Also, I tried node_modules/.bin/lynt test --react --env jest
but it still shows "describe is not defined" etc.
from lynt.
Hmm, that's strange. I've been testing it out on a couple of my larger projects as well as a new project I just made with create-react-app
, and there didn't seem to be those issues.
Example: https://github.com/saadq/issues/tree/master/lynt-jest
I just ran:
create-react-app lynt-jest
And once that was done, in the project I just ran:
npm install -D lynt
Which installed lynt
version v0.5.5
. I added a describe
function call to the default Jest test.
Running lynt
without --env jest
would result in errors like you described, but they should go away when the env
flag is passed:
Not that it should matter, but could you give a bit of info on whether you have lynt
installed globally or as a local project devDependency
? And if possible, would you be able to share some code (or even better, a minimal project) which causes this issue?
from lynt.
(I used such configuration in my .eslintrc)
from lynt.
Ah, I see. I currently didn't have tests for both CLI and config files existing simultaneously, so I should definitely add that. I am currently overriding the CLI args with the config file, but I definitely agree it should be the other way around. Opened #44 for this problem.
I think the reason your issue was happening was that the env
in a .lyntrc
file should be an array of env
strings (for example, ['jest', 'browser']
rather than a mapping of env string => boolean. I think I went this way rather than the .eslintrc
config style because the programmatic ESLint API requires env
to be passed as an array of strings, and I just thought it was simpler overall.
Going to close this out as I think it is currently working, but automatically adding jest
support on detection (like react/ts/flow) might be a good idea. For example, if the user has a jest.config.js
file or "jest"
key in package.json
or even if they just have jest
installed as a dependency are some things I could look for.
from lynt.
Related Issues (20)
- upgrade eslint v5 HOT 1
- Group related packages together into monorepo
- ESLint compromise
- Logo
- Remove `no-unused-variable` in TSLint config
- Tslint with exportedConfig and lynt have different output HOT 4
- Avoid installing extra packages HOT 1
- lint typescript using eslint HOT 2
- --strict mode HOT 1
- Add eslint-plugin-react-hooks for react lint config
- Invalid "is defined but never used" errors HOT 6
- ESLint 5 Breaking Change: Globs to lint MUST be valid HOT 1
- Auto-detect if the user needs react, flow, or typescript support
- Lynt v1 HOT 1
- Create gitter chat and add badge of it HOT 1
- --watch mode
- CLI flags should override config file options
- 30 high severity vulnerabilities in 2466 scanned packages HOT 3
- Is this project alive?
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 lynt.