verekia / js-stack-from-scratch

🛠️⚡ Step-by-step tutorial to build a modern JavaScript stack.
MIT License
20.05k stars 1.99k forks source link

don't check node_modules with flow #220

Open beane opened 7 years ago

beane commented 7 years ago

Written to fix this annoying issue. We probably shouldn't be flow checking our libraries, anyway.

Corresponding walkthrough PR

verekia commented 7 years ago

This does not work for me. Flow chokes on every import.

beane commented 7 years ago

@verekia can you elaborate? Does it choke after adding these ignore lines or was it choking before?

I'm using flow version 0.46.0. I see that the tutorial has 0.41.0. I didn't find anything in the CHANGELOGs, but maybe there's a difference in how flow reads the [ignore] block?

$ grep flow-bin yarn.lock
flow-bin@^0.46.0:
  resolved "https://registry.yarnpkg.com/flow-bin/-/flow-bin-0.46.0.tgz#06ad7fe19dddb1042264438064a2a32fee12b872"
verekia commented 7 years ago

I used 0.46.0 as well for the test. Sorry if that sounds rude, but did you actually test that change on the code of the tutorial?

beane commented 7 years ago

Of course I did. I made the PR because the code as it is wasn't working.

Try using the walkthrough code.

cd js-stack-walkthrough/02-babel-es6-eslint-flow-jest-husky/
git checkout  fix_flow_errors_on_node_modules
yarn install
yarn test

Can you explain what you mean by

Flow chokes on every import.

I'm trying to figure out why it doesn't work for you. I'm confused how this didn't blow up in the first place without the [ignore] block.

verekia commented 7 years ago

Okay I'll try your branch a bit later, but the errors I am getting when running flow on the final boilerplate of the tutorial are 45 messages like this one:

src/client/index.jsx:13
 13: import thunkMiddleware from 'redux-thunk'
                                 ^^^^^^^^^^^^^ redux-thunk. Required module not found
verekia commented 7 years ago

Same errors in the walkthrough starting chapter 03. I guess you only tried it on chapter 02?

beane commented 7 years ago

Originally I only tried in chapter 02. I can confirm that it breaks the other chapters. I'll try to figure out why and how to prevent it.

If you use the following package.json file in 02 (blow away node_modules, yarn install etc) you should see that flow just blows up because it's trying to check some libraries in node_modules. I have no idea why it works with the original package.json -- trying to figure out what changes confused flow.

{
  "name": "your-project",
  "version": "1.0.0",
  "license": "MIT",
  "browserslist": ["> 1%"],
  "scripts": {
    "start": "babel-node src",
    "lint": "eslint src && flow"
  },
  "devDependencies": {
    "babel-cli": "^6.24.1",
    "babel-eslint": "^7.2.3",
    "babel-preset-env": "^1.5.1",
    "babel-preset-flow": "^6.23.0",
    "eslint": "^3.19.0",
    "eslint-config-airbnb": "^15.0.1",
    "eslint-plugin-compat": "^1.0.3",
    "eslint-plugin-flowtype": "^2.33.0",
    "eslint-plugin-import": "^2.2.0",
    "eslint-plugin-jsx-a11y": "^5.0.1",
    "eslint-plugin-react": "^7.0.1",
    "flow-bin": "^0.47.0"
  }
}