Skip to content
This repository has been archived by the owner on Oct 10, 2018. It is now read-only.

Feature/awesome import manager #210

Merged
merged 56 commits into from
Jun 15, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
56 commits
Select commit Hold shift + click to select a range
0f0b9a8
add schema for setting
May 31, 2017
b858b8d
adding classes for import grouping
May 31, 2017
3d39095
change interface
May 31, 2017
b406b74
add barrel file
May 31, 2017
4996150
change from yarn lock to npm5
Jun 1, 2017
61bfb44
change commands
Jun 1, 2017
e2aa899
change prepare release script
Jun 1, 2017
e14c564
update travis script
Jun 1, 2017
65ed7a8
rename folder
Jun 1, 2017
41f5756
correct escaping
Jun 1, 2017
ca01ed1
adding first impl for module improts
Jun 1, 2017
eb00f5c
tests and code for keyword import group
Jun 1, 2017
d5e07ba
adding regex import group
Jun 1, 2017
2bb2acf
add remain import group
Jun 1, 2017
8129973
adding settings parser and error for not matching ones
Jun 1, 2017
eb3512a
add setting parser tests
Jun 1, 2017
16ee3d1
add remain grp to default
Jun 1, 2017
1f220d1
change ignore file
Jun 2, 2017
6dc4665
remove more stuff from extension
Jun 2, 2017
d374c41
code st yle, export type
Jun 2, 2017
5b04467
add more sofisticated info
Jun 2, 2017
102614f
adding import settings
Jun 2, 2017
86ff24a
do not cache (because of the array)
Jun 2, 2017
a906abc
add remain grp if no is specified, adding back some tests
Jun 2, 2017
68c6f01
upgrade deps
Jun 6, 2017
384d71f
refactor add imports
Jun 6, 2017
e408a48
adding method to add import groups
Jun 12, 2017
802f9e2
deps
Jun 12, 2017
ed45dfc
adding reset to groups
Jun 13, 2017
cd7f2c2
adding organize tests for group
Jun 13, 2017
98ae9cf
remove \n from import ts gen
Jun 13, 2017
f288dc1
try to generate code
Jun 13, 2017
0594666
correctly generating organized imports
Jun 13, 2017
868af0c
comment
Jun 13, 2017
86dd52e
changelog
Jun 14, 2017
3710923
remove "newImportLocation"
Jun 14, 2017
c8e51d1
add sortedImports property
Jun 14, 2017
97199be
generate the correct imports at the correct places (imp mgmt)
Jun 14, 2017
be5c231
add remaining as keyword and parsing for it
Jun 14, 2017
b2ee963
changelog
Jun 14, 2017
dcf9a8e
refactor code completion to use import manager
Jun 14, 2017
a260850
adding stringtemplate func and multiline comma import
Jun 14, 2017
aa0da9d
fix tests
Jun 14, 2017
a865d3f
update tests & code style
Jun 14, 2017
f2d6796
fix bug and change the tests to new import groups
Jun 14, 2017
4e8f110
improve performance for code completion
Jun 14, 2017
7796dde
documentation
Jun 15, 2017
1c28d83
rename commands
Jun 15, 2017
dd605a8
readme
Jun 15, 2017
aecc64d
explained old ver
Jun 15, 2017
b652bea
upgrade dependencies
Jun 15, 2017
f458f12
Revert "upgrade dependencies"
Jun 15, 2017
5143b11
package log
Jun 15, 2017
e132015
upgrade tslint (npm 5)
Jun 15, 2017
fde166a
code style
Jun 15, 2017
2955b54
Fix/upgrade vscode deps (#212)
buehler Jun 15, 2017
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,14 @@ sudo: false

language: node_js
node_js:
- '7'
- '8'

env:
global:
- CODE_TESTS_WORKSPACE=$TRAVIS_BUILD_DIR/test/_workspace
- secure: ZFxa817TgXMaJc/zC0PUHFqPt4aSXJxuMAXpsthyZyCMC0M2HAyZH14fDf8o7LX24q90EO6eAn3/JRhHWyQK9MygM4wW3J5mTc4Hm/2sJpqmDgmwHaoa1jZSxf7bykb1dPvkdgR15U0Xd0vtmMVR0gY7yQ6pcRVUPO6TNceCsu6p1nUfPGBDjLAKAa5wdJhaxOmfKjoIyT36jrJ2U5lCs7YtYuJGSgu4wHBnVsNjZIYyA8cF6FNMYYe/lRTheCz9vE0IYlmXT5aPEQL2kWZRGyWZOzBbtQXI+5XVqlKNbao4l15K62BvKuBu70bOa9Hxz7nR2ycwcfcpdxiJeDbOYwF5zsXVYY633p3SngPrkKBOww6gqbkMDEN6dqkT7clSZzqHnlL/o35b8LKNwdO9pxqU5YFALFHMSms5zJpTo3TAz4wxlb6TZCJlk+9Y4QaE3JqwTRxfk0Xw79w6N6eQXY2qq0zmL4MMyu3Q0KTCRAYX9CoWEbDD4WanWrLyXTkQbkNO7rZ+nSbS7CmEnt4Zs8AlLqdtsdf93cw7LcDotWnLQ+Fj+hUnApivSJkcQCFpqaJqFJcUutkn70ziqPe3b/BZZtHsbc1Dvda2GLl9gR9jFh61wrlk2WM/Q5kr+BVfT5RtKMSXRrEasEjz15tS0EQMP1k7VXjGMV4P1b57i4A=

os:
#- osx
- linux

addons:
Expand All @@ -35,11 +34,13 @@ before_install:
fi

install:
- yarn install
- yarn run build
- npm install

before_script:
- npm run build

script:
- yarn test --silent
- npm test --silent

deploy:
provider: script
Expand Down
15 changes: 9 additions & 6 deletions .vscodeignore
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
.github/**
.vscode/**
.vscode-test/**
typings/**
out/test/**

.gitignore
package-lock.json
prepare-release.js

config/**
test/**
src/**
**/*.map
.gitignore
tsconfig.json
tslint.json
typings.json

*.vsix
_workspace/**
out/test/**
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,16 @@ All notable changes to this project will be documented in this file.
This project adheres to [Semantic Versioning](http://semver.org/).

## [Unreleased]
#### Added
- Import grouping, imports are now grouped and sorted (read the docs in README) ([#102](https://github.com/buehler/typescript-hero/issues/102))
- Option to add a trailing comma to a multiline import (at the last import) ([#100](https://github.com/buehler/typescript-hero/issues/100))

#### Changed
- Multiline import statement threshold to a new default value `125`, since github thinks this is a good value [source-code-line-length](http://hilton.org.uk/blog/source-code-line-length)

#### Removed
- `newImportLocation` setting, since the imports are grouped and sorted, the new import location is obsolete ([#102](https://github.com/buehler/typescript-hero/issues/102))

#### Fixed
- Default imports are removed regardless if they are used or not ([#149](https://github.com/buehler/typescript-hero/issues/149))
- Support for generic interfaces and abstract classes for the implement elements feature of the light bulb ([#158](https://github.com/buehler/typescript-hero/issues/158))
Expand Down
91 changes: 88 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ All commands are preceeded by `typescriptHero`.

| Command | Extension part | Description |
| ---------------------------- | --------------- | --------------------------------------------------------- |
| showCmdGui | general | Shows a small gui with all available internal commands |
| resolve.addImport | import resolver | Shows a pick list with all recognized, importable symbols |
| resolve.addImportUnderCursor | import resolver | Imports the symbol under the cursor |
| resolve.addMissingImports | import resolver | Imports all missing symbols for the actual document |
Expand Down Expand Up @@ -74,13 +73,14 @@ The following settings do have the prefix `resolver`. So an example setting coul

| Setting | Description |
| ------------------------------------- | ------------------------------------------------------------------------------------ |
| stringQuoteStyle | The string delimiter to use for the imports |
| stringQuoteStyle | The string delimiter to use for the imports (`'` or `"`) |
| ignorePatterns | If any of these strings is part of a file path, the file is ignored |
| insertSpaceBeforeAndAfterImportBraces | If the extension should place spaces into import braces (`{Symbol}` vs `{ Symbol }`) |
| insertSemicolons | If the extension should add a semicolon to the end of a statement |
| multiLineWrapThreshold | The threshold, when imports are converted into multiline imports |
| newImportLocation | The location of new imports (at the top of the file, or at the cursor location) |
| multiLineTrailingComma | When multiline imports are created, `true` inserts a trailing comma to the last line |
| disableImportSorting | Disable sorting during organize imports action |
| importGroups | The groups that are used for sorting the imports (description below) |

## Features (extended)

Expand All @@ -93,6 +93,91 @@ TypeScript Hero can manage your imports. It is capable of:
- Import all missing identifiers of the current file
- Remove unused imports and sort the remaining ones by alphabet

#### Import groups

The import groups setting allows you to order all your imports as you may want. The settings is an array of elements.
An element can either be a string (with a certain keyword or a regex like string) or an object that contains an
identifier (with a certain keyword or a regex like string) and a sort order. The order you enter those objects / string
does matter since it is used to define the import groups.

An example (complex) could be:

```json
[
"Plains",
"/@angular/",
{
"identifier": "/Foo[1-9]Bar/",
"order": "desc"
},
"Workspace",
{
"identifier": "Remaining",
"order": "desc"
}
]
```

##### Keyword imports

- `Modules` : contains all imports from modules (npm etc) `import ... from 'vscode';`
- `Plains` : contains all string only imports `import 'reflect-metadata;`
- `Workspace` : contains all local project files `import ... from '../server';`
- `Remaining` : contains all imports that are not matched by other import groups

(_hint_: The `Remaining` group is added implicitly as the last import group if not added specifically)

The default is as follows:

```json
[
"Plains",
"Modules",
"Workspace"
]
```

For everybody that just wants all imports ordered in asc or desc, just overwrite the default with:

For all imports sorted asc:
```json
[]
```

For all imports sorted desc:
```json
[
{
"identifier": "Remaining",
"order": "desc"
}
]
```

##### Regex imports

The regex import group contains a regex string. Let's say you want to group all your `@angular` namespaced imports together
in one group you'd use `/@angular/` as "identifier" (either in the object when you want to change the order or just
the plain regex since default order is `asc`).

(_hint_: only the name of the library is matched against the regex)

```json
[
"/@angular/"
]
```

The setting above would create two groups: one with all @angular imports another with all other imports.

```typescript
import {http} from '@angular/http';
import {component} from '@angular/core';

import 'reflect-metadata';
import {Server} from './server';
```

### Intellisense

Intellisense is a common IDE feature. TypeScript Hero provides you with symbols as you type your code
Expand Down
Loading