Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

fix: from-map rule is not working on TS files #50

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
freaktechnik merged 4 commits into freaktechnik:master from doniyor2109:fix_from_map_ts
Apr 5, 2020

Conversation

Copy link
Contributor

@doniyor2109 doniyor2109 commented Mar 27, 2020

Fixes #49

Copy link

codecov bot commented Mar 27, 2020
edited
Loading

Codecov Report

Merging #50 into master will not change coverage by %.
The diff coverage is 100.00%.

Impacted file tree graph

@@ Coverage Diff @@
## master #50 +/- ##
=========================================
 Coverage 100.00% 100.00% 
=========================================
 Files 8 8 
 Lines 111 116 +5 
=========================================
+ Hits 111 116 +5 
Impacted Files Coverage Δ
rules/from-map.js 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 51e547a...09f515b. Read the comment docs.

Copy link
Owner

Hm, if the location info is indeed the issue I fear most rules won't behave properly with the TS parser.

Copy link
Owner

More importantly: thank you very much for the PR, I'll try to get to it within a week or so.

Copy link
Contributor Author

We have big codebase using Typescript and only this rule is broken at the moment

@@ -76,18 +76,18 @@ module.exports = {
}
// The original map callback from Array.from gets nested as a parameter to the callback from map.
const lastCallback = getCallback(mapCallback, mapThisArgument, `${firstCallback}${restParameterString}`),
restParameters = sourceCode.getText().slice(callback.end, parent.end);
restParameters = sourceCode.getText().slice(callback.loc.end.column, parent.loc.end.column);
Copy link
Owner

@freaktechnik freaktechnik Apr 5, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should use callback.range[1] instead of loc.end.column. Same goes for all ranges. range[0] is the start, range[1] is the end. I believe the current approach only works because all unit tests only operate on the first line.

doniyor2109 reacted with thumbs up emoji
}
});

ruleTester.run('from-map', rule, {
Copy link
Owner

@freaktechnik freaktechnik Apr 5, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if the actual rule tests should be shared with a helper module, so adding a test for the rule automatically checks for both parsers.

doniyor2109 reacted with thumbs up emoji
Copy link
Owner

@freaktechnik freaktechnik left a comment
edited
Loading

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you very much for the fix. I can't promise that I'll get a release out today with these changes, but I've made a task to get it done this week.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Reviewers

@freaktechnik freaktechnik freaktechnik approved these changes

Assignees
No one assigned
Labels
None yet
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

[from-map] Does not work with TS files

AltStyle によって変換されたページ (->オリジナル) /