Skip to content

Organize imports should not remove blank lines before first import #22724

@mjbvz

Description

@mjbvz

TypeScript Version: 2.8.0-dev20180320

Search Terms:

  • Organize imports

Code
For the js

/*---------------------------------------------------------------------------------------------
 *  Copyright (c) Microsoft Corporation. All rights reserved.
 *  Licensed under the MIT License. See License.txt in the project root for license information.
 *--------------------------------------------------------------------------------------------*/

import * as fs from 'fs'

fs.writeFileSync('a', 'x')

Run organize imports

Expected behavior:
No change. Imports already organized

Actual behavior:
The blank line before the import is removed:

/*---------------------------------------------------------------------------------------------
 *  Copyright (c) Microsoft Corporation. All rights reserved.
 *  Licensed under the MIT License. See License.txt in the project root for license information.
 *--------------------------------------------------------------------------------------------*/
import * as fs from 'fs';

fs.writeFileSync('a', 'x')

Trace:

[Trace  - 10:44:05 AM] Response received: organizeImports (136). Request took 3 ms. Success: true 
Result: [
    {
        "fileName": "/Users/matb/projects/san/index.js",
        "textChanges": [
            {
                "start": {
                    "line": 1,
                    "offset": 1
                },
                "end": {
                    "line": 7,
                    "offset": 1
                },
                "newText": "/*---------------------------------------------------------------------------------------------\n *  Copyright (c) Microsoft Corporation. All rights reserved.\n *  Licensed under the MIT License. See License.txt in the project root for license information.\n *--------------------------------------------------------------------------------------------*/\nimport * as fs from 'fs';\n"
            }
        ]
    }
]

Metadata

Metadata

Assignees

Labels

BugA bug in TypeScriptDomain: LS: Organize ImportsIssues with the organize imports featureFixedA PR has been merged for this issue

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions