Skip to content

Commit

Permalink
Merge pull request #99 from d-kimuson/feature/v1
Browse files Browse the repository at this point in the history
Feature/v1
  • Loading branch information
d-kimuson authored Jan 22, 2023
2 parents bf4fcb4 + b3fa0fa commit 9dcd56f
Show file tree
Hide file tree
Showing 120 changed files with 8,090 additions and 2,828 deletions.
4 changes: 2 additions & 2 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
*rc.js
*.config.js
*.js
*.(c|m)js
105 changes: 105 additions & 0 deletions .eslintrc.base.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
module.exports = {
root: true,
parser: "@typescript-eslint/parser",
parserOptions: {
ecmaVersion: 6,
sourceType: "module",
project: "./**/(tsconfig|tsconfig.test).json",
},
extends: [
"eslint:recommended",
"plugin:@typescript-eslint/recommended",
"prettier",
],
plugins: ["@typescript-eslint", "import"],
settings: {
"import/resolver": {
typescript: {
alwaysTryTypes: true,
},
},
},
env: {
node: true,
jest: true,
},
rules: {
// typescript
// "@typescript-eslint/explicit-function-return-type": "error",
"@typescript-eslint/explicit-module-boundary-types": "error",
"@typescript-eslint/no-unused-vars": [
"error",
{
varsIgnorePattern: "^_",
argsIgnorePattern: "^_",
args: "after-used",
},
],
"@typescript-eslint/ban-ts-comment": [
"error",
{
"ts-expect-error": "allow-with-description",
"ts-ignore": true,
"ts-nocheck": "allow-with-description",
"ts-check": false,
minimumDescriptionLength: 1,
},
],
"@typescript-eslint/explicit-member-accessibility": "warn",
"@typescript-eslint/prefer-ts-expect-error": "error",
"@typescript-eslint/consistent-type-imports": "error",
"@typescript-eslint/no-non-null-assertion": "error",
"@typescript-eslint/prefer-nullish-coalescing": "error",
"@typescript-eslint/no-explicit-any": [
"error",
{
fixToUnknown: true,
},
],
"@typescript-eslint/consistent-type-definitions": ["error", "type"],
"@typescript-eslint/method-signature-style": ["error", "property"],
"@typescript-eslint/prefer-for-of": "error",
"@typescript-eslint/no-unnecessary-condition": "error",
"@typescript-eslint/no-unnecessary-boolean-literal-compare": "error",
// common
"no-console": "warn",
"import/order": [
"error",
{
groups: [
"builtin",
"external",
"type",
"internal",
"parent",
"index",
"sibling",
"object",
"unknown",
],
pathGroups: [
{
pattern: "~/**",
group: "internal",
position: "before",
},
],
alphabetize: {
order: "asc",
},
"newlines-between": "never",
},
],
},
overrides: [
{
files: ["**/*.type.ts", "**/*.type-test.ts", "**/types/*.ts"],
rules: {
"@typescript-eslint/no-explicit-any": "off",
"@typescript-eslint/ban-types": "off",
"@typescript-eslint/no-unused-vars": "off",
},
},
],
ignorePatterns: ["**/*.d.ts"],
}
36 changes: 0 additions & 36 deletions .eslintrc.js

This file was deleted.

9 changes: 6 additions & 3 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,14 @@ jobs:
run: |
yarn install
- name: check source codes (typecheck & eslint & prettier)
- name: check source codes (linter)
run: |
yarn typecheck
yarn lint
- name: build check
run: |
yarn build
- name: test
run: |
yarn test:jest
yarn test
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,8 @@ node_modules
*.vsix

src/run.ts

.history
yarn-error.log

logs
9 changes: 9 additions & 0 deletions .husky/prepare-commit-msg
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

first_line=$(head -n1 $1)
if [ "${first_line}" != "" ]; then
exit 0
fi

exec < /dev/tty && node_modules/.bin/cz --hook || true
39 changes: 39 additions & 0 deletions .lintstagedrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
// @ts-check

/**
* @param {string[]} relPaths
* @param {string} packageName
*/
function parsePackagePaths(relPaths, packageName) {
return relPaths
.map((file) => file.replace(`packages/${packageName}/`, "./"))
.join(" ")
}

module.exports = {
/**
* @param {string[]} relPaths
* @returns {string[]}
*/
"packages/ts-type-expand/*.ts": (relPaths) => {
return [
`yarn --cwd 'packages/ts-type-expand' eslint --fix ${parsePackagePaths(
relPaths,
"ts-type-expand"
)}`,
]
},
/**
* @param {string[]} relPaths
* @returns {string[]}
*/
"packages/example/*.ts": (relPaths) => {
return [
`yarn --cwd 'packages/example' eslint --fix ${parsePackagePaths(
relPaths,
"example"
)}`,
]
},
"*.{js,json,md}": ["yarn prettier --write"],
}
15 changes: 10 additions & 5 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,24 @@
"name": "Run Extension",
"type": "extensionHost",
"request": "launch",
"args": ["--extensionDevelopmentPath=${workspaceFolder}"],
"outFiles": ["${workspaceFolder}/out/**/*.js"],
"args": [
"--profile-temp",
"--extensionDevelopmentPath=${workspaceFolder}/packages/ts-type-expand"
],
"outFiles": ["${workspaceFolder}/packages/ts-type-expand/out/**/*.js"],
"preLaunchTask": "${defaultBuildTask}"
},
{
"name": "Extension Tests",
"type": "extensionHost",
"request": "launch",
"args": [
"--extensionDevelopmentPath=${workspaceFolder}",
"--extensionTestsPath=${workspaceFolder}/out/test/suite/index"
"--extensionDevelopmentPath=${workspaceFolder}/packages/ts-type-expand",
"--extensionTestsPath=${workspaceFolder}/packages/ts-type-expand/out/test/suite/index"
],
"outFiles": [
"${workspaceFolder}/packages/ts-type-expand/out/test/**/*.js"
],
"outFiles": ["${workspaceFolder}/out/test/**/*.js"],
"preLaunchTask": "${defaultBuildTask}"
}
]
Expand Down
29 changes: 22 additions & 7 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
// Place your settings in this file to overwrite default and user settings.
{
"editor.tabSize": 2,
// typescript
"typescript.tsdk": "node_modules/typescript/lib",
"ts-type-expand.validate": [
"typescript",
"typescriptreact",
"javascript",
"javascriptreact"
],
// ESLint
"eslint.workingDirectories": ["./"],
"eslint.options": {
"configFile": ".eslintrc.js",
"extensions": ["ts", "js"]
},
"eslint.validate": ["javascript", "typescript"],
"eslint.workingDirectories": ["./packages/*"],
"eslint.alwaysShowStatus": true,
"editor.codeActionsOnSave": {
"source.fixAll.eslint": true
Expand Down Expand Up @@ -42,5 +45,17 @@
"out": true // set this to false to include "out" folder in search results
},
// Turn off tsc task auto detection since we have the necessary tasks as npm scripts
"typescript.tsc.autoDetect": "off"
"typescript.tsc.autoDetect": "off",
"cSpell.words": [
"decycle",
"encycle",
"esbuild",
"kimuson",
"outdir",
"pino",
"postbuild",
"TRPC",
"tsserverlibrary",
"Varibale"
]
}
2 changes: 1 addition & 1 deletion .vscode/tasks.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"tasks": [
{
"type": "npm",
"script": "watch",
"script": "dev",
"problemMatcher": "$tsc-watch",
"isBackground": true,
"presentation": {
Expand Down
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2021 @d-kimuson

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
34 changes: 24 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# ts-type-expand for VSCode

:memo: ts-type-expand is now v1 and the mechanism behind it has changed. You can downgrade to v0.12 if you find it inconvenient.

VSCode extension that allows you to expand TypeScript type definitions.

- Displays the type information of the selected node
Expand All @@ -13,8 +15,6 @@ You can install this extension from the [ts-type-expand - Visual Studio Marketpl

There is nothing additional that needs to be installed.

If `tsconfig.json` is not directly under your workspace, specify the path with the `ts-type-expand.tsconfigPath` option. See [Configure](#Configure) for other valid options.

## Supports

### Expansion
Expand Down Expand Up @@ -50,19 +50,19 @@ Types are calculated by the [CompilerAPI](https://github.com/Microsoft/TypeScrip

### Others

- Vue is not supported (not tried)
- React also works, but there can be problems with component types
- SFC for Vue is not supported
- React is supported.

## Configure

Configure `ts-type-expand.*` to your vscode config to customize.

| key | value | default |
| :---------------------- | :------------------------------------------------------------------------------------------------------ | ------------- |
| `tsconfigPath` | Path for `tsconfig.json` | tsconfig.json |
| `compactOptionalType` | display `T?` for type T \| undefined | true |
| `compactPropertyLength` | Omit when the type can be expanded and the number of characters of the type is longer than this length. | 10 |
| `directExpandArray` | Directly expand T for Array\<T\> | true |
| key | value | default |
| :---------------------- | :------------------------------------------------------------------------------------------------------ | -------------------------------------------------------------------- | ------ |
| `compactOptionalType` | display `T?` for type `T | undefined` | `true` |
| `compactPropertyLength` | Omit when the type can be expanded and the number of characters of the type is longer than this length. | `10` |
| `directExpandArray` | Directly expand T for `Array<T>` | `true` |
| `validate` | Validate by specifying languageId | `["typescript", "typescriptreact", "javascript", "javascriptreact"]` |

In order for these settings to take effect, you need to run `ts-type-expand.restart` or reload the VSCode after making the changes.

Expand All @@ -75,3 +75,17 @@ In order for these settings to take effect, you need to run `ts-type-expand.rest
## License

MIT

## Contribute

Welcome.

### :memo:

For debugging purposes, it is recommended to put a symbolic link to the directory where the logs are written.

```bash
$ ln -s ~/.ts-type-expand/logs ./logs
```

To start the debugger in a plain environment, you must enable `Workbench > Experimental > Settings Profile`. This setting does not exist in the per-workspace settings, only in the user settings, and must be set individually by the developer.
Loading

0 comments on commit 9dcd56f

Please sign in to comment.