Skip to content

Commit

Permalink
format
Browse files Browse the repository at this point in the history
  • Loading branch information
romainmenke committed Jan 25, 2025
1 parent a137a21 commit 6002ba2
Show file tree
Hide file tree
Showing 31 changed files with 620 additions and 174 deletions.
15 changes: 8 additions & 7 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@
"postcss": "^8.4.31",
"postcss-sass": "^0.5.0",
"postcss-scss": "^4.0.9",
"prettier": "^3.2.5",
"prettier": "^3.4.2",
"stylelint": "^16.2.1",
"stylelint-processor-glamorous": "^0.3.0",
"stylelint-processor-styled-components": "^1.10.0",
Expand Down
4 changes: 3 additions & 1 deletion src/extension/__tests__/extension.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
jest.doMock('vscode', () => ({ workspace: {}, window: {}, commands: {} }), { virtual: true });
jest.doMock('vscode', () => ({ workspace: {}, window: {}, commands: {} }), {
virtual: true,
});
jest.mock('vscode-languageclient/node', () => ({
LanguageClient: jest.fn(),
SettingMonitor: jest.fn(),
Expand Down
4 changes: 3 additions & 1 deletion src/extension/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@ let client: LanguageClient;
export async function activate({ subscriptions }: ExtensionContext): Promise<PublicApi> {
const serverPath = path.join(__dirname, 'start-server.js');

const api = Object.assign(new EventEmitter(), { codeActionReady: false }) as PublicApi;
const api = Object.assign(new EventEmitter(), {
codeActionReady: false,
}) as PublicApi;

client = new LanguageClient(
'Stylelint',
Expand Down
20 changes: 15 additions & 5 deletions src/server/__tests__/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,9 @@ describe('StylelintLanguageServer', () => {

await onInitializedHandler?.({});

expect(mockLogger.debug).toHaveBeenCalledWith('received onInitialized', { params: {} });
expect(mockLogger.debug).toHaveBeenCalledWith('received onInitialized', {
params: {},
});
expect(mockLogger.debug).not.toHaveBeenCalledWith(
'Registering DidChangeConfigurationNotification',
);
Expand Down Expand Up @@ -295,7 +297,9 @@ describe('StylelintLanguageServer', () => {

await onInitializedHandler?.({});

expect(mockLogger.debug).toHaveBeenCalledWith('received onInitialized', { params: {} });
expect(mockLogger.debug).toHaveBeenCalledWith('received onInitialized', {
params: {},
});
expect(mockLogger.debug).toHaveBeenCalledWith('Registering DidChangeConfigurationNotification');
expect(mockConnection.client.register).toHaveBeenCalledWith(
LSP.DidChangeConfigurationNotification.type,
Expand Down Expand Up @@ -711,7 +715,9 @@ describe('StylelintLanguageServer', () => {
{} as WorkDoneProgressReporter,
);

const withOptions = await getContext()?.lintDocument(document, { maxWarnings: 1 });
const withOptions = await getContext()?.lintDocument(document, {
maxWarnings: 1,
});
const withoutOptions = await getContext()?.lintDocument(document);

expect(withOptions).toStrictEqual(['test']);
Expand Down Expand Up @@ -787,7 +793,9 @@ describe('StylelintLanguageServer', () => {
{} as WorkDoneProgressReporter,
);

const results = await getContext()?.lintDocument(document, { maxWarnings: 1 });
const results = await getContext()?.lintDocument(document, {
maxWarnings: 1,
});

expect(results).toBeUndefined();
expect(mockDisplayError).toHaveBeenCalledWith(mockConnection, error);
Expand Down Expand Up @@ -818,7 +826,9 @@ describe('StylelintLanguageServer', () => {
{} as WorkDoneProgressReporter,
);

const withOptions = await getContext()?.getFixes(document, { maxWarnings: 1 });
const withOptions = await getContext()?.getFixes(document, {
maxWarnings: 1,
});
const withoutOptions = await getContext()?.getFixes(document);

expect(withOptions).toStrictEqual(['test']);
Expand Down
49 changes: 39 additions & 10 deletions src/server/modules/__tests__/auto-fix.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,14 @@ describe('AutoFixModule', () => {
mockContext.documents.get.mockReturnValue(document);
mockContext.__options.validate = ['bar'];
mockContext.getFixes.mockResolvedValue([TextEdit.insert(Position.create(0, 0), 'text')]);
mockContext.connection.workspace.applyEdit.mockResolvedValue({ applied: true });
mockContext.connection.workspace.applyEdit.mockResolvedValue({
applied: true,
});

const module = new AutoFixModule({ context: mockContext.__typed(), logger: mockLogger });
const module = new AutoFixModule({
context: mockContext.__typed(),
logger: mockLogger,
});

module.onDidRegisterHandlers();

Expand Down Expand Up @@ -108,7 +113,10 @@ describe('AutoFixModule', () => {
test('if no matching document exists, should not attempt to auto-fix', async () => {
mockContext.documents.get.mockReturnValue(undefined);

const module = new AutoFixModule({ context: mockContext.__typed(), logger: mockLogger });
const module = new AutoFixModule({
context: mockContext.__typed(),
logger: mockLogger,
});

module.onDidRegisterHandlers();

Expand All @@ -134,7 +142,10 @@ describe('AutoFixModule', () => {
mockContext.documents.get.mockReturnValue(TextDocument.create('foo', 'bar', 1, 'a {}'));
mockContext.__options.validate = ['baz'];

const module = new AutoFixModule({ context: mockContext.__typed(), logger: mockLogger });
const module = new AutoFixModule({
context: mockContext.__typed(),
logger: mockLogger,
});

module.onDidRegisterHandlers();

Expand Down Expand Up @@ -167,7 +178,10 @@ describe('AutoFixModule', () => {
mockContext.__options.validate = ['baz'];
mockLogger.isDebugEnabled.mockReturnValue(false);

const module = new AutoFixModule({ context: mockContext.__typed(), logger: mockLogger });
const module = new AutoFixModule({
context: mockContext.__typed(),
logger: mockLogger,
});

module.onDidRegisterHandlers();

Expand Down Expand Up @@ -195,7 +209,10 @@ describe('AutoFixModule', () => {
mockContext.documents.get.mockReturnValue(TextDocument.create('foo', 'bar', 2, 'a {}'));
mockContext.__options.validate = ['bar'];

const module = new AutoFixModule({ context: mockContext.__typed(), logger: mockLogger });
const module = new AutoFixModule({
context: mockContext.__typed(),
logger: mockLogger,
});

module.onDidRegisterHandlers();

Expand Down Expand Up @@ -227,7 +244,10 @@ describe('AutoFixModule', () => {
mockContext.getFixes.mockResolvedValue([TextEdit.insert(Position.create(0, 0), 'text')]);
mockContext.connection.workspace.applyEdit.mockResolvedValue(response);

const module = new AutoFixModule({ context: mockContext.__typed(), logger: mockLogger });
const module = new AutoFixModule({
context: mockContext.__typed(),
logger: mockLogger,
});

module.onDidRegisterHandlers();

Expand Down Expand Up @@ -259,7 +279,10 @@ describe('AutoFixModule', () => {
mockContext.getFixes.mockResolvedValue([TextEdit.insert(Position.create(0, 0), 'text')]);
mockContext.connection.workspace.applyEdit.mockRejectedValue(error);

const module = new AutoFixModule({ context: mockContext.__typed(), logger: mockLogger });
const module = new AutoFixModule({
context: mockContext.__typed(),
logger: mockLogger,
});

module.onDidRegisterHandlers();

Expand All @@ -284,14 +307,20 @@ describe('AutoFixModule', () => {
});

it('should be disposable', () => {
const module = new AutoFixModule({ context: mockContext.__typed(), logger: mockLogger });
const module = new AutoFixModule({
context: mockContext.__typed(),
logger: mockLogger,
});

expect(module).toHaveProperty('dispose');
expect(module.dispose).toBeInstanceOf(Function);
});

it('should dispose all handler registrations when disposed', () => {
const module = new AutoFixModule({ context: mockContext.__typed(), logger: mockLogger });
const module = new AutoFixModule({
context: mockContext.__typed(),
logger: mockLogger,
});

module.onDidRegisterHandlers();
module.dispose();
Expand Down
Loading

0 comments on commit 6002ba2

Please sign in to comment.