Should empty array trigger warning?
See original GitHub issueThis is a Question
Description
typeof []
=== ‘object’ so this causes empty arrays to trigger a warning. Intended? Or worth a check for !Array.isArray
)?
Additional Data
- Serverless Framework Version you’re using: latest (Master)
Issue Analytics
- State:
- Created 6 years ago
- Comments:6 (4 by maintainers)
Top Results From Across the Web
How to trigger a break when an Array is empty? - Stack Overflow
One idea would be to add a didSet{} block to the property that holds the array, adding a log statement within - break...
Read more >This is why you should pass an empty array into useEffect
Empty array means no dependencies can trigger the supplied function to run again, therefor it will only run once. No argument at all...
Read more >empty - Manual - PHP
Determine whether a variable is considered to be empty. A variable is considered empty if it does not exist or if its value...
Read more >Empty arrays and collections should be returned instead of null
Returning null instead of an actual array, collection or map forces callers of the method to explicitly test for nullity, making them more...
Read more >Dependency array in useEffect hook | by Shreejit Rajbanshi
An empty array simply means that there are no dependencies that will trigger the callback within it. Our code inside the callback will...
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 Free
Top 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
I’m running into the same problem as @antogyn, specifically for API keys. More generally, an empty object or an empty array is often intentional, but we have our CI setup to fail on serverless warnings, because null or undefined values usually are not.
I use empty arrays sometimes in my config (e.g. for api keys on a particular environment) and I couldn’t find a workaround for this warning.