tiagob / create-full-stack

Set up a TypeScript full stack with one command.
https://create-full-stack.com
MIT License
97 stars 9 forks source link

ESLint Error on create #160

Closed gjolund closed 3 years ago

gjolund commented 3 years ago

Describe the bug Let me start off by saying that this project is incredible. Really great work.

Its one of those FOSS projects that you look and think "Shit, that took me a month to build 6 months ago."

Pulumi was news to me, really liking it so far. I don't think I'll use this project wholesale, but there is a lot of good stuff in here I'm going to transplant into an existing fullstack TS / Hasura SaaS project I'm leading.

Unfortunately, it seems like there is a ESLint Error when running the create command.

Running

yarn create full-stack --backend hasura --authentication auth0 --cloud aws --web react --mobile react-native --cicd github-actions

Yields

yarn run v1.22.4
$ eslint packages/** --ext ts,tsx --fix

Oops! Something went wrong! :(

ESLint: 7.12.1

Error: Error while loading rule 'jest/no-deprecated-functions': Unable to detect Jest version - please ensure jest package is installed, or otherwise set version explicitly

Expected behavior

Painless setup that creates a unicorn with 0 effort.

Desktop (please complete the following information):

Additional context

Definitely going to be keeping an eye on this project.

I'm working on TS metadata generation that would be a good fit for this, I'll share once its ready.

gjolund commented 3 years ago

yarn add jest -W --dev in the workspace root resolved the issue.

tiagob commented 3 years ago

Thanks for the kind words! I couldn't have said why I built the project better myself. How'd you discover it?

Thanks for the bug report. I tried your proposed solution but the web tests fail for me.

% yarn test
[Web] 
[Web] There might be a problem with the project dependency tree.
[Web] It is likely not a bug in Create React App, but something you need to fix locally.
[Web] 
[Web] The react-scripts package provided by Create React App requires a dependency:
[Web] 
[Web]   "jest": "26.6.0"
[Web] 
[Web] Don't try to install it manually: your package manager does it automatically.
[Web] However, a different version of jest was detected higher up in the tree:
[Web] 
[Web]   /Users/tiagobandeira/dev/apollo-server-express-no-auth/node_modules/jest (version: 26.6.1) 
[Web] 
[Web] Manually installing incompatible versions is known to cause hard-to-debug issues.
[Web] 
[Web] If you would prefer to ignore this check, add SKIP_PREFLIGHT_CHECK=true to an .env file in your project.
[Web] That will permanently disable this message but you might encounter other issues.
[Web] 
[Web] To fix the dependency tree, try following the steps below in the exact order:
[Web] 
[Web]   1. Delete package-lock.json (not package.json!) and/or yarn.lock in your project folder.
[Web]   2. Delete node_modules in your project folder.
[Web]   3. Remove "jest" from dependencies and/or devDependencies in the package.json file in your project folder.
[Web]   4. Run npm install or yarn, depending on the package manager you use.
[Web] 
[Web] In most cases, this should be enough to fix the problem.
[Web] If this has not helped, there are a few other things you can try:
[Web] 
[Web]   5. If you used npm, install yarn (http://yarnpkg.com/) and repeat the above steps with it instead.
[Web]      This may help because npm has known issues with package hoisting which may get resolved in future versions.
[Web] 
[Web]   6. Check if /Users/tiagobandeira/dev/apollo-server-express-no-auth/node_modules/jest is outside your project directory.
[Web]      For example, you might have accidentally installed something in your home folder.
[Web] 
[Web]   7. Try running npm ls jest in your project folder.
[Web]      This will tell you which other package (apart from the expected react-scripts) installed jest.
[Web] 
[Web] If nothing else helps, add SKIP_PREFLIGHT_CHECK=true to an .env file in your project.
[Web] That would permanently disable this preflight check in case you want to proceed anyway.
[Web] 
[Web] P.S. We know this message is long but please read the steps above :-) We hope you find them helpful!
[Web] 
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
[Web] yarn --cwd packages/web test --ci --watchAll=false exited with code 1

Could either set the jest version at the root to 26.6.0 to match react-scripts or set the jest version in the eslint-plugin-create-full-stack. I'm going with the latter since that's one fewer dependency

gjolund commented 3 years ago

heard about the project through the hasura newsletter, you were the featured project

I'd like to hear your thoughts on why you decided to include the eslint config through a package.

personally I like my dependencies to be a bit more declarative, even if it is more verbose. having to dig through an additional layer of dependencies to determine why eslint is acting weird (which happens all the time) is a little cumbersome.

tiagob commented 3 years ago

Nice!

I did it to follow the CRA model: https://github.com/facebook/create-react-app/tree/master/packages/eslint-config-react-app

It's a trade-off. CRA hides babel, webpack and eslint configs from you to make the project simpler to navigate while still allowing you to override a lot of the settings. It's one more layer to dig through but ideally if it works as it should then only experts need to dig into it and novices feel more comfortable.

gjolund commented 3 years ago

fair enough, its a design choice, nothing wrong with it.

more recently I've been encouraging my devs to adhere to cra as closesly as possible, I tend to reject pr's that start messing with it because I like getting the free incremental improvements from the cra team.