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: add helper getPositionAt to fix incorrect loc #293

Merged
merged 5 commits into from
Mar 20, 2021
Merged

fix: add helper getPositionAt to fix incorrect loc #293

merged 5 commits into from
Mar 20, 2021

Conversation

JounQin
Copy link
Member

@JounQin JounQin commented Mar 19, 2021

close #292

The following has been resolved!

I don't know if there is a better and cleaner way without source `code` or `lines`.

OK, I found maybe we have to use this approach because the loc column of start node could be incorrect as described at #279 (comment), while the start offset is always correct.

@JounQin JounQin self-assigned this Mar 19, 2021
@codecov-io
Copy link

codecov-io commented Mar 19, 2021

Codecov Report

Merging #293 (618e5ec) into master (f5d288a) will not change coverage.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff            @@
##            master      #293   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           22        22           
  Lines          512       521    +9     
  Branches       100       100           
=========================================
+ Hits           512       521    +9     
Impacted Files Coverage Δ
.eslintrc.js 100.00% <ø> (ø)
packages/eslint-mdx/src/helpers.ts 100.00% <100.00%> (ø)
packages/eslint-mdx/src/parser.ts 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 f5d288a...618e5ec. Read the comment docs.

@JounQin JounQin added 🏡 area/internal This affects the hidden internals 🐛 type/bug This is a problem 👶 semver/patch This is a backwards-compatible fix labels Mar 19, 2021
@JounQin JounQin changed the title fix: add helper getLocFromRange fix: add helper getPositionAt to fix incorrect loc Mar 19, 2021
packages/eslint-mdx/src/helpers.ts Outdated Show resolved Hide resolved
@JounQin JounQin merged commit 260a07e into master Mar 20, 2021
@JounQin JounQin deleted the fix/loc branch March 20, 2021 00:49
@JounQin
Copy link
Member Author

JounQin commented Mar 20, 2021

@wooorm ready for a patch release!

@wooorm
Copy link
Member

wooorm commented Mar 21, 2021

@JounQin I can’t release, there’s a typescript error when running tsc -b:

Error: @rollup/plugin-typescript TS2569: Type 'IterableIterator<[number, string]>' is not an array type or a string type. Use compiler option '--downlevelIteration' to allow iterating of iterators.
    at error (~/eslint-mdx/node_modules/rollup/dist/shared/rollup.js:5279:30)
    at throwPluginError (~/eslint-mdx/node_modules/rollup/dist/shared/rollup.js:18240:12)
    at Object.error (~/eslint-mdx/node_modules/rollup/dist/shared/rollup.js:18847:24)
    at Object.error (~/eslint-mdx/node_modules/rollup/dist/shared/rollup.js:18409:38)
    at ~/eslint-mdx/node_modules/@rollup/plugin-typescript/dist/index.js:27:21
    at Array.forEach (<anonymous>)
    at emitDiagnostics (~/eslint-mdx/node_modules/@rollup/plugin-typescript/dist/index.js:22:10)
    at Object.transform (~/eslint-mdx/node_modules/@rollup/plugin-typescript/dist/index.js:465:17)
    at ~/eslint-mdx/node_modules/rollup/dist/shared/rollup.js:19049:25 {
  pluginCode: 'TS2569',
  loc: {
    column: 37,
    line: 103,
    file: '~/eslint-mdx/packages/eslint-mdx/src/helpers.ts'
  },
  frame: '\n' +
    "\x1B[7m103\x1B[0m   for (const [index, { length }] of code.split('\\n').entries()) {\n" +
    '\x1B[7m   \x1B[0m \x1B[91m                                    ~~~~~~~~~~~~~~~~~~~~~~~~~~\x1B[0m\n',
  id: '~/eslint-mdx/packages/eslint-mdx/src/helpers.ts',
  hook: 'transform',
  code: 'PLUGIN_ERROR',
  plugin: 'typescript',
  watchFiles: [
    '~/eslint-mdx/packages/eslint-mdx/src/index.ts',
    '~/eslint-mdx/packages/eslint-mdx/src/helpers.ts',
    '~/eslint-mdx/packages/eslint-mdx/src/parser.ts',
    '~/eslint-mdx/packages/eslint-mdx/src/regexp.ts',
    '~/eslint-mdx/packages/eslint-mdx/src/traverse.ts',
    '~/eslint-mdx/packages/eslint-mdx/src/types.ts'
  ]
}

@wooorm
Copy link
Member

wooorm commented Mar 21, 2021

Released!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🏡 area/internal This affects the hidden internals 👶 semver/patch This is a backwards-compatible fix 🐛 type/bug This is a problem
Development

Successfully merging this pull request may close these issues.

[bug] restored loc column is still incorrect when startLine is not 1
4 participants