Comments (6)
I'm pretty sure jsinspect 0.9 and below just completely ignored any JSX and kept parsing the files. The tool was completely rewritten in 0.10 as I found people were mostly interested in copy-paste detection, and the API was pretty inconsistent. As a result, thresholds will likely need to be tweaked.
That said, that's definitely a bug! Looks like there's 2 issues that need to be addressed:
- End line for the sequence of JSX nodes is incorrect
- JSX ASTs tend to be quite verbose, will probably need to make them more compact so as to avoid tripping up at lower thresholds
Thanks for letting me know!
from jsinspect.
End line for the sequence of JSX nodes is incorrect
Fixed in 20a16c9 and published a new patch release. The issue is that NodeUtils.getChildren
isn't guaranteeing children order. It worked for most nodes, e.g. function params get visited before its body, but not JSX. Will probably update the function to peak at node location before caching attribute order. Previous versions of jsinspect hardcoded attribute traversal order... but it's not very future-proof.
JSX ASTs tend to be quite verbose, will probably need to make them more compact so as to avoid tripping up at lower thresholds
This is still an issue, but working on a fix!
from jsinspect.
Quick explanation as to why it's not completely a false positive, but a higher threshold might be necessary for JSX files. Let's look at this small snippet from the first example:
start={{x: 0.0, y: 0.0}} end={{x: 0.0, y: 1.0}}
locations={[0, 1]}
This small of a snippet breaks down into the following 25 nodes
JSXIdentifier (start), JSXExpressionContainer, ObjectExpression, ObjectProperty, Identifier (x), NumericLiteral (0), ObjectProperty, Identifier (y), NumericLiteral (0), JSXAttribute, JSXIdentifier (end), JSXExpressionContainer, ObjectExpression, ObjectProperty, Identifier (x), NumericLiteral (0), ObjectProperty, Identifier (y), NumericLiteral (1), JSXAttribute, JSXIdentifier (locations), JSXExpressionContainer, ArrayExpression, NumericLiteral (0), NumericLiteral 1
Token-based copy paste detection would probably even label that small snippet as having ~30-40 tokens. So this would hint that the LinearGradient
element could probably benefit from a helper/wrapper/component where all these properties are already set.
As a temp fix, a threshold of 45 or more might be more appropriate. However, this might improve by correcting the JSX node attribute traversal order.
from jsinspect.
And as a note, here's what would be reported after the latest patch release (note that it's not just a single line)
from jsinspect.
This has been fixed in 119e32d
This makes up 40 nodes:
<LinearGradient
start={{x: 0.0, y: 0.0}} end={{x: 0.0, y: 1.0}}
locations={[0, 1]}
colors={['#074595', '#6589A4']}
style={Styles.
With 0.12.2, setting the threshold to 41 will avoid catching this LinearGradient. Thanks!
from jsinspect.
Awesome, thanks for the fast turnaround! :) π₯
from jsinspect.
Related Issues (20)
- Possibility to specify custom reporter via CLI and by .jsinspectrc HOT 3
- Blowing up on large react projects HOT 7
- How to save a fileοΌ HOT 1
- Feature request: parsing script tags in HTML
- can't set boolean flags from config file HOT 1
- detect-copy-paste fork HOT 1
- instances > X OR threshold > Y HOT 1
- Usage in Javascript-like languages? HOT 4
- Ability to define files to report
- npx example for package.json scripts
- Cannot parse files using the babel proposal optional chaining
- Typo in documentation example
- Feature Request: Ignore Existing Duplication HOT 1
- Has any plan to support TypeScript? HOT 3
- Unexpected token <> HOT 1
- Consider different font colour for showing matching code blocks HOT 1
- FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory
- [feature request] support suffix other than .js or .jsx HOT 2
- Single line match reported when there is no match
- Is this project still maintained? HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. πππ
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from jsinspect.