Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
21dc586
build: remove unmaintained `cross-spawn` package.
yCodeTech Oct 1, 2025
eba6c33
remove: the redundant `encoding` and `tty` spawn options from sniffer.
yCodeTech Oct 2, 2025
a30b23f
fix: `std*` possibly being null TS errors by checking if they're truthy.
yCodeTech Oct 2, 2025
359ddc5
Improve Error Reporting (#171)
yCodeTech Oct 2, 2025
facb4cb
fix: prevent the process from hanging if we can't write to `stdin`.
yCodeTech Oct 2, 2025
e10798c
refactor: fixer's `determineNodeError` function and move into utils.
yCodeTech Oct 4, 2025
bc5980e
fix: remove unused import
yCodeTech Oct 4, 2025
5993f33
refactor: extract platform check into new dedicated `isWin` function.
yCodeTech Oct 10, 2025
7b62982
feat: add Windows ENOENT error handling for fixer and sniffer processes
yCodeTech Oct 10, 2025
6e40824
fix: ts error `error TS2315: Type 'Buffer' is not generic.`
yCodeTech Oct 10, 2025
7e64111
refactor: organise utility files into a new directory and renaming files
yCodeTech Oct 12, 2025
6e3d7a9
refactor: `getArgs` function in sniffer and fixer into 1 helper function
yCodeTech Oct 12, 2025
2368fb5
fix: ts error `error TS2304: Cannot find name 'TextDocument'.`
yCodeTech Oct 12, 2025
1374d6c
refactor: integrate path normalization and joining in settings resolver.
yCodeTech Oct 24, 2025
6d9a74d
refactor: `getArgs` to pass the `fileName` as `filePath` arg.
yCodeTech Oct 25, 2025
ac2e9b3
refactor: remove double quotes from the args in the `getArgs` function.
yCodeTech Oct 25, 2025
5cdab03
fix: ENOENT handling to use original command info instead of `parsed`.
yCodeTech Oct 25, 2025
789f2ca
feat: add `parseArgs` helper function for command line argument handling
yCodeTech Oct 29, 2025
9ff2043
feat: add validation for standards, blocking command injection attacks.
yCodeTech Oct 30, 2025
3287939
refactor: `additionalArgument` filtering into new `validateAdditional…
yCodeTech Oct 31, 2025
b16e5be
refactor: `validate` settings function for DRYer code and warn the user.
yCodeTech Nov 9, 2025
c89a626
feat: validate the arguments against a whitelist.
yCodeTech Nov 10, 2025
5bcfec4
fix: the arguments whitelist docblock types.
yCodeTech Nov 10, 2025
8b43573
fix: the import path resolution.
yCodeTech Nov 10, 2025
8c79ebe
fix: Node 24 spawn deprecation of passing args as array when using shell
yCodeTech Nov 11, 2025
d55b7ec
refactor: user messages in `validateAdditionalArguments` to be clearer.
yCodeTech Nov 12, 2025
a3e13e7
fix: the `ts-watch` script to use the proper `--watch` flag
yCodeTech Nov 12, 2025
c1cce59
fix: `isStandardValid` function to check if it's an allowed xml ruleset.
yCodeTech Nov 12, 2025
2642308
fix: warnings should only appear if args were invalid.
yCodeTech Nov 13, 2025
f852ec0
fix: `activateSniffer` shouldn't be checking if sniffer enabled or not.
yCodeTech Nov 15, 2025
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
2 changes: 0 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -155,11 +155,9 @@
"ts-watch": "tsc -watch -p ./"
},
"dependencies": {
"cross-spawn": "^7.0.3",
"lodash": "^4.17.21"
},
"devDependencies": {
"@types/cross-spawn": "^6.0.6",
"@types/lodash": "^4.14.202",
"@types/mocha": "^10.0.6",
"@types/node": "^20.11.20",
Expand Down
13 changes: 8 additions & 5 deletions src/fixer.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import spawn from 'cross-spawn';
import { SpawnSyncOptions } from 'node:child_process';
import { spawnSync, SpawnSyncOptions } from 'node:child_process';
import {
ConfigurationChangeEvent,
Disposable,
Expand Down Expand Up @@ -74,9 +73,9 @@ const getArgs = (
*/

if (standard !== '') {
args.push(`--standard=${standard}`);
args.push(`--standard="${standard}"`);
}
args.push(`--stdin-path=${filePath}`);
args.push(`--stdin-path="${filePath}"`);
args = args.concat(additionalArguments);
args.push('-');
return args;
Expand Down Expand Up @@ -154,13 +153,17 @@ const format = async (document: TextDocument, fullDocument: boolean) => {
env: process.env,
encoding: 'utf8',
input: fileText,
// Required to prevent EINVAL errors when spawning .bat files on Windows.
// https://github.com/valeryan/vscode-phpsab/issues/128
// https://github.com/nodejs/node/issues/52554
shell: true,
};

logger.info(
`FIXER COMMAND: ${resourceConf.executablePathCBF} ${lintArgs.join(' ')}`,
);

const fixer = spawn.sync(resourceConf.executablePathCBF, lintArgs, options);
const fixer = spawnSync(resourceConf.executablePathCBF, lintArgs, options);
const stdout = fixer.stdout.toString();

let fixed = stdout;
Expand Down
9 changes: 6 additions & 3 deletions src/sniffer.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
import { debounce } from 'lodash';
import { spawn } from 'node:child_process';
import { spawn, SpawnOptions } from 'node:child_process';
import {
CancellationTokenSource,
ConfigurationChangeEvent,
Diagnostic,
DiagnosticCollection,
DiagnosticSeverity,
Disposable,
languages,
Range,
TextDocument,
TextDocumentChangeEvent,
Uri,
languages,
window,
workspace,
} from 'vscode';
Expand Down Expand Up @@ -134,14 +134,17 @@

let fileText = document.getText();

const options = {
const options: SpawnOptions = {
cwd:
resourceConf.workspaceRoot !== null
? resourceConf.workspaceRoot
: undefined,
env: process.env,
encoding: 'utf8',

Check failure on line 143 in src/sniffer.ts

View workflow job for this annotation

GitHub Actions / test

Object literal may only specify known properties, and 'encoding' does not exist in type 'SpawnOptions'.
tty: true,
// Required to prevent EINVAL errors when spawning .bat files on Windows.
// https://github.com/valeryan/vscode-phpsab/issues/128
// https://github.com/nodejs/node/issues/52554
shell: true,
};
logger.info(
Expand All @@ -150,14 +153,14 @@

const sniffer = spawn(resourceConf.executablePathCS, lintArgs, options);

sniffer.stdin.write(fileText);

Check failure on line 156 in src/sniffer.ts

View workflow job for this annotation

GitHub Actions / test

'sniffer.stdin' is possibly 'null'.
sniffer.stdin.end();

Check failure on line 157 in src/sniffer.ts

View workflow job for this annotation

GitHub Actions / test

'sniffer.stdin' is possibly 'null'.

let stdout = '';
let stderr = '';

sniffer.stdout.on('data', (data) => (stdout += data));

Check failure on line 162 in src/sniffer.ts

View workflow job for this annotation

GitHub Actions / test

'sniffer.stdout' is possibly 'null'.
sniffer.stderr.on('data', (data) => (stderr += data));

Check failure on line 163 in src/sniffer.ts

View workflow job for this annotation

GitHub Actions / test

'sniffer.stderr' is possibly 'null'.

const done = new Promise<void>((resolve, reject) => {
sniffer.on('close', () => {
Expand Down
Loading