Skip to content

Commit e7790bb

Browse files
committed
Update workflow and linting
1 parent 9188068 commit e7790bb

File tree

16 files changed

+85
-44
lines changed

16 files changed

+85
-44
lines changed

.github/workflows/pull-request.yml

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -65,25 +65,21 @@ jobs:
6565
if: needs.paths-filter.outputs.libraries == 'true'
6666
run: yarn workspaces foreach -ptW --from "./lib/*" run tsc
6767

68-
- name: Run lint for libraries
69-
if: needs.paths-filter.outputs.libraries == 'true'
70-
run: yarn eslint lib
71-
7268
- name: Run test for libraries
7369
if: needs.paths-filter.outputs.libraries == 'true'
7470
run: yarn test:libs
7571

76-
- name: Build, lint and run tsc for bundles and tabs
72+
- name: Build and run tsc for bundles and tabs
7773
if: needs.paths-filter.outputs.devserver == 'true'
78-
run: yarn workspaces foreach -j 5 -ptW --from "./src/{bundles,tabs}/*" run build --tsc --lint
74+
run: yarn workspaces foreach -j 5 -ptW --from "./src/{bundles,tabs}/*" run build --tsc
7975

8076
- name: Test bundles and tabs
8177
if: needs.paths-filter.outputs.modules == 'true'
8278
run: yarn test:modules
8379

8480
- name: Build manifest
8581
if: needs.paths-filter.outputs.devserver == 'true'
86-
run: yarn buildtools build manifest
82+
run: yarn buildtools manifest
8783

8884
- name: Build Docs Server
8985
if: needs.paths-filter.outputs.docs == 'true'
@@ -93,10 +89,9 @@ jobs:
9389
if: needs.paths-filter.outputs.devserver == 'true'
9490
run: yarn tsc:devserver
9591

96-
- name: Run Lint for Dev Server
97-
if: needs.paths-filter.outputs.devserver == 'true'
98-
run: yarn eslint devserver
99-
10092
- name: Test Dev Server
10193
if: needs.paths-filter.outputs.devserver == 'true'
10294
run: yarn test:devserver
95+
96+
- name: Lint Everything
97+
run: yarn buildtools lintglobal

devserver/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
"@types/react": "^18.3.1",
3030
"@types/react-dom": "^18.3.1",
3131
"@vitest/browser": "^3.2.3",
32-
"eslint": "^9.29.0",
32+
"eslint": "^9.31.0",
3333
"playwright": "^1.52.0",
3434
"sass": "^1.85.0",
3535
"typescript": "^5.8.2",

eslint.config.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ export default tseslint.config(
3131
'devserver/vite.config.ts',
3232
'lib/buildtools/bin',
3333
'lib/buildtools/src/build/__test_mocks__',
34-
'lib/lintplugin/dist.js',
34+
'lib/*/dist.*js',
3535
'src/**/samples/**',
3636
'src/bundles/scrabble/src/words.json', // Don't lint this because its way too big
3737
'src/java/**',
@@ -303,6 +303,7 @@ export default tseslint.config(
303303
'vitest/no-conditional-expect': 'off',
304304
'vitest/no-export': 'off',
305305
'vitest/require-top-level-describe': 'off',
306+
'vitest/valid-describe-callback': 'off',
306307
'vitest/valid-expect-in-promise': 'error',
307308

308309
'import/extensions': ['error', 'never', {

lib/lintplugin/src/configs.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import stylePlugin from '@stylistic/eslint-plugin';
2+
import vitestPlugin from '@vitest/eslint-plugin';
23
import type { Linter } from 'eslint';
34
import * as importPlugin from 'eslint-plugin-import';
45
import reactPlugin from 'eslint-plugin-react';
56
import reactHooksPlugin from 'eslint-plugin-react-hooks';
6-
import vitestPlugin from '@vitest/eslint-plugin';
77
import globals from 'globals';
88
import tseslint from 'typescript-eslint';
99
import saLintPlugin from '.';

lib/markdown-tree/src/__tests__/index.test.ts

Lines changed: 47 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { generateStructure } from '../structure';
44
import { isRootYamlObject, isYamlObject } from '../types';
55

66
const mockExistsSync = vi.spyOn(fs, 'existsSync');
7-
vi.spyOn(fs, 'statSync').mockReturnValue({
7+
const mockStatSync = vi.spyOn(fs, 'statSync').mockReturnValue({
88
isDirectory: () => true
99
} as any);
1010

@@ -55,32 +55,71 @@ describe('Test structure generation', () => {
5555

5656
describe('Test tree validation', () => {
5757
const validPaths = [
58-
'/dir',
59-
'/dir/real_item0'
58+
'/',
59+
'/real_item0',
60+
'/real_item1',
61+
'/real_item1/real_item2',
6062
];
6163

6264
mockExistsSync.mockImplementation(path => validPaths.includes(path as string));
6365

6466
test('Successful validation', () => {
6567
const [,,warnings] = generateStructure({
66-
path: '/dir',
68+
path: '.',
6769
name: 'root',
6870
children: [
69-
'real_item0'
71+
'real_item0',
72+
{
73+
name: 'real_item1',
74+
children: ['real_item2']
75+
}
7076
]
7177
}, '/');
7278
expect(warnings.length).toEqual(0);
73-
expect(fs.existsSync).toHaveBeenCalledTimes(2);
79+
expect(fs.existsSync).toHaveBeenCalledTimes(4);
7480
});
7581

76-
test('Unsuccessful validation', () => {
82+
test('Unsuccessful validation when child item doesn\'t exist', () => {
7783
const [,,warnings] = generateStructure({
78-
path: './dir',
84+
path: '.',
7985
name: 'root',
8086
children: ['fake_item0']
8187
}, '/');
8288

8389
expect(warnings.length).toEqual(1);
8490
expect(fs.existsSync).toHaveBeenCalledTimes(2);
8591
});
92+
93+
test('Unsuccessful validation when item with children is not a folder', () => {
94+
mockStatSync.mockReturnValueOnce({
95+
isDirectory: () => false
96+
} as any);
97+
98+
const [,,warnings] = generateStructure({
99+
path: '.',
100+
name: 'root',
101+
children: [{
102+
name: 'real_item0',
103+
children: ['real_item2']
104+
}]
105+
}, '/');
106+
107+
expect(warnings.length).toEqual(1);
108+
expect(fs.existsSync).toHaveBeenCalledTimes(3);
109+
});
110+
111+
test('Not providing a path means no validation is run', () => {
112+
const [,,warnings] = generateStructure({
113+
path: '.',
114+
name: 'root',
115+
children: [{
116+
name: 'real_item1',
117+
children: ['real_item2']
118+
}]
119+
});
120+
121+
expect(warnings.length).toEqual(0);
122+
expect(fs.existsSync).not.toHaveBeenCalled();
123+
expect(fs.statSync).not.toHaveBeenCalled();
124+
});
86125
});

lib/markdown-tree/src/structure.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ export function generateStructure(rootObj: RootYamlObject, validatePath?: string
5757
const warnings: string[] = [];
5858

5959
if (validatePath !== undefined && !fs.existsSync(validatePath)) {
60+
console.log(`${validatePath} failed to validate`);
6061
warnings.push(`[Markdown Tree Plugin 1] Could not locate ${validatePath}`);
6162
exists = false;
6263
}

src/bundles/ar/src/ObjectsHelper.ts

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,10 @@ import {
2020
type PathItem,
2121
} from 'saar/libraries/object_state_library/Behaviour';
2222
import UIBase64ImageComponent from 'saar/libraries/object_state_library/ui_component/UIBase64ImageItem';
23-
import UIColumnItem, {
24-
type HorizontalAlignment,
25-
} from 'saar/libraries/object_state_library/ui_component/UIColumnItem';
23+
import UIColumnItem, { type HorizontalAlignment } from 'saar/libraries/object_state_library/ui_component/UIColumnItem';
2624
import UIImageItem from 'saar/libraries/object_state_library/ui_component/UIImageItem';
2725
import type { UIBasicItem } from 'saar/libraries/object_state_library/ui_component/UIItem';
28-
import UIRowItem, {
29-
type VerticalAlignment,
30-
} from 'saar/libraries/object_state_library/ui_component/UIRowItem';
26+
import UIRowItem, { type VerticalAlignment } from 'saar/libraries/object_state_library/ui_component/UIRowItem';
3127
import UITextItem from 'saar/libraries/object_state_library/ui_component/UITextItem';
3228
import uniqid from 'uniqid';
3329
import { callARCallback } from './AR';

src/bundles/arcade_2d/src/phaserScene.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
import Phaser from 'phaser';
22
import { AudioClip } from './audio';
33
import { DEFAULT_PATH_PREFIX } from './constants';
4-
import {
5-
config
6-
} from './functions';
4+
import { config } from './functions';
75
import {
86
CircleGameObject,
97
GameObject,

src/bundles/csg/src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,9 @@
4545
* );
4646
* render_grid_axes(snowglobe);
4747
* ```
48-
*
4948
* More samples can be found at: https://github.com/source-academy/modules/tree/master/src/bundles/csg/samples
5049
*
50+
*
5151
* @module csg
5252
* @author Joel Leow
5353
* @author Liu Muchen

src/bundles/csg/src/utilities.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
/* [Imports] */
2-
import geom3, {
3-
transform as _transform
4-
} from '@jscad/modeling/src/geometries/geom3';
2+
import geom3, { transform as _transform } from '@jscad/modeling/src/geometries/geom3';
53
import mat4, { type Mat4 } from '@jscad/modeling/src/maths/mat4';
64
import {
75
center as _center,

0 commit comments

Comments
 (0)