Deprecation warnings for non-Gatsby code
See original GitHub issueDescription
On develop, Gatsby parses the codebase for deprecated APIs like pathContext
and boundActionsCreator
. In some cases, these keywords are detected in non-Gatsby code, as mentioned already in #11679 (closed) and #10211 (stale), and a warning is shown:
Real example of the warning being thrown for minified Storybook code
Steps to reproduce
gatsby new bug-repro https://github.com/gatsbyjs/gatsby-starter-hello-world
cd bug-repro
mkdir random-files && echo pathContext > random-files/random-file.js
➡️ this creates a js file and writespathContext
in itgatsby develop
Expected result
These warnings should only be shown if these deprecated APIs are actually being used in the Gatsby project.
Actual result
Environment
System:
OS: macOS 10.15.2
CPU: (12) x64 Intel(R) Core(TM) i7-8850H CPU @ 2.60GHz
Shell: 5.7.1 - /bin/zsh
Binaries:
Node: 12.6.0 - ~/.nvm/versions/node/v12.6.0/bin/node
Yarn: 1.19.1 - ~/.yarn/bin/yarn
npm: 6.9.0 - ~/.nvm/versions/node/v12.6.0/bin/npm
Languages:
Python: 2.7.16 - /usr/bin/python
Browsers:
Chrome: 79.0.3945.88
Firefox: 71.0
Safari: 13.0.4
npmPackages:
gatsby: ^2.18.12 => 2.18.12
Issue Analytics
- State:
- Created 4 years ago
- Comments:5 (3 by maintainers)
Top Results From Across the Web
The Complete Guide for Deprecation Warnings in Rails
After you fix a deprecation warning in the project, you want to make sure that nobody introduces that deprecated code again. Rubocop. If...
Read more >Dealing with Deprecation Warnings - Java Cookbook [Book]
Your code used to compile cleanly, but now gives deprecation warnings. Solution. You must have blinked :-). Either live with the warnings --...
Read more >warnings — Warning control — Python 3.11.1 documentation
Base category for warnings about deprecated features when those warnings are intended for other Python developers (ignored by default, unless triggered by code...
Read more >How to ignore deprecation warnings in Python - Stack Overflow
You should just fix your code but just in case, import warnings warnings.filterwarnings("ignore", category=DeprecationWarning).
Read more >Deprecation warnings in Python code - Piccolo Blog
Deprecation warnings in Python code. When working on Python libraries like Piccolo, it's important to evolve it in a graceful way.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@sidharthachatterjee checking if they are props before printing the warning could work! Not sure how we could lint this though, any ideas? 🤔
I had another related idea - could we somehow stop Gatsby from parsing files that are ignored in
.gitignore
(or.gatsbyignore
😛)? In my case for instance, thestorybook-public
folder is ignored, similarly to Gatsby’spublic
folder. This is where keywords likeboundActionsCreator
come up unexpectedly.If Gatsby took an ignore file as a CLI flag or a config option, we could avoid some warnings. There’s probably already some ignore logic built in, to avoid parsing
node_modules
for instance. This could ensure that warnings are only thrown for code that is actually intended to be in the Gatsby project (i.e. not ignored).Love detailed issues like these. Thanks @robinmetral 🙌
So the deprecation warning here isn’t for APIs in non-Gatsby code but for instances of
pathContext
andboundActionsCreator
in any code because they are available as props and could be passed down arbitrarily.The heuristic isn’t great though and we should improve this since it is confusing.
Perhaps we can lint for if they are props and then print this warning? What do you think?