Skip to content

Commit dfeb085

Browse files
committed
chore(style): minor code style adjustments for improved consistency
1 parent a9e6cea commit dfeb085

File tree

8 files changed

+25
-19
lines changed

8 files changed

+25
-19
lines changed

docs/tutorialkit.dev/src/components/Layout/Head.astro

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,10 @@ import Default from '@astrojs/starlight/components/Head.astro';
1616
// @ts-ignore
1717
dataLayer.push(arguments);
1818
}
19+
1920
// @ts-ignore
2021
gtag('js', new Date());
22+
2123
// @ts-ignore
2224
gtag('config', 'G-64MFE82HG5');
2325
</script>

extensions/vscode/build.mjs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import * as esbuild from 'esbuild';
2-
import fs from 'node:fs';
32
import { execa } from 'execa';
3+
import fs from 'node:fs';
44

55
const production = process.argv.includes('--production');
66
const watch = process.argv.includes('--watch');
@@ -18,7 +18,7 @@ async function main() {
1818
external: ['vscode'],
1919
logLevel: 'silent',
2020
plugins: [
21-
/* add to the end of plugins array */
21+
// add to the end of plugins array
2222
esbuildProblemMatcherPlugin,
2323
],
2424
});
@@ -33,7 +33,7 @@ async function main() {
3333
await ctx.dispose();
3434

3535
if (production) {
36-
// rename name in package json to match extension name on store:
36+
// rename name in package json to match extension name on store
3737
const pkgJSON = JSON.parse(fs.readFileSync('./package.json', { encoding: 'utf8' }));
3838

3939
pkgJSON.name = 'tutorialkit';
@@ -50,14 +50,16 @@ const esbuildProblemMatcherPlugin = {
5050
name: 'esbuild-problem-matcher',
5151
setup(build) {
5252
build.onStart(() => {
53-
console.log('[watch] build started');
53+
console.log('[watch] Build started');
5454
});
55+
5556
build.onEnd((result) => {
5657
result.errors.forEach(({ text, location }) => {
5758
console.error(`✘ [ERROR] ${text}`);
5859
console.error(` ${location.file}:${location.line}:${location.column}:`);
5960
});
60-
console.log('[watch] build finished');
61+
62+
console.log('[watch] Build finished');
6163
});
6264
},
6365
};

extensions/vscode/src/commands/index.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,7 @@ import { selectTutorial } from './tutorialkit.select-tutorial';
66
import { loadTutorial } from './tutorialkit.load-tutorial';
77
import { initialize } from './tutorialkit.initialize';
88

9-
/**
10-
* No need to use these consts outside of this file:
11-
* – Use `cmd[name].command` instead.
12-
*/
9+
// no need to use these consts outside of this file, use `cmd[name].command` instead
1310
const CMD = {
1411
INITIALIZE: 'tutorialkit.initialize',
1512
SELECT_TUTORIAL: 'tutorialkit.select-tutorial',

extensions/vscode/src/commands/tutorialkit.initialize.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import * as vscode from 'vscode';
2-
import isTutorialKitWorkspace from '../utils/isTutorialKit';
32
import { cmd } from '.';
3+
import isTutorialKitWorkspace from '../utils/isTutorialKit';
44

55
export async function initialize(toastIfEmpty = false) {
66
const tutorialWorkpaces = (vscode.workspace.workspaceFolders || []).filter(isTutorialKitWorkspace);
@@ -10,6 +10,7 @@ export async function initialize(toastIfEmpty = false) {
1010
vscode.window.showInformationMessage(
1111
'No TutorialKit project found in the current workspace. Make sure there is a "@tutorialkit/astro" dependency or devDependency in your package.json file.',
1212
);
13+
1314
vscode.commands.executeCommand('setContext', 'tutorialkit:tree', false);
1415
}
1516
} else if (tutorialWorkpaces.length === 1) {

extensions/vscode/src/commands/tutorialkit.load-tutorial.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import * as vscode from 'vscode';
2-
import { LessonsTreeDataProvider, getLessonsTreeDataProvider, setLessonsTreeDataProvider } from '../views/lessonsTree';
32
import { extContext } from '../extension';
3+
import { LessonsTreeDataProvider, getLessonsTreeDataProvider, setLessonsTreeDataProvider } from '../views/lessonsTree';
44

55
export async function loadTutorial(uri: vscode.Uri) {
66
setLessonsTreeDataProvider(new LessonsTreeDataProvider(uri, extContext));

extensions/vscode/src/commands/tutorialkit.select-tutorial.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import * as vscode from 'vscode';
2-
import isTutorialKitWorkspace from '../utils/isTutorialKit';
32
import { cmd } from '.';
3+
import isTutorialKitWorkspace from '../utils/isTutorialKit';
44

55
export async function selectTutorial() {
66
const tutorialWorkpaces = (vscode.workspace.workspaceFolders || []).filter(isTutorialKitWorkspace);

extensions/vscode/src/utils/isTutorialKit.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
import * as vscode from 'vscode';
2-
import * as path from 'path';
31
import * as fs from 'fs';
2+
import * as path from 'path';
3+
import * as vscode from 'vscode';
44

55
/**
6-
* Check if the workspace is a TutorialKit workspace
7-
* by looking for a TutorialKit dependency in the package.json file.
6+
* Check if the workspace is a TutorialKit workspace by looking for a
7+
* TutorialKit dependency in the package.json file.
88
*
99
* @param folder The workspace folder to check.
1010
* @returns True if the workspace is a TutorialKit workspace, false otherwise.
@@ -13,6 +13,7 @@ export default function isTutorialKitWorkspace(folder: vscode.WorkspaceFolder):
1313
const packageJsonPath = path.join(folder.uri.fsPath, 'package.json');
1414
const packageJsonContent = fs.readFileSync(packageJsonPath, 'utf8');
1515
const packageJson = JSON.parse(packageJsonContent);
16+
1617
const tutorialkitDependency =
1718
packageJson.dependencies?.['@tutorialkit/astro'] || packageJson.devDependencies?.['@tutorialkit/astro'];
1819

extensions/vscode/src/views/lessonsTree.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,15 @@ let lessonsTreeDataProvider: LessonsTreeDataProvider;
1515
export function getLessonsTreeDataProvider() {
1616
return lessonsTreeDataProvider;
1717
}
18+
1819
export function setLessonsTreeDataProvider(provider: LessonsTreeDataProvider) {
1920
lessonsTreeDataProvider = provider;
2021
}
2122

2223
export class LessonsTreeDataProvider implements vscode.TreeDataProvider<Lesson> {
2324
private _lessons: Lesson[] = [];
25+
private _onDidChangeTreeData: vscode.EventEmitter<Lesson | undefined> = new vscode.EventEmitter<Lesson | undefined>();
26+
readonly onDidChangeTreeData: vscode.Event<Lesson | undefined> = this._onDidChangeTreeData.event;
2427

2528
constructor(
2629
private readonly _workspaceRoot: vscode.Uri,
@@ -59,11 +62,14 @@ export class LessonsTreeDataProvider implements vscode.TreeDataProvider<Lesson>
5962
const metadataFilePath = path.join(filePath, metadataFile);
6063
const metadataFileContent = fs.readFileSync(metadataFilePath, 'utf8');
6164
const parsedContent = grayMatter(metadataFileContent);
65+
6266
lesson.name = parsedContent.data.title;
67+
6368
lesson.metadata = {
6469
_path: metadataFilePath,
6570
...(parsedContent.data as any),
6671
};
72+
6773
lessons.push(lesson);
6874
}
6975
}
@@ -72,9 +78,6 @@ export class LessonsTreeDataProvider implements vscode.TreeDataProvider<Lesson>
7278
return lessons;
7379
}
7480

75-
private _onDidChangeTreeData: vscode.EventEmitter<Lesson | undefined> = new vscode.EventEmitter<Lesson | undefined>();
76-
readonly onDidChangeTreeData: vscode.Event<Lesson | undefined> = this._onDidChangeTreeData.event;
77-
7881
refresh(): void {
7982
this._loadLessons();
8083
this._onDidChangeTreeData.fire(undefined);

0 commit comments

Comments
 (0)