fix: correct the return type of applyInlineConfig
#548
+23
−6
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Prerequisites checklist
What is the purpose of this pull request?
Which language are you using?
CommonMark and GFM.
What did you do?
I expected the return type of
applyInlineConfig().configs
— specificallyloc.start
andloc.end
— to include anoffset
property, but they don't.What did you expect to happen?
I expect the types of
loc.start
andloc.end
to include anoffset
property.Link to minimal reproducible Example
If you run the code above, you'll see that
markdownSourceCode.applyInlineConfig().configs[0].loc.start
andmarkdownSourceCode.applyInlineConfig().configs[0].loc.end
include anoffset
property. However, the return type doesn't reflect thatoffset
property.# Output { start: { line: 1, column: 1, offset: 0 }, end: { line: 1, column: 42, offset: 41 } }
What changes did you make? (Give an overview)
Looking at the origin of the
loc
property returned byapplyInlineConfig
, you'll find that it directly uses theposition
property of theHtml
node.markdown/src/language/markdown-source-code.js
Lines 83 to 85 in 88b9391
markdown/src/language/markdown-source-code.js
Line 98 in 88b9391
markdown/src/language/markdown-source-code.js
Lines 87 to 89 in 88b9391
markdown/src/language/markdown-source-code.js
Line 107 in 88b9391
markdown/src/language/markdown-source-code.js
Lines 112 to 115 in 88b9391
The
position
property uses thePosition
type fromunist
as shown below, so technically it doesn’t match theSourceLocation
type.Position
SourceLocation
To provide a more accurate return type, I've replaced the
SourceLocation
type with thePosition
type fromunist
.Related Issues
Ref: eslint/css#281, eslint/json#162
Is there anything you'd like reviewers to focus on?
N/A