Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: actually run prettier #2359

Merged
merged 1 commit into from
Feb 4, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
27 changes: 17 additions & 10 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,19 +31,26 @@ function runPrettier(command, cb) {
var exec = require('child_process').exec;
exec(command, function(err, stdout, stderr) {
if (err) {
cb(err);
return;
return cb(err);
}

const files = stdout.split('\n');
for (const file of files) {
if (file.endsWith('.ts') || file.endsWith('.js')) {
exec(
`node ./node_modules/.bin/prettier --write --print-width 100 --single-quote --trailing-comma es5 ${file}`,
cb
);
}
if (!stdout) {
return cb();
}

var files = stdout
.split('\n')
.filter(f => {
return f.endsWith('.ts') || f.endsWith('.js');
})
.join(' ');

exec(
`node ./node_modules/.bin/prettier --write --print-width 100 --single-quote --trailing-comma es5 ${files}`,
function(err, stdout, stderr) {
cb(err);
}
);
});
}

Expand Down
6 changes: 3 additions & 3 deletions src/cmd_line/commands/setoptions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,13 +77,13 @@ export class SetOptionsCommand extends node.CommandBase {
configuration[this._arguments.name] = false;
break;
case SetOptionOperator.Equal:
configuration[this._arguments.name] = this._arguments.value!;
configuration[this._arguments.name] = this._arguments.value!;
break;
case SetOptionOperator.Invert:
configuration[this._arguments.name] = !configuration[this._arguments.name];
configuration[this._arguments.name] = !configuration[this._arguments.name];
break;
case SetOptionOperator.Append:
configuration[this._arguments.name] += this._arguments.value!;
configuration[this._arguments.name] += this._arguments.value!;
break;
case SetOptionOperator.Subtract:
if (typeof this._arguments.value! === 'number') {
Expand Down
6 changes: 4 additions & 2 deletions src/configuration/configuration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,9 @@ class Configuration implements IConfiguration {
}

reload() {
let vimConfigs: any = Globals.isTesting ? Globals.mockConfiguration : this.getConfiguration('vim');
let vimConfigs: any = Globals.isTesting
? Globals.mockConfiguration
: this.getConfiguration('vim');

/* tslint:disable:forin */
// Disable forin rule here as we make accessors enumerable.`
Expand Down Expand Up @@ -295,7 +297,7 @@ class Configuration implements IConfiguration {
replace: undefined,
};

get modeToCursorStyleMap() : IModeSpecificStrings<vscode.TextEditorCursorStyle> {
get modeToCursorStyleMap(): IModeSpecificStrings<vscode.TextEditorCursorStyle> {
let map = <IModeSpecificStrings<vscode.TextEditorCursorStyle>>{};

Object.keys(this.cursorStylePerMode).forEach(k => {
Expand Down
14 changes: 7 additions & 7 deletions src/configuration/iconfiguration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,18 +73,18 @@ export interface IConfiguration {
easymotionMarkerBackgroundColor: string;
easymotionMarkerForegroundColorOneChar: string;
easymotionMarkerForegroundColorTwoChar: string;
easymotionMarkerWidthPerChar : number;
easymotionMarkerHeight : number;
easymotionMarkerWidthPerChar: number;
easymotionMarkerHeight: number;
easymotionMarkerFontFamily: string;
easymotionMarkerFontSize: string;
easymotionMarkerFontWeight: string;
easymotionMarkerYOffset : number;
easymotionMarkerYOffset: number;
easymotionKeys: string;

/**
* Timeout in milliseconds for remapped commands.
*/
timeout : number;
timeout: number;

/**
* Display partial commands on status bar?
Expand All @@ -99,12 +99,12 @@ export interface IConfiguration {
/**
* What key should <leader> map to in key remappings?
*/
leader : string;
leader: string;

/**
* How much search or command history should be remembered
*/
history : number;
history: number;

/**
* Show results of / or ? search as user is typing?
Expand Down Expand Up @@ -200,4 +200,4 @@ export interface IConfiguration {
insertModeKeyBindingsNonRecursive: IKeyRemapping[];
otherModesKeyBindings: IKeyRemapping[];
otherModesKeyBindingsNonRecursive: IKeyRemapping[];
}
}
4 changes: 3 additions & 1 deletion src/mode/modeHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1266,7 +1266,9 @@ export class ModeHandler implements vscode.Disposable {
cursorStyle = configuration.userCursor;
}

cursorStyle = configuration.modeToCursorStyleMap[this.currentMode.friendlyName.toLowerCase()] || cursorStyle;
cursorStyle =
configuration.modeToCursorStyleMap[this.currentMode.friendlyName.toLowerCase()] ||
cursorStyle;

let options = this.vimState.editor.options;
options.cursorStyle = cursorStyle;
Expand Down
7 changes: 6 additions & 1 deletion test/cmd_line/substitute.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,12 @@ import { getAndUpdateModeHandler } from '../../extension';
import { CommandLine } from '../../src/cmd_line/commandLine';
import { Globals } from '../../src/globals';
import { ModeHandler } from '../../src/mode/modeHandler';
import { assertEqualLines, cleanUpWorkspace, reloadConfiguration, setupWorkspace } from './../testUtils';
import {
assertEqualLines,
cleanUpWorkspace,
reloadConfiguration,
setupWorkspace,
} from './../testUtils';

suite('Basic substitute', () => {
let modeHandler: ModeHandler;
Expand Down
7 changes: 6 additions & 1 deletion test/cmd_line/vsplit.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,12 @@ import * as vscode from 'vscode';
import { getAndUpdateModeHandler } from '../../extension';
import { CommandLine } from '../../src/cmd_line/commandLine';
import { ModeHandler } from '../../src/mode/modeHandler';
import { assertEqual, cleanUpWorkspace, setupWorkspace, WaitForEditorsToClose } from './../testUtils';
import {
assertEqual,
cleanUpWorkspace,
setupWorkspace,
WaitForEditorsToClose,
} from './../testUtils';

suite('Vertical split', () => {
let modeHandler: ModeHandler;
Expand Down
7 changes: 6 additions & 1 deletion test/cmd_line/writequit.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,12 @@ import * as vscode from 'vscode';
import { getAndUpdateModeHandler } from '../../extension';
import { CommandLine } from '../../src/cmd_line/commandLine';
import { ModeHandler } from '../../src/mode/modeHandler';
import { assertEqual, cleanUpWorkspace, setupWorkspace, WaitForEditorsToClose } from './../testUtils';
import {
assertEqual,
cleanUpWorkspace,
setupWorkspace,
WaitForEditorsToClose,
} from './../testUtils';

suite('Basic write-quit', () => {
let modeHandler: ModeHandler;
Expand Down
13 changes: 7 additions & 6 deletions test/configuration/configuration.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,13 @@ import { reloadConfiguration } from '../testUtils';
suite('Configuration', () => {
suiteSetup(() => {
let configuration = new testConfiguration.Configuration();
configuration.leader = "<space>";
configuration.leader = '<space>';
configuration.otherModesKeyBindingsNonRecursive = [
{
"before": ["leader", "o"],
"after": ["o", "eSc", "k"]
}];
before: ['leader', 'o'],
after: ['o', 'eSc', 'k'],
},
];

Globals.mockConfiguration = configuration;
reloadConfiguration();
Expand All @@ -24,7 +25,7 @@ suite('Configuration', () => {
let keybindings = configuration.otherModesKeyBindingsNonRecursive;

assert.equal(keybindings.length, 1);
assert.deepEqual(keybindings[0].before, [" ", "o"]);
assert.deepEqual(keybindings[0].after, ["o", "<Esc>", "k"]);
assert.deepEqual(keybindings[0].before, [' ', 'o']);
assert.deepEqual(keybindings[0].after, ['o', '<Esc>', 'k']);
});
});
36 changes: 20 additions & 16 deletions test/configuration/remapper.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,24 @@ import { assertEqual, setupWorkspace, cleanUpWorkspace } from '../testUtils';
suite('Remapper', () => {
let modeHandler: ModeHandler;
const leaderKey = '\\';
const insertModeKeyBindings = [{
"before": ["j", "j"],
"after": ["<Esc>"]
}];
const otherModeKeysRebindings = [{
"before": ["leader", "w"],
"after": [],
"commands": [
{
"command": "workbench.action.closeActiveEditor",
"args": []
},
]
}];
const insertModeKeyBindings = [
{
before: ['j', 'j'],
after: ['<Esc>'],
},
];
const otherModeKeysRebindings = [
{
before: ['leader', 'w'],
after: [],
commands: [
{
command: 'workbench.action.closeActiveEditor',
args: [],
},
],
},
];

setup(async () => {
let configuration = new Configuration();
Expand All @@ -47,7 +51,7 @@ suite('Remapper', () => {
// act
let actual = false;
try {
actual = await remapper.sendKey(["j", "j"], modeHandler, modeHandler.vimState);
actual = await remapper.sendKey(['j', 'j'], modeHandler, modeHandler.vimState);
} catch (e) {
assert.fail(e);
}
Expand All @@ -65,7 +69,7 @@ suite('Remapper', () => {
// act
let actual = false;
try {
actual = await remapper.sendKey([leaderKey, "w"], modeHandler, modeHandler.vimState);
actual = await remapper.sendKey([leaderKey, 'w'], modeHandler, modeHandler.vimState);
} catch (e) {
assert.fail(e);
}
Expand Down
12 changes: 8 additions & 4 deletions test/extension.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,16 @@ suite('package.json', () => {

// configuration
let handlers = Object.keys(srcConfiguration.configuration);
let unhandled = _.filter(keys, k => { return handlers.indexOf(k) >= 0; });
assert.equal(unhandled, 0, 'Missing src handlers for ' + unhandled.join(","));
let unhandled = _.filter(keys, k => {
return handlers.indexOf(k) >= 0;
});
assert.equal(unhandled, 0, 'Missing src handlers for ' + unhandled.join(','));

// test configuration
handlers = Object.keys(new testConfiguration.Configuration());
unhandled = _.filter(keys, k => { return handlers.indexOf(k) >= 0; });
assert.equal(unhandled, 0, 'Missing test handlers for ' + unhandled.join(","));
unhandled = _.filter(keys, k => {
return handlers.indexOf(k) >= 0;
});
assert.equal(unhandled, 0, 'Missing test handlers for ' + unhandled.join(','));
});
});
8 changes: 7 additions & 1 deletion test/mode/modeVisual.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,13 @@ import { ModeName } from '../../src/mode/mode';
import { ModeHandler } from '../../src/mode/modeHandler';
import { TextEditor } from '../../src/textEditor';
import { getTestingFunctions } from '../testSimplifier';
import { assertEqual, assertEqualLines, cleanUpWorkspace, reloadConfiguration, setupWorkspace } from './../testUtils';
import {
assertEqual,
assertEqualLines,
cleanUpWorkspace,
reloadConfiguration,
setupWorkspace,
} from './../testUtils';

suite('Mode Visual', () => {
let modeHandler: ModeHandler;
Expand Down
5 changes: 4 additions & 1 deletion test/plugins/easymotion.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
import { getAndUpdateModeHandler } from '../../extension';
import { buildTriggerKeys, EasymotionTrigger } from '../../src/actions/plugins/easymotion/easymotion.cmd';
import {
buildTriggerKeys,
EasymotionTrigger,
} from '../../src/actions/plugins/easymotion/easymotion.cmd';
import { ModeHandler } from '../../src/mode/modeHandler';
import { Configuration } from '../testConfiguration';
import { getTestingFunctions } from '../testSimplifier';
Expand Down
13 changes: 6 additions & 7 deletions test/testConfiguration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,12 @@ export class Configuration implements IConfiguration {
startInInsertMode = false;
statusBarColorControl = false;
statusBarColors: {
normal: '#005f5f',
insert: '#5f0000',
visual: '#5f00af',
visualline: '#005f87',
visualblock: '#86592d',
replace: '#000000',
normal: '#005f5f';
insert: '#5f0000';
visual: '#5f00af';
visualline: '#005f87';
visualblock: '#86592d';
replace: '#000000';
};
searchHighlightColor = 'rgba(150, 150, 255, 0.3)';
tabstop = 2;
Expand Down Expand Up @@ -67,4 +67,3 @@ export class Configuration implements IConfiguration {
otherModesKeyBindings: IKeyRemapping[] = [];
otherModesKeyBindingsNonRecursive: IKeyRemapping[] = [];
}

9 changes: 6 additions & 3 deletions test/testUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,10 @@ export function assertEqual<T>(one: T, two: T, message: string = ''): void {
assert.equal(one, two, message);
}

export async function setupWorkspace(config: IConfiguration = new Configuration(), fileExtension: string = ''): Promise<any> {
export async function setupWorkspace(
config: IConfiguration = new Configuration(),
fileExtension: string = ''
): Promise<any> {
const file = await createRandomFile('', fileExtension);
const doc = await vscode.workspace.openTextDocument(file);

Expand Down Expand Up @@ -114,8 +117,8 @@ export async function cleanUpWorkspace(): Promise<any> {
}
);
}).then(() => {
assert.equal(vscode.window.visibleTextEditors.length, 0, "Expected all editors closed.");
assert(!vscode.window.activeTextEditor, "Expected no active text editor.");
assert.equal(vscode.window.visibleTextEditors.length, 0, 'Expected all editors closed.');
assert(!vscode.window.activeTextEditor, 'Expected no active text editor.');
});
}

Expand Down