Skip to content

Commit

Permalink
chore: use @meskill/sharec-config as tools setup (#17)
Browse files Browse the repository at this point in the history
  • Loading branch information
meskill committed Oct 16, 2021
1 parent 60738e7 commit 0ef7ba4
Show file tree
Hide file tree
Showing 14 changed files with 1,331 additions and 754 deletions.
11 changes: 6 additions & 5 deletions .eslintrc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,17 @@ env:
browser: true
es2021: true
extends:
- "eslint:recommended"
- "plugin:@typescript-eslint/recommended"
- "plugin:prettier/recommended"
- eslint:recommended
- plugin:@typescript-eslint/recommended
- plugin:prettier/recommended
parser: "@typescript-eslint/parser"
parserOptions:
ecmaVersion: 12
sourceType: module
plugins:
- "@typescript-eslint"
ignorePatterns:
- "dist"
- dist
rules:
indent:
- error
Expand All @@ -30,4 +30,5 @@ rules:
overrides:
- files:
- "*.md"
parser: "markdown-eslint-parser"
parser: markdown-eslint-parser
reportUnusedDisableDirectives: true
2 changes: 0 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,7 @@
!.yarn/sdks
!.yarn/versions
.pnp.*

# js-ts
node_modules/

# dist
dist/
2 changes: 1 addition & 1 deletion .prettierrc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ printWidth: 120
overrides:
- files: "*.md"
options:
parser: "markdown"
parser: markdown
2 changes: 1 addition & 1 deletion .yarn/sdks/eslint/lib/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@ if (existsSync(absPnpApiPath)) {
}

// Defer to the real eslint/lib/api.js your application uses
module.exports = absRequire(`eslint/lib/api.js`);
module.exports = absRequire(`eslint`);
2 changes: 1 addition & 1 deletion .yarn/sdks/eslint/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "eslint",
"version": "7.32.0-sdk",
"version": "8.0.1-sdk",
"main": "./lib/api.js",
"type": "commonjs"
}
2 changes: 1 addition & 1 deletion .yarn/sdks/prettier/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "prettier",
"version": "2.3.2-sdk",
"version": "2.4.1-sdk",
"main": "./index.js",
"type": "commonjs"
}
37 changes: 32 additions & 5 deletions .yarn/sdks/typescript/lib/tsserver.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ const moduleWrapper = tsserver => {

function toEditorPath(str) {
// We add the `zip:` prefix to both `.zip/` paths and virtual paths
if (isAbsolute(str) && !str.match(/^\^zip:/) && (str.match(/\.zip\//) || isVirtual(str))) {
if (isAbsolute(str) && !str.match(/^\^?(zip:|\/zip\/)/) && (str.match(/\.zip\//) || isVirtual(str))) {
// We also take the opportunity to turn virtual paths into physical ones;
// this makes it much easier to work with workspaces that list peer
// dependencies, since otherwise Ctrl+Click would bring us to the virtual
Expand Down Expand Up @@ -60,10 +60,18 @@ const moduleWrapper = tsserver => {
//
// Ref: https://github.com/microsoft/vscode/issues/105014#issuecomment-686760910
//
case `vscode`: {
// Update Oct 8 2021: VSCode changed their format in 1.61.
// Before | ^zip:/c:/foo/bar.zip/package.json
// After | ^/zip//c:/foo/bar.zip/package.json
//
case `vscode <1.61`: {
str = `^zip:${str}`;
} break;

case `vscode`: {
str = `^/zip/${str}`;
} break;

// To make "go to definition" work,
// We have to resolve the actual file system path from virtual path
// and convert scheme to supported by [vim-rzip](https://github.com/lbrayner/vim-rzip)
Expand Down Expand Up @@ -91,9 +99,25 @@ const moduleWrapper = tsserver => {
}

function fromEditorPath(str) {
return process.platform === `win32`
? str.replace(/^\^?zip:\//, ``)
: str.replace(/^\^?zip:/, ``);
switch (hostInfo) {
case `coc-nvim`:
case `neovim`: {
str = str.replace(/\.zip::/, `.zip/`);
// The path for coc-nvim is in format of /<pwd>/zipfile:/<pwd>/.yarn/...
// So in order to convert it back, we use .* to match all the thing
// before `zipfile:`
return process.platform === `win32`
? str.replace(/^.*zipfile:\//, ``)
: str.replace(/^.*zipfile:/, ``);
} break;

case `vscode`:
default: {
return process.platform === `win32`
? str.replace(/^\^?(zip:|\/zip)\/+/, ``)
: str.replace(/^\^?(zip:|\/zip)\/+/, `/`);
} break;
}
}

// Force enable 'allowLocalPluginLoads'
Expand Down Expand Up @@ -129,6 +153,9 @@ const moduleWrapper = tsserver => {
typeof parsedMessage.arguments.hostInfo === `string`
) {
hostInfo = parsedMessage.arguments.hostInfo;
if (hostInfo === `vscode` && process.env.VSCODE_IPC_HOOK && process.env.VSCODE_IPC_HOOK.match(/Code\/1\.[1-5][0-9]\./)) {
hostInfo += ` <1.61`;
}
}

return originalOnMessage.call(this, JSON.stringify(parsedMessage, (key, value) => {
Expand Down
37 changes: 32 additions & 5 deletions .yarn/sdks/typescript/lib/tsserverlibrary.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ const moduleWrapper = tsserver => {

function toEditorPath(str) {
// We add the `zip:` prefix to both `.zip/` paths and virtual paths
if (isAbsolute(str) && !str.match(/^\^zip:/) && (str.match(/\.zip\//) || isVirtual(str))) {
if (isAbsolute(str) && !str.match(/^\^?(zip:|\/zip\/)/) && (str.match(/\.zip\//) || isVirtual(str))) {
// We also take the opportunity to turn virtual paths into physical ones;
// this makes it much easier to work with workspaces that list peer
// dependencies, since otherwise Ctrl+Click would bring us to the virtual
Expand Down Expand Up @@ -60,10 +60,18 @@ const moduleWrapper = tsserver => {
//
// Ref: https://github.com/microsoft/vscode/issues/105014#issuecomment-686760910
//
case `vscode`: {
// Update Oct 8 2021: VSCode changed their format in 1.61.
// Before | ^zip:/c:/foo/bar.zip/package.json
// After | ^/zip//c:/foo/bar.zip/package.json
//
case `vscode <1.61`: {
str = `^zip:${str}`;
} break;

case `vscode`: {
str = `^/zip/${str}`;
} break;

// To make "go to definition" work,
// We have to resolve the actual file system path from virtual path
// and convert scheme to supported by [vim-rzip](https://github.com/lbrayner/vim-rzip)
Expand Down Expand Up @@ -91,9 +99,25 @@ const moduleWrapper = tsserver => {
}

function fromEditorPath(str) {
return process.platform === `win32`
? str.replace(/^\^?zip:\//, ``)
: str.replace(/^\^?zip:/, ``);
switch (hostInfo) {
case `coc-nvim`:
case `neovim`: {
str = str.replace(/\.zip::/, `.zip/`);
// The path for coc-nvim is in format of /<pwd>/zipfile:/<pwd>/.yarn/...
// So in order to convert it back, we use .* to match all the thing
// before `zipfile:`
return process.platform === `win32`
? str.replace(/^.*zipfile:\//, ``)
: str.replace(/^.*zipfile:/, ``);
} break;

case `vscode`:
default: {
return process.platform === `win32`
? str.replace(/^\^?(zip:|\/zip)\/+/, ``)
: str.replace(/^\^?(zip:|\/zip)\/+/, `/`);
} break;
}
}

// Force enable 'allowLocalPluginLoads'
Expand Down Expand Up @@ -129,6 +153,9 @@ const moduleWrapper = tsserver => {
typeof parsedMessage.arguments.hostInfo === `string`
) {
hostInfo = parsedMessage.arguments.hostInfo;
if (hostInfo === `vscode` && process.env.VSCODE_IPC_HOOK && process.env.VSCODE_IPC_HOOK.match(/Code\/1\.[1-5][0-9]\./)) {
hostInfo += ` <1.61`;
}
}

return originalOnMessage.call(this, JSON.stringify(parsedMessage, (key, value) => {
Expand Down
2 changes: 1 addition & 1 deletion .yarn/sdks/typescript/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "typescript",
"version": "4.3.5-sdk",
"version": "4.4.4-sdk",
"main": "./lib/typescript.js",
"type": "commonjs"
}
3 changes: 1 addition & 2 deletions .yarnrc.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
yarnPath: ".yarn/releases/yarn-berry.cjs"

yarnPath: .yarn/releases/yarn-berry.cjs
enableGlobalCache: true
nmMode: hardlinks-global

0 comments on commit 0ef7ba4

Please sign in to comment.