Skip to content

Commit

Permalink
Merge pull request #190 from zardoy/develop
Browse files Browse the repository at this point in the history
  • Loading branch information
zardoy authored Jan 19, 2024
2 parents 16b2f50 + 36ad9b9 commit 88f69aa
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
3 changes: 2 additions & 1 deletion .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@
"unicorn/switch-case-braces": "off",
"@typescript-eslint/consistent-type-imports": "off",
"@typescript-eslint/ban-types": "off",
"sonarjs/prefer-single-boolean-return": "off"
"sonarjs/prefer-single-boolean-return": "off",
"unicorn/no-typeof-undefined": "off" // todo disable globally
},
"overrides": [
{
Expand Down
2 changes: 1 addition & 1 deletion typescript/src/getPatchedNavTree.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ type AdditionalFeatures = Record<'arraysTuplesNumberedItems', boolean>

const getPatchedNavModule = (additionalFeatures: AdditionalFeatures): { getNavigationTree(...args) } => {
// what is happening here: grabbing & patching NavigationBar module contents from actual running JS
const tsServerPath = __TS_SEVER_PATH__ === undefined ? require.main!.filename : __TS_SEVER_PATH__
const tsServerPath = typeof __TS_SEVER_PATH__ === 'undefined' ? require.main!.filename : __TS_SEVER_PATH__
// current lib/tsserver.js
const mainScript = nodeModules!.fs.readFileSync(tsServerPath, 'utf8')
type PatchData = {
Expand Down
7 changes: 7 additions & 0 deletions typescript/src/specialCommands/handle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,9 @@ export default (
let targetNode: undefined | ts.Node | [number, number]
if (ts.isIdentifier(node) && node.parent) {
node = node.parent
if (ts.isJsxExpression(node)) node = node.parent
if (ts.isJsxAttributeLike(node)) node = node.parent
if (ts.isJsxAttributes(node)) node = node.parent
if (ts.isPropertyAssignment(node)) {
targetNode = node.initializer
} else if ('body' in node) {
Expand All @@ -140,6 +143,10 @@ export default (
const pos = node.end
targetNode = [pos, pos]
}
if (ts.isJsxClosingElement(node) || ts.isJsxClosingFragment(node)) {
const { pos } = node
targetNode = [pos, pos]
}
}

if (!targetNode) {
Expand Down

0 comments on commit 88f69aa

Please sign in to comment.