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

lint: increased line-length #444

Merged
merged 1 commit into from
Nov 15, 2024
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
1 change: 1 addition & 0 deletions .prettierrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"tabWidth": 2,
"trailingComma": "es5",
"parser": "typescript",
"printWidth": 100,
"singleQuote": true,
"arrowParens": "avoid"
}
4 changes: 1 addition & 3 deletions packages/decorators/src/plugin/autocmd.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,7 @@ export function Autocmd(name: string, options?: AutocmdOptions) {
}
});

const nameWithPattern = `${name}${
options?.pattern ? `:${options.pattern}` : ''
}`;
const nameWithPattern = `${name}${options?.pattern ? `:${options.pattern}` : ''}`;
Object.defineProperty(f, NVIM_METHOD_NAME, {
value: `autocmd:${nameWithPattern}`,
});
Expand Down
17 changes: 3 additions & 14 deletions packages/decorators/src/plugin/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,7 @@

import { Neovim, NvimPlugin } from 'neovim';
import { NVIM_SPEC } from './properties';
import {
PluginOptions,
AutocmdOptions,
CommandOptions,
FunctionOptions,
} from './types';
import { PluginOptions, AutocmdOptions, CommandOptions, FunctionOptions } from './types';

interface Spec {
type: 'function' | 'autocmd' | 'command';
Expand Down Expand Up @@ -57,11 +52,7 @@ function wrapper(cls: PluginWrapperConstructor, options?: PluginOptions): any {
autoCmdOpts.eval = spec.opts.eval;
}

plugin.registerAutocmd(
spec.name,
[this, method],
autoCmdOpts as any
);
plugin.registerAutocmd(spec.name, [this, method], autoCmdOpts as any);
break;
case 'command':
const cmdOpts: CommandOptions = {
Expand Down Expand Up @@ -134,7 +125,5 @@ export function Plugin(outter: any): any {
*
* Plugin(TestPlugin)
*/
return typeof outter !== 'function'
? (cls: any) => wrapper(cls, outter)
: wrapper(outter);
return typeof outter !== 'function' ? (cls: any) => wrapper(cls, outter) : wrapper(outter);
}
47 changes: 16 additions & 31 deletions packages/integration-tests/src/factory.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,27 +51,20 @@ describe('Plugin Factory (used by host)', () => {
});

it('should collect the handlers from a plugin', async () => {
expect(await pluginObj.handleRequest('Func', 'function', ['town'])).toEqual(
'Funcy town'
);
expect(await pluginObj.handleRequest('Func', 'function', ['town'])).toEqual('Funcy town');
});

it('should load the plugin a sandbox', async () => {
expect(
await pluginObj.handleRequest('Global', 'function', ['loaded'])
).toEqual(true);
expect(
await pluginObj.handleRequest('Global', 'function', ['Buffer'])
).not.toEqual(undefined);
expect(
await pluginObj.handleRequest('Global', 'function', ['process'])
).not.toContain(['chdir', 'exit']);
expect(await pluginObj.handleRequest('Global', 'function', ['loaded'])).toEqual(true);
expect(await pluginObj.handleRequest('Global', 'function', ['Buffer'])).not.toEqual(undefined);
expect(await pluginObj.handleRequest('Global', 'function', ['process'])).not.toContain([
'chdir',
'exit',
]);
});

it('should load files required by the plugin in a sandbox', async () => {
expect(
await pluginObj.handleRequest('Global', 'function', ['required'])
).toEqual('you bet!');
expect(await pluginObj.handleRequest('Global', 'function', ['required'])).toEqual('you bet!');
// expect(
// Object.keys(required.globals.process),
// ).not.toContain(
Expand All @@ -94,10 +87,7 @@ describe('Plugin Factory (decorator api)', () => {
let pluginObj: NvimPlugin;

beforeEach(() => {
const p = loadPlugin(
'@neovim/example-plugin-decorators',
getFakeNvimClient()
);
const p = loadPlugin('@neovim/example-plugin-decorators', getFakeNvimClient());
if (!p) {
throw new Error();
}
Expand Down Expand Up @@ -126,24 +116,19 @@ describe('Plugin Factory (decorator api)', () => {
});

it('should collect the handlers from a plugin', async () => {
expect(await pluginObj.handleRequest('Func', 'function', ['town'])).toEqual(
'Funcy town'
);
expect(await pluginObj.handleRequest('Func', 'function', ['town'])).toEqual('Funcy town');
});

it('should load the plugin a sandbox', async () => {
expect(
await pluginObj.handleRequest('Global', 'function', ['loaded'])
).toEqual(true);
expect(
await pluginObj.handleRequest('Global', 'function', ['process'])
).not.toContain(['chdir', 'exit']);
expect(await pluginObj.handleRequest('Global', 'function', ['loaded'])).toEqual(true);
expect(await pluginObj.handleRequest('Global', 'function', ['process'])).not.toContain([
'chdir',
'exit',
]);
});

it('should load files required by the plugin in a sandbox', async () => {
expect(
await pluginObj.handleRequest('Global', 'function', ['required'])
).toEqual('you bet!');
expect(await pluginObj.handleRequest('Global', 'function', ['required'])).toEqual('you bet!');
// expect(
// Object.keys(required.globals.process),
// ).not.toContain(
Expand Down
22 changes: 3 additions & 19 deletions packages/neovim/src/api/Base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,7 @@ export class BaseApi extends EventEmitter {
// Node Buffer
protected client: any;

constructor({
transport,
data,
logger,
metadata,
client,
}: BaseConstructorOptions) {
constructor({ transport, data, logger, metadata, client }: BaseConstructorOptions) {
super();

this.transport = transport;
Expand Down Expand Up @@ -75,12 +69,7 @@ export class BaseApi extends EventEmitter {
try {
logData =
res && typeof res === 'object'
? partialClone(
res,
2,
['logger', 'transport', 'client'],
'[Object]'
)
? partialClone(res, 2, ['logger', 'transport', 'client'], '[Object]')
: res;
} catch {
logData = String(res);
Expand Down Expand Up @@ -108,12 +97,7 @@ export class BaseApi extends EventEmitter {
return this[DO_REQUEST](name, args).catch(err => {
// XXX: Get a `*.ts stacktrace. If we re-throw `err` we get a `*.js` trace. tsconfig issue?
const newError = new Error(err.message);
this.logger.error(
`failed request to "%s": %s: %s`,
name,
newError.name,
newError.message
);
this.logger.error(`failed request to "%s": %s: %s`, name, newError.name, newError.message);
throw newError;
});
}
Expand Down
95 changes: 17 additions & 78 deletions packages/neovim/src/api/Buffer.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,7 @@ describe('Buffer API', () => {

// utility to allow each test to be run in its
// own buffer
function withBuffer(
lines: string[],
test: (buffer: Buffer) => Promise<void>
) {
function withBuffer(lines: string[], test: (buffer: Buffer) => Promise<void>) {
return async () => {
await nvim.command('new!');

Expand Down Expand Up @@ -118,38 +115,18 @@ describe('Buffer API', () => {

it(
'replaces the right lines',
withBuffer(
['0', '1', '2', '3', '4', '5', '6', '7', '8', '9'],
async buffer => {
await buffer.replace(['a', 'b', 'c'], 2);

expect(await buffer.lines).toEqual([
'0',
'1',
'a',
'b',
'c',
'5',
'6',
'7',
'8',
'9',
]);
}
)
withBuffer(['0', '1', '2', '3', '4', '5', '6', '7', '8', '9'], async buffer => {
await buffer.replace(['a', 'b', 'c'], 2);

expect(await buffer.lines).toEqual(['0', '1', 'a', 'b', 'c', '5', '6', '7', '8', '9']);
})
);

it(
'inserts line at index 2',
withBuffer(['test', 'bar', 'bar', 'bar'], async buffer => {
buffer.insert(['foo'], 2);
expect(await buffer.lines).toEqual([
'test',
'bar',
'foo',
'bar',
'bar',
]);
expect(await buffer.lines).toEqual(['test', 'bar', 'foo', 'bar', 'bar']);
})
);

Expand Down Expand Up @@ -192,13 +169,7 @@ describe('Buffer API', () => {
withBuffer(['test', 'bar', 'foo'], async buffer => {
await buffer.append(['test', 'test']);

expect(await buffer.lines).toEqual([
'test',
'bar',
'foo',
'test',
'test',
]);
expect(await buffer.lines).toEqual(['test', 'bar', 'foo', 'test', 'test']);
})
);

Expand Down Expand Up @@ -307,26 +278,12 @@ describe('Buffer API', () => {

it(
'replaces the right lines',
withBuffer(
['0', '1', '2', '3', '4', '5', '6', '7', '8', '9'],
async () => {
const buffer = await nvim.buffer;
await buffer.replace(['a', 'b', 'c'], 2);

expect(await buffer.lines).toEqual([
'0',
'1',
'a',
'b',
'c',
'5',
'6',
'7',
'8',
'9',
]);
}
)
withBuffer(['0', '1', '2', '3', '4', '5', '6', '7', '8', '9'], async () => {
const buffer = await nvim.buffer;
await buffer.replace(['a', 'b', 'c'], 2);

expect(await buffer.lines).toEqual(['0', '1', 'a', 'b', 'c', '5', '6', '7', '8', '9']);
})
);

it(
Expand All @@ -352,13 +309,7 @@ describe('Buffer API', () => {
withBuffer(['test', 'bar', 'bar', 'bar'], async () => {
const buffer = await nvim.buffer;
await buffer.insert(['foo'], 2);
expect(await buffer.lines).toEqual([
'test',
'bar',
'foo',
'bar',
'bar',
]);
expect(await buffer.lines).toEqual(['test', 'bar', 'foo', 'bar', 'bar']);
})
);

Expand All @@ -376,13 +327,7 @@ describe('Buffer API', () => {
withBuffer(['test', 'bar', 'foo'], async () => {
const buffer = await nvim.buffer;
await buffer.append(['test', 'test']);
expect(await buffer.lines).toEqual([
'test',
'bar',
'foo',
'test',
'test',
]);
expect(await buffer.lines).toEqual(['test', 'bar', 'foo', 'test', 'test']);
})
);

Expand Down Expand Up @@ -477,13 +422,7 @@ describe('Buffer event updates', () => {
const promise = new Promise<void>(resolve => {
const unlisten = buffer.listen(
'lines',
async (
currentBuffer: Buffer,
tick: number,
start: number,
end: number,
data: string[]
) => {
async (currentBuffer: Buffer, tick: number, start: number, end: number, data: string[]) => {
expect(await currentBuffer.name).toBe(bufferName);
expect(start).toBe(1);
expect(end).toBe(1);
Expand Down
Loading