react-slingshot: Tip: Things to check if you get an npm run lint error or build error

I am opening this issue as I also caught up in the npm run lint error issues. After a few hours research on github issues and googling, I found the current checklist to resolve this issue. (Note: this applies to both react-slingshot and react-redux course git repo)

  • First Make Sure .eslintrc is in your project root folder. The current ESW have some weird behavior in terms of reading .eslintrc. Even your .eslintrc is not in your root folder, for example, I accidentally put mine in the /tools folder, some of the setting will still be activated like parserOptions but none of the rules are valid.
  • Putting the .eslintrc in the wrong folder would lead to Parsing error: The keyword 'import' is reserved

And it is not related to the setting of your .eslintrc but whether it is in your root folder or not. If you didn’t put

"sourceType": "module", "ecmaFeatures": { "jsx": true, "modules": true }

  • Missing modules setting would lead to Parsing error: 'import' and 'export' may appear only with 'sourceType: module'
  • Second change the npm run lint script to "esw webpack.config.* src tools; exit 0" and change the npm run lint:watch script to "esw webpack.config.* src tools --watch; exit 0" If ESW found any error or warning in your project like console statement or missing semi, the lint thread will be exit with Exit status 1. This will lead to an ELIFECYCLE error. This is actually not an error but a warning of ESW to indicate that it will print out all the warning and error. Adding exit 0 will not break the eslint checking but allow npm script to ignore the status 1 and allow ESW to print all all the warning and error.
  • Third check eslint/esw global install version and the local version to match. This is not an issue I encounter but, make sure the global install is not outdate or out-sync with local project will help you resolve the ‘esw’ keyword. And this means we could use esw to replace the /node_modules/.bin/esw.

These are all the issues I found regarding debugging npm run lint issues. I hope this helps a lot current unresolved opened issues. Including some closed issues with is not correctly resolved.

This include: https://github.com/coryhouse/react-slingshot/issues/133 https://github.com/coryhouse/react-slingshot/issues/84 https://github.com/coryhouse/react-slingshot/issues/150

Note: I did not reproduce the issue above, some my solution could be not working with the above issues but I think this is a pretty solid solution to the current version of eslint/esw/npm script.

Credit to: modules solution exit 0 solution

About this issue

  • Original URL
  • State: closed
  • Created 8 years ago
  • Reactions: 9
  • Comments: 17 (8 by maintainers)

Commits related to this issue

Most upvoted comments

This lint thing does not work for me on Windows… Even if I applied all the suggestions. I just ignore it for the time being… In general this is why it is difficult for me to start with all these tools: versioning nightmare + completely unreadable error messages… We are still in medieval when it comes to building software! 😃

esw webpack.config.* src buildScripts --color; exit 0 npm ERR! code ELIFECYCLE npm ERR! errno 1

Hi @romarioraffington - Thanks! I corrected a minor typo by editing your comment. Let’s omit the first bullet since that code is already included in the project. but otherwise looks great. Thanks!

I’m fine with closing, but would suggest copying any info here to here: https://github.com/coryhouse/react-slingshot#having-issues-try-these-things-first

This is probably obvious to everyone except me, but it took me a bit to figure out that step 2 occurs in the package.json. That fixed my issue, so thanks!