Skip to content
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

fix(typescript-estree): fix handling of range/loc removal #2028

merged 1 commit into from May 17, 2020


Copy link

if I pass the options with
comment: true,
loc: false,
range: false,

when parsing, I expect it should remove loc & range both

Copy link

Thanks for the PR, @captainblue2013!

typescript-eslint is a 100% community driven project, and we are incredibly grateful that you are contributing to that community.

The core maintainers work on this in their personal time, so please understand that it may not be possible for them to review your work immediately.

Thanks again!

🙏 Please, if you or your company is finding typescript-eslint valuable, help us sustain the project by sponsoring it transparently on As a thank you, your profile/company logo will be added to our main README which receives thousands of unique visitors per day.

Copy link

codecov bot commented May 15, 2020

Codecov Report

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

@@           Coverage Diff           @@
##           master    #2028   +/-   ##
  Coverage   93.93%   93.93%           
  Files         172      172           
  Lines        7829     7829           
  Branches     2245     2245           
  Hits         7354     7354           
  Misses        217      217           
  Partials      258      258           
Flag Coverage Δ
#unittest 93.93% <100.00%> (ø)
Impacted Files Coverage Δ
packages/typescript-estree/src/ast-converter.ts 100.00% <100.00%> (ø)

@bradzacher bradzacher changed the title fix: 🐛 allow remove range & loc both fix(typescript-estree): allow removing any combination of range and loc May 15, 2020
@bradzacher bradzacher added the bug Something isn't working label May 15, 2020
Copy link

@bradzacher bradzacher left a comment

Choose a reason for hiding this comment

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


@bradzacher bradzacher changed the title fix(typescript-estree): allow removing any combination of range and loc fix(typescript-estree): fix handling of range/loc removal May 17, 2020
@bradzacher bradzacher merged commit ce344d9 into typescript-eslint:master May 17, 2020
Copy link

JounQin commented Jun 15, 2020

@bradzacher This seems to be incompatible with espree and babel-eslint which include loc and range by default. What means should we check if the value is false specifically instead of removing them by default.

I'm developing an eslint plugin which support babel-eslint and @typescript-eslint/typesript-estree at the same time. But I found it broke some cases in recent days, and it wasted me a few hours to find out why loc and range were missing...

Copy link

typescript-estree has a its options and defaults spelled out:

const PARSE_DEFAULT_OPTIONS: ParseOptions = {
comment: false,
errorOnUnknownASTType: false,
filePath: 'estree.ts', // or 'estree.tsx', if you pass jsx: true
jsx: false,
loc: false,
loggerFn: undefined,
range: false,
tokens: false,
useJSXTextNode: false,
declare function parse(
code: string,
options: ParseOptions = PARSE_DEFAULT_OPTIONS,
): TSESTree.Program;

The system was working incorrectly before this PR. It was always supposed to treat ast and loc as false by default.

Copy link

@JounQin Sorry about that

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jul 17, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
bug Something isn't working
None yet

Successfully merging this pull request may close these issues.

None yet

4 participants