Skip to content
Open
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
3 changes: 1 addition & 2 deletions .github/actions/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
"type": "module",
"devDependencies": {
"@sourceacademy/modules-repotools": "workspace:^",
"@types/lodash": "^4.14.198",
"@types/node": "^22.15.30",
"typescript": "^5.8.2",
"vitest": "^4.0.18"
Expand All @@ -14,7 +13,7 @@
"@actions/artifact": "^6.0.0",
"@actions/core": "^1.11.1",
"@actions/exec": "^3.0.0",
"lodash": "^4.17.23",
"es-toolkit": "^1.44.0",
"snyk-nodejs-lockfile-parser": "^2.4.2"
},
"scripts": {
Expand Down
10 changes: 7 additions & 3 deletions .github/actions/src/__tests__/commons.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,13 @@ import * as exec from '@actions/exec';
import { describe, expect, it, test, vi } from 'vitest';
import * as commons from '../commons.js';

vi.mock(import('lodash/memoize.js'), () => ({
default: (x: any) => x
}) as any);
vi.mock(import('es-toolkit'), async (importOriginal) => {
const actual = await importOriginal();
return {
...actual,
memoize: (x: any) => x
};
});

const mockedExecOutput = vi.spyOn(exec, 'getExecOutput');

Expand Down
4 changes: 2 additions & 2 deletions .github/actions/src/__tests__/lockfiles.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ describe(utils.extractPackageName, () => {
});

it('works with regular package names', () => {
expect(utils.extractPackageName('lodash@npm:^4.17.20'))
.toEqual('lodash');
expect(utils.extractPackageName('es-toolkit@npm:^1.44.0'))
.toEqual('es-toolkit');
});

it('throws an error on an invalid package name', () => {
Expand Down
12 changes: 6 additions & 6 deletions .github/actions/src/__tests__/sample_why.txt

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion .github/actions/src/commons.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { getExecOutput } from '@actions/exec';
import memoize from 'lodash/memoize.js';
import { memoize } from 'es-toolkit';

export interface RawPackageRecord {
directory: string;
Expand Down
2 changes: 1 addition & 1 deletion .github/actions/src/info/__tests__/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ const mockDirectory: Record<string, string | Record<string, unknown>> = {
'package.json': JSON.stringify({
name: '@sourceacademy/tab-Tab0',
dependencies: {
lodash: '^4.1.1',
'es-toolkit': '^1.44.0',
'@sourceacademy/bundle-bundle0': 'workspace:^',
},
devDependencies: {
Expand Down
2 changes: 1 addition & 1 deletion .github/actions/src/lockfiles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import fs from 'fs/promises';
import pathlib from 'path';
import * as core from '@actions/core';
import { getExecOutput } from '@actions/exec';
import memoize from 'lodash/memoize.js';
import { memoize } from 'es-toolkit';
import { extractPkgsFromYarnLockV2 } from 'snyk-nodejs-lockfile-parser';
import { gitRoot } from './gitRoot.js';

Expand Down
1 change: 1 addition & 0 deletions .yarnrc.yml
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
nodeLinker: node-modules
checksumBehavior: update
1 change: 1 addition & 0 deletions docs/src/lib/lintplugin/2-rules.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ import path from 'pathlib';

## `no-barrel-imports`

_Note: Due to the migration to es-toolkit, this rule is no longer used_
Enforces that imports from a certain source uses individual imports instead of the main barrel import.

This rule was primarily motivated by packages like `lodash` and `@mui`, which re-export all their functionalities
Expand Down
2 changes: 1 addition & 1 deletion docs/src/modules/2-bundle/3-editing.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ You can also add the dependency directly by modifying your `package.json`:
{
"name": "@sourceacademy/bundle-bundle0",
"dependencies": {
"lodash": "^4.0.0"
"es-toolkit": "^1.44.0"
}
}
```
Expand Down
2 changes: 1 addition & 1 deletion docs/src/modules/3-tabs/3-editing.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ You can also add the dependency directly by modifying your `package.json`:
{
"name": "@sourceacademy/tab-Tab0",
"dependencies": {
"lodash": "^4.0.0"
"es-toolkit": "^1.44.0"
}
}
```
Expand Down
1 change: 0 additions & 1 deletion eslint.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,6 @@ export default defineConfig(
'prefer-const': ['warn', { destructuring: 'all' }],

'@sourceacademy/default-import-name': ['warn', { path: 'pathlib' }],
'@sourceacademy/no-barrel-imports': ['error', ['lodash']],
'@sourceacademy/region-comment': 'error',
}
},
Expand Down
3 changes: 1 addition & 2 deletions lib/buildtools/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
"@commander-js/extra-typings": "^14.0.0",
"@types/estree": "^1.0.0",
"@types/http-server": "^0.12.4",
"@types/lodash": "^4.14.198",
"@types/node": "^22.15.30",
"typescript": "^5.8.2"
},
Expand All @@ -26,11 +25,11 @@
"astring": "^1.8.6",
"chalk": "^5.0.1",
"commander": "^14.0.0",
"es-toolkit": "^1.44.0",
"esbuild": "^0.27.0",
"eslint": "^9.35.0",
"http-server": "^14.1.1",
"jsdom": "^26.1.0",
"lodash": "^4.17.23",
"typedoc": "^0.28.9",
"vite": "^7.1.11",
"vitest": "^4.0.18"
Expand Down
2 changes: 1 addition & 1 deletion lib/buildtools/src/commands/commandUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { InvalidArgumentError, Option } from '@commander-js/extra-typings';
import type { ErrorResult, Severity } from '@sourceacademy/modules-repotools/types';
import { isSeverity, objectKeys, objectValues } from '@sourceacademy/modules-repotools/utils';
import chalk from 'chalk';
import capitalize from 'lodash/capitalize.js';
import { capitalize } from 'es-toolkit';
import { LogLevel } from 'typedoc';

export const lintOption = new Option('--lint', 'Run ESLint when building')
Expand Down
8 changes: 4 additions & 4 deletions lib/buildtools/src/commands/list.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Command } from '@commander-js/extra-typings';
import { bundlesDir, tabsDir } from '@sourceacademy/modules-repotools/getGitRoot';
import { resolveAllBundles, resolveAllTabs, resolveSingleBundle, resolveSingleTab } from '@sourceacademy/modules-repotools/manifest';
import chalk from 'chalk';
import omit from 'lodash/omit.js';
import { omit } from 'es-toolkit';
import { logCommandErrorAndExit } from './commandUtils.js';

export const getListBundlesCommand = () => new Command('bundle')
Expand All @@ -23,7 +23,7 @@ export const getListBundlesCommand = () => new Command('bundle')
return;
}

const bundlesStr = bundleNames.map((each, i) => `${i+1}. ${each}`).join('\n');
const bundlesStr = bundleNames.map((each, i) => `${i + 1}. ${each}`).join('\n');
console.log(`${chalk.magentaBright(`Detected ${bundleNames.length} bundles in ${bundlesDir}:`)}\n${bundlesStr}`);
} else {
logCommandErrorAndExit(`No bundles in ${bundlesDir}!`);
Expand All @@ -49,7 +49,7 @@ export const getListTabsCommand = () => new Command('tabs')
return;
}

const tabsStr = tabNames.map((each, i) => `${i+1}. ${each}`).join('\n');
const tabsStr = tabNames.map((each, i) => `${i + 1}. ${each}`).join('\n');
console.log(`${chalk.magentaBright(`Detected ${tabNames.length} tabs in ${tabsDir}:`)}\n${tabsStr}`);
} else {
logCommandErrorAndExit(`No tabs in ${tabsDir}`);
Expand All @@ -73,7 +73,7 @@ export const getValidateCommand = () => new Command('validate')
} else if (manifestResult.severity === 'error') {
logCommandErrorAndExit(manifestResult);
} else {
const bundle = omit(manifestResult.bundle, 'type');
const bundle = omit(manifestResult.bundle, ['type']);
const manifestStr = JSON.stringify(bundle, null, 2);
console.log(`${chalk.magentaBright(`Bundle '${manifestResult.bundle.name}' found in ${directory}`)}:\n${manifestStr}`);
}
Expand Down
4 changes: 2 additions & 2 deletions lib/buildtools/src/templates/tab.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import pathlib from 'path';
import type { Interface } from 'readline/promises';
import { getBundleManifests } from '@sourceacademy/modules-repotools/manifest';
import type { BundleManifest, ModulesManifest } from '@sourceacademy/modules-repotools/types';
import omit from 'lodash/omit.js';
import { omit } from 'es-toolkit/object';
import _package from '../../../../package.json' with { type: 'json' };
import { formatResult } from '../build/formatter.js';
import { askQuestion, error, success, warn } from './print.js';
Expand Down Expand Up @@ -79,7 +79,7 @@ export async function addNew(bundlesDir: string, tabsDir: string, rl: Interface)
};

// Version property gets stored in package.json, not manifest.json
const requiredProperties = omit(manifest[moduleName], 'version');
const requiredProperties = omit(manifest[moduleName], ['version']);

const newManifest: BundleManifest = {
...requiredProperties,
Expand Down
3 changes: 1 addition & 2 deletions lib/markdown-tree/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
"devDependencies": {
"@sourceacademy/modules-buildtools": "workspace:^",
"@sourceacademy/modules-repotools": "workspace:^",
"@types/lodash": "^4.14.198",
"@types/markdown-it": "^14.1.2",
"shiki": "^3.15.0",
"typescript": "^5.8.2"
Expand All @@ -23,7 +22,7 @@
"shiki": ">=2"
},
"dependencies": {
"lodash": "^4.17.23",
"es-toolkit": "^1.44.0",
"tm-themes": "^1.10.12",
"yaml": "^2.8.0"
},
Expand Down
11 changes: 4 additions & 7 deletions lib/markdown-tree/src/tree.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
// Adapted from: https://gitlab.com/nfriend/tree-online/-/tree/master?ref_type=heads

import type { RecursiveArray } from 'lodash';
import defaultsDeep from 'lodash/defaultsDeep';
import flattenDeep from 'lodash/flattenDeep';
import last from 'lodash/last';
import { flattenDeep, last } from 'es-toolkit';
import type { FileStructure } from './types';

/**
Expand Down Expand Up @@ -73,11 +70,11 @@ export function generateTree(
commentLoc: number,
options?: GenerateTreeOptions
): string {
const combinedOptions = defaultsDeep({}, options, defaultOptions);
const combinedOptions = { ...defaultOptions, ...options };

return flattenDeep([
getAsciiLine(structure, commentLoc, combinedOptions),
structure.children.map(c => generateTree(c, commentLoc, options)) as RecursiveArray<string>,
structure.children.map(c => generateTree(c, commentLoc, options)),
])
// Remove null entries. Should only occur for the very first node
// when `options.rootDot === false`
Expand Down Expand Up @@ -161,7 +158,7 @@ const getName = (
nameChunks.unshift(
getName(
structure.parent,
defaultsDeep({}, { trailingDirSlash: true }, options),
{ ...{ trailingDirSlash: true }, ...options },
),
);
}
Expand Down
3 changes: 1 addition & 2 deletions lib/modules-lib/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
"type": "module",
"devDependencies": {
"@sourceacademy/modules-buildtools": "workspace:^",
"@types/lodash": "^4.14.198",
"@types/react": "^18.3.1",
"@types/react-dom": "^18.3.1",
"@vitejs/plugin-react": "^5.1.0",
Expand Down Expand Up @@ -34,8 +33,8 @@
"dependencies": {
"@blueprintjs/core": "^6.0.0",
"@blueprintjs/icons": "^6.0.0",
"es-toolkit": "^1.44.0",
"js-slang": "^1.0.85",
"lodash": "^4.17.23",
"react": "^18.3.1",
"react-dom": "^18.3.1"
},
Expand Down
6 changes: 3 additions & 3 deletions lib/modules-lib/src/tabs/MultiItemDisplay/index.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Button, EditableText } from '@blueprintjs/core';
import { IconNames } from '@blueprintjs/icons';
import clamp from 'lodash/clamp';
import { clamp } from 'es-toolkit';
import { useState } from 'react';

export interface MultiItemDisplayProps {
Expand Down Expand Up @@ -31,7 +31,7 @@ export default function MultiItemDisplay(props: MultiItemDisplayProps) {
const elementsDigitCount = Math.floor(Math.log10(Math.max(1, props.elements.length))) + 1;

return (
<div
(<div
style={{
display: 'flex',
flexDirection: 'column',
Expand Down Expand Up @@ -157,6 +157,6 @@ export default function MultiItemDisplay(props: MultiItemDisplayProps) {
>
{props.elements[currentStep]}
</div>
</div>
</div>)
);
}
2 changes: 1 addition & 1 deletion lib/modules-lib/src/tabs/NumberSelector.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { EditableText, type EditableTextProps } from '@blueprintjs/core';
import clamp from 'lodash/clamp';
import { clamp } from 'es-toolkit';
import { useState } from 'react';

export type NumberSelectorProps = {
Expand Down
2 changes: 1 addition & 1 deletion lib/modules-lib/vitest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export default mergeConfig(
include: [
'@blueprintjs/core',
'@blueprintjs/icons',
'lodash',
'es-toolkit',
'vitest-browser-react',
]
},
Expand Down
5 changes: 2 additions & 3 deletions lib/repotools/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
"description": "Common library for tooling used by the modules repository",
"devDependencies": {
"@commander-js/extra-typings": "^14.0.0",
"@types/lodash": "^4.14.198",
"@types/node": "^22.15.30",
"@vitejs/plugin-react": "^5.1.0",
"@vitest/coverage-v8": "^4.0.18",
Expand All @@ -18,9 +17,9 @@
"@vitest/browser-playwright": "^4.0.18",
"chalk": "^5.0.1",
"commander": "^14.0.0",
"es-toolkit": "^1.44.0",
"esbuild": "^0.27.0",
"jsonschema": "^1.5.0",
"lodash": "^4.17.23"
"jsonschema": "^1.5.0"
},
"peerDependencies": {
"@vitejs/plugin-react": "*",
Expand Down
2 changes: 1 addition & 1 deletion lib/repotools/src/manifest.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import type { Dirent } from 'fs';
import fs from 'fs/promises';
import pathlib from 'path';
import { uniq } from 'es-toolkit';
import { validate } from 'jsonschema';
import uniq from 'lodash/uniq.js';
import { tabsDir } from './getGitRoot.js';
import manifestSchema from './manifest.schema.json' with { type: 'json' };
import type { BundleManifest, InputAsset, ResolvedBundle, ResolvedTab, ResultType } from './types.js';
Expand Down
5 changes: 2 additions & 3 deletions lib/repotools/src/testing/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@ import fs from 'fs/promises';
import pathlib from 'path';
import react from '@vitejs/plugin-react';
import { playwright } from '@vitest/browser-playwright';
import cloneDeep from 'lodash/cloneDeep.js';
import partition from 'lodash/partition.js';
import { cloneDeep, partition } from 'es-toolkit';
import { loadConfigFromFile } from 'vite';
import type { LabelColor } from 'vitest';
import { defineProject, mergeConfig, type TestProjectInlineConfiguration, type ViteUserConfig } from 'vitest/config';
Expand Down Expand Up @@ -82,7 +81,7 @@ export const sharedTabsConfig = mergeConfig(
'@blueprintjs/icons',
'gl-matrix',
'js-slang',
'lodash',
'es-toolkit',
'vitest-browser-react'
]
},
Expand Down
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,8 @@
"husky": "^9.1.7",
"jsdom": "^26.1.0",
"jsonc-eslint-parser": "^2.4.0",
"react": "^18.3.1",
"react-dom": "^18.3.1",
"typescript": "^5.8.2",
"typescript-eslint": "^8.53.1",
"vitest": "^4.0.18",
Expand All @@ -82,8 +84,8 @@
"peerDependencies": {
"@blueprintjs/core": "^6.0.0",
"@blueprintjs/icons": "^6.0.0",
"es-toolkit": "^1.44.0",
"js-slang": "^1.0.85",
"lodash": "^4.17.23",
"react": "^18.3.1",
"react-dom": "^18.3.1"
},
Expand Down
1 change: 1 addition & 0 deletions src/bundles/curve/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"private": true,
"dependencies": {
"@sourceacademy/modules-lib": "workspace:^",
"es-toolkit": "^1.44.0",
"gl-matrix": "^3.3.0",
"js-slang": "^1.0.85"
},
Expand Down
2 changes: 1 addition & 1 deletion src/bundles/curve/src/functions.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import clamp from 'lodash/clamp';
import { clamp } from 'es-toolkit';
import { Point, type Curve } from './curves_webgl';
import { functionDeclaration } from './type_interface';
import type { CurveTransformer } from './types';
Expand Down
2 changes: 1 addition & 1 deletion src/bundles/midi/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ type NotesWithFlats = 'A' | 'B' | 'D' | 'E' | 'G';
// & {} is a weird trick with typescript that causes intellisense to evaluate every single option
// so you see all the valid notes instead of just the type definition below
export type Note = {} & (NoteName | `${NoteName}${Accidental.NATURAL}` | `${NotesWithFlats}${Accidental.FLAT}` | `${NotesWithSharps}${Accidental.SHARP}`);
export type NoteWithOctave = (Note | `${Note}${number}`);
export type NoteWithOctave = Note | `${Note}${number}`;

/**
* An integer representing a MIDI note value. Refer to {@link https://i.imgur.com/qGQgmYr.png|this} mapping from
Expand Down
Loading
Loading