Skip to content

Commit b307ef4

Browse files
committed
Add lint-affected script for smart linting
1 parent 03b4661 commit b307ef4

File tree

2 files changed

+17
-56
lines changed

2 files changed

+17
-56
lines changed

scripts/lint-affected.mjs

Lines changed: 4 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@ import path from 'node:path'
88

99
import { promises as fs } from 'node:fs'
1010

11-
import { logger } from '../dist/logger.js'
12-
import { spawn } from '../dist/spawn.js'
11+
import WIN32 from '@socketsecurity/registry/lib/constants/WIN32'
12+
import { logger } from '@socketsecurity/registry/lib/logger'
13+
import { spawn } from '@socketsecurity/registry/lib/spawn'
1314

14-
import constants from './constants.mjs'
1515
import { getChangedFiles, getStagedFiles } from './utils/git.mjs'
1616
import { runCommandQuiet } from './utils/run-command.mjs'
1717

@@ -113,32 +113,6 @@ async function runLintersOnFiles(files, options = {}) {
113113

114114
// Build the linter configurations.
115115
const linters = [
116-
{
117-
args: [
118-
'exec',
119-
'oxlint',
120-
'-c=.config/oxlintrc.json',
121-
'--ignore-path=.config/.oxlintignore',
122-
'--tsconfig=tsconfig.json',
123-
...(fix ? ['--fix'] : []),
124-
...files,
125-
],
126-
name: 'oxlint',
127-
enabled: true,
128-
},
129-
{
130-
args: [
131-
'exec',
132-
'biome',
133-
'format',
134-
'--log-level=none',
135-
...(fix ? ['--write'] : ['--check']),
136-
...files,
137-
],
138-
name: 'biome',
139-
// Only run biome when fixing.
140-
enabled: fix,
141-
},
142116
{
143117
args: [
144118
'exec',
@@ -191,32 +165,6 @@ async function runLintersOnAll(options = {}) {
191165
logger.log('Running linters on all files...\n')
192166

193167
const linters = [
194-
{
195-
args: [
196-
'exec',
197-
'oxlint',
198-
'-c=.config/oxlintrc.json',
199-
'--ignore-path=.config/.oxlintignore',
200-
'--tsconfig=tsconfig.json',
201-
...(fix ? ['--fix'] : []),
202-
'.',
203-
],
204-
name: 'oxlint',
205-
enabled: true,
206-
},
207-
{
208-
args: [
209-
'exec',
210-
'biome',
211-
'format',
212-
'--log-level=none',
213-
...(fix ? ['--write'] : ['--check']),
214-
'.',
215-
],
216-
name: 'biome',
217-
// Only run biome when fixing.
218-
enabled: fix,
219-
},
220168
{
221169
args: [
222170
'exec',
@@ -387,7 +335,7 @@ async function main() {
387335
],
388336
{
389337
cwd: absolutePath,
390-
shell: constants.WIN32,
338+
shell: WIN32,
391339
stdio: 'inherit',
392340
},
393341
)

scripts/utils/git.mjs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
/**
2+
* @fileoverview Git utilities for socket-packageurl-js.
3+
* Re-exports git functions from the registry package.
4+
*/
5+
6+
export {
7+
getChangedFiles,
8+
getChangedFilesSync,
9+
getStagedFiles,
10+
getStagedFilesSync,
11+
getUnstagedFiles,
12+
getUnstagedFilesSync,
13+
} from '@socketsecurity/registry/lib/git'

0 commit comments

Comments
 (0)