Skip to content

Commit 9a27f85

Browse files
committed
fix formatting
1 parent 0b87aaf commit 9a27f85

5 files changed

Lines changed: 15 additions & 20 deletions

File tree

.github/actions/find/src/dynamicImport.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
// - this exists because I'm not sure how to mock
32
// the dynamic import function, so mocking this instead
43
// - also, vitest has a limitation on mocking:

.github/actions/find/src/findForUrl.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,7 @@ import AxeBuilder from '@axe-core/playwright'
33
import playwright from 'playwright'
44
import {AuthContext} from './AuthContext.js'
55
import {generateScreenshots} from './generateScreenshots.js'
6-
import { loadPlugins } from './pluginManager.js'
7-
6+
import {loadPlugins} from './pluginManager.js'
87

98
export async function findForUrl(
109
url: string,
@@ -32,7 +31,7 @@ export async function findForUrl(
3231
const plugins = await loadPlugins()
3332
for (const plugin of plugins) {
3433
console.log('Running plugin: ', plugin.name)
35-
await plugin.default({ page, addFinding, url })
34+
await plugin.default({page, addFinding, url})
3635
}
3736

3837
let screenshotId: string | undefined

.github/actions/find/src/pluginManager.ts

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import * as fs from 'fs'
22
import * as path from 'path'
3-
import { fileURLToPath } from 'url'
4-
import { dynamicImport } from './dynamicImport.js'
3+
import {fileURLToPath} from 'url'
4+
import {dynamicImport} from './dynamicImport.js'
55

66
// Helper to get __dirname equivalent in ES Modules
77
const __filename = fileURLToPath(import.meta.url)
@@ -12,7 +12,6 @@ const __dirname = path.dirname(__filename)
1212
const plugins: any[] = []
1313
let pluginsLoaded = false
1414

15-
1615
export async function loadPlugins() {
1716
console.log('loading plugins')
1817

@@ -33,17 +32,15 @@ export async function loadPlugins() {
3332
export const abortError = [
3433
'There was an error while loading plugins.',
3534
'Clearing all plugins and aborting custom plugin scans.',
36-
'Please check the logs for hints as to what may have gone wrong.'
35+
'Please check the logs for hints as to what may have gone wrong.',
3736
].join('\n')
3837

39-
4038
export function clearCache() {
4139
console.log('clearing plugin cache')
4240
pluginsLoaded = false
4341
plugins.length = 0
4442
}
4543

46-
4744
// exported for mocking/testing. not for actual use
4845
export async function loadBuiltInPlugins() {
4946
console.log('Loading built-in plugins')
@@ -62,12 +59,12 @@ export async function loadCustomPlugins() {
6259
const pluginsPath = process.cwd() + '/.github/scanner-plugins/'
6360
await loadPluginsFromPath({
6461
readPath: pluginsPath,
65-
importPath: pluginsPath
62+
importPath: pluginsPath,
6663
})
6764
}
6865

6966
// exported for mocking/testing. not for actual use
70-
export async function loadPluginsFromPath({ readPath, importPath }: { readPath: string, importPath: string }) {
67+
export async function loadPluginsFromPath({readPath, importPath}: {readPath: string; importPath: string}) {
7168
try {
7269
const res = fs.readdirSync(readPath)
7370
for (const pluginFolder of res) {
@@ -79,6 +76,6 @@ export async function loadPluginsFromPath({ readPath, importPath }: { readPath:
7976
console.log('error: ')
8077
console.log(e)
8178
// - throw error to handle aborting the plugin scans
82-
throw(e)
79+
throw e
8380
}
8481
}

.github/actions/find/tests/pluginManager.test.ts

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,17 @@ import * as fs from 'fs'
44
import * as dynamicImportModule from '../src/dynamicImport.js'
55
import * as pluginManager from '../src/pluginManager.js'
66

7-
87
// - enable spying on fs
98
// https://vitest.dev/guide/browser/#limitations
10-
vi.mock('fs', { spy: true })
11-
vi.mock('../src/pluginManager.js', { spy: true })
9+
vi.mock('fs', {spy: true})
10+
vi.mock('../src/pluginManager.js', {spy: true})
1211

1312
describe('loadPlugins', () => {
14-
vi.spyOn(dynamicImportModule, 'dynamicImport').mockImplementation((path) => (
15-
Promise.resolve(path)
16-
))
13+
vi.spyOn(dynamicImportModule, 'dynamicImport').mockImplementation(path => Promise.resolve(path))
1714
beforeEach(() => {
18-
vi.spyOn(fs, 'readdirSync').mockImplementation((readPath) => {
15+
// @ts-expect-error - we don't need the full fs readdirsync
16+
// method signature here
17+
vi.spyOn(fs, 'readdirSync').mockImplementation(readPath => {
1918
return [readPath + '/plugin-1', readPath + '/plugin-2']
2019
})
2120
})

.vscode/settings.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{}

0 commit comments

Comments
 (0)