@autofleet/lint 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.oxfmtrc.json +22 -0
- package/.oxlintrc.json +255 -0
- package/MIGRATION_GAPS.md +299 -0
- package/README.md +273 -0
- package/RULES.md +396 -0
- package/bin/oxfmt.cjs +43 -0
- package/bin/oxlint.cjs +44 -0
- package/bin/postinstall.cjs +87 -0
- package/package.json +44 -0
package/bin/oxfmt.cjs
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
// Wrapper script to run Oxfmt from @autofleet/lint's dependencies
|
|
4
|
+
const { spawn } = require('node:child_process');
|
|
5
|
+
const path = require('node:path');
|
|
6
|
+
|
|
7
|
+
try {
|
|
8
|
+
// Resolve oxfmt module from our package's dependencies
|
|
9
|
+
const oxfmtModulePath = require.resolve('oxfmt', {
|
|
10
|
+
paths: [__dirname]
|
|
11
|
+
});
|
|
12
|
+
// Navigate up from the resolved module to the package root
|
|
13
|
+
const oxfmtPackageDir = path.dirname(path.dirname(oxfmtModulePath));
|
|
14
|
+
const oxfmtBin = path.join(oxfmtPackageDir, 'bin', 'oxfmt');
|
|
15
|
+
|
|
16
|
+
// Get args from command line
|
|
17
|
+
const args = process.argv.slice(2);
|
|
18
|
+
|
|
19
|
+
// Check if user passed any path/pattern (anything that's not a flag)
|
|
20
|
+
const hasPattern = args.some(arg => !arg.startsWith('-'));
|
|
21
|
+
|
|
22
|
+
// Default to 'src' if no pattern provided
|
|
23
|
+
if (!hasPattern) {
|
|
24
|
+
args.push('src');
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
const child = spawn(oxfmtBin, args, {
|
|
28
|
+
stdio: 'inherit',
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
child.on('exit', (code) => {
|
|
32
|
+
process.exit(code || 0);
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
child.on('error', (err) => {
|
|
36
|
+
console.error('Failed to start oxfmt:', err.message);
|
|
37
|
+
process.exit(1);
|
|
38
|
+
});
|
|
39
|
+
} catch (err) {
|
|
40
|
+
console.error('Could not find oxfmt. Make sure @autofleet/lint is properly installed.');
|
|
41
|
+
console.error(err.message);
|
|
42
|
+
process.exit(1);
|
|
43
|
+
}
|
package/bin/oxlint.cjs
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
// Wrapper script to run Oxlint from @autofleet/lint's dependencies with auto-fix support
|
|
4
|
+
const { spawn } = require('node:child_process');
|
|
5
|
+
const path = require('node:path');
|
|
6
|
+
|
|
7
|
+
try {
|
|
8
|
+
// Resolve oxlint module from our package's dependencies
|
|
9
|
+
const oxlintModulePath = require.resolve('oxlint', {
|
|
10
|
+
paths: [__dirname]
|
|
11
|
+
});
|
|
12
|
+
// Navigate up from the resolved module to the package root
|
|
13
|
+
// oxlint resolves to dist/index.js, so we go up one level
|
|
14
|
+
const oxlintPackageDir = path.dirname(path.dirname(oxlintModulePath));
|
|
15
|
+
const oxlintBin = path.join(oxlintPackageDir, 'bin', 'oxlint');
|
|
16
|
+
|
|
17
|
+
// Get args from command line
|
|
18
|
+
const args = process.argv.slice(2);
|
|
19
|
+
|
|
20
|
+
// Check if user passed any path (anything that's not a flag)
|
|
21
|
+
const hasPath = args.some(arg => !arg.startsWith('-'));
|
|
22
|
+
|
|
23
|
+
// Default to 'src' if no path provided
|
|
24
|
+
if (!hasPath) {
|
|
25
|
+
args.push('src');
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
const child = spawn(oxlintBin, args, {
|
|
29
|
+
stdio: 'inherit',
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
child.on('exit', (code) => {
|
|
33
|
+
process.exit(code || 0);
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
child.on('error', (err) => {
|
|
37
|
+
console.error('Failed to start oxlint:', err.message);
|
|
38
|
+
process.exit(1);
|
|
39
|
+
});
|
|
40
|
+
} catch (err) {
|
|
41
|
+
console.error('Could not find oxlint. Make sure @autofleet/lint is properly installed.');
|
|
42
|
+
console.error(err.message);
|
|
43
|
+
process.exit(1);
|
|
44
|
+
}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
// Ensures native bindings for oxlint and oxfmt are installed where each tool can find them.
|
|
4
|
+
// Both tools use createRequire(import.meta.url) to load bindings, so the bindings
|
|
5
|
+
// must be resolvable from each tool's own package directory.
|
|
6
|
+
// npm does not install optionalDependencies of transitive packages, so we handle it here
|
|
7
|
+
// by directly extracting the binding tarball into each tool's node_modules.
|
|
8
|
+
|
|
9
|
+
const { execFileSync } = require('node:child_process');
|
|
10
|
+
const fs = require('node:fs');
|
|
11
|
+
const os = require('node:os');
|
|
12
|
+
const path = require('node:path');
|
|
13
|
+
|
|
14
|
+
const OXLINT_PLATFORM_TO_BINDING = {
|
|
15
|
+
'darwin-arm64': '@oxlint/binding-darwin-arm64',
|
|
16
|
+
'darwin-x64': '@oxlint/binding-darwin-x64',
|
|
17
|
+
'linux-x64': '@oxlint/binding-linux-x64-gnu',
|
|
18
|
+
'linux-arm64': '@oxlint/binding-linux-arm64-gnu',
|
|
19
|
+
'win32-x64': '@oxlint/binding-win32-x64-msvc',
|
|
20
|
+
'win32-arm64': '@oxlint/binding-win32-arm64-msvc',
|
|
21
|
+
'freebsd-x64': '@oxlint/binding-freebsd-x64',
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
const OXFMT_PLATFORM_TO_BINDING = {
|
|
25
|
+
'darwin-arm64': '@oxfmt/binding-darwin-arm64',
|
|
26
|
+
'darwin-x64': '@oxfmt/binding-darwin-x64',
|
|
27
|
+
'linux-x64': '@oxfmt/binding-linux-x64-gnu',
|
|
28
|
+
'linux-arm64': '@oxfmt/binding-linux-arm64-gnu',
|
|
29
|
+
'win32-x64': '@oxfmt/binding-win32-x64-msvc',
|
|
30
|
+
'win32-arm64': '@oxfmt/binding-win32-arm64-msvc',
|
|
31
|
+
'freebsd-x64': '@oxfmt/binding-freebsd-x64',
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
const platform = `${process.platform}-${process.arch}`;
|
|
35
|
+
const lintDir = path.resolve(__dirname, '..');
|
|
36
|
+
|
|
37
|
+
const installBinding = (toolName, moduleName, platformMap) => {
|
|
38
|
+
const bindingPackage = platformMap[platform];
|
|
39
|
+
if (!bindingPackage) {
|
|
40
|
+
console.warn(`@autofleet/lint postinstall: No known ${toolName} binding for platform ${platform}, skipping.`);
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
try {
|
|
45
|
+
const modulePath = require.resolve(moduleName, { paths: [lintDir] });
|
|
46
|
+
const moduleDir = path.dirname(path.dirname(modulePath));
|
|
47
|
+
const bindingDestDir = path.join(moduleDir, 'node_modules', bindingPackage);
|
|
48
|
+
|
|
49
|
+
if (fs.existsSync(bindingDestDir) && fs.readdirSync(bindingDestDir).some(f => f.endsWith('.node'))) {
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
const modulePkg = JSON.parse(fs.readFileSync(path.join(moduleDir, 'package.json'), 'utf8'));
|
|
54
|
+
const bindingVersion = modulePkg.optionalDependencies?.[bindingPackage];
|
|
55
|
+
|
|
56
|
+
if (!bindingVersion) {
|
|
57
|
+
console.warn(`@autofleet/lint postinstall: Could not determine binding version from ${toolName} package.json.`);
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
console.log(`@autofleet/lint postinstall: Installing ${bindingPackage}@${bindingVersion} for ${toolName}...`);
|
|
62
|
+
|
|
63
|
+
const tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), `${toolName}-binding-`));
|
|
64
|
+
try {
|
|
65
|
+
execFileSync('npm', ['pack', `${bindingPackage}@${bindingVersion}`, '--pack-destination', tmpDir], {
|
|
66
|
+
stdio: 'pipe',
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
const tarballs = fs.readdirSync(tmpDir).filter(f => f.endsWith('.tgz'));
|
|
70
|
+
if (tarballs.length === 0) { throw new Error('npm pack produced no tarball'); }
|
|
71
|
+
|
|
72
|
+
const tarball = path.join(tmpDir, tarballs[0]);
|
|
73
|
+
fs.mkdirSync(bindingDestDir, { recursive: true });
|
|
74
|
+
execFileSync('tar', ['-xzf', tarball, '-C', bindingDestDir, '--strip-components=1'], { stdio: 'pipe' });
|
|
75
|
+
|
|
76
|
+
console.log(`@autofleet/lint postinstall: ${toolName} native binding installed successfully.`);
|
|
77
|
+
} finally {
|
|
78
|
+
fs.rmSync(tmpDir, { recursive: true, force: true });
|
|
79
|
+
}
|
|
80
|
+
} catch (err) {
|
|
81
|
+
console.warn(`@autofleet/lint postinstall: Could not install ${toolName} native binding: ${err.message}`);
|
|
82
|
+
console.warn(`If ${toolName} fails, add "${moduleName}" to your devDependencies as a workaround.`);
|
|
83
|
+
}
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
installBinding('oxlint', 'oxlint', OXLINT_PLATFORM_TO_BINDING);
|
|
87
|
+
installBinding('oxfmt', 'oxfmt', OXFMT_PLATFORM_TO_BINDING);
|
package/package.json
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@autofleet/lint",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Shared Oxlint and Oxfmt configuration for Autofleet projects (Rust-powered, ultra-fast)",
|
|
5
|
+
"main": "index.js",
|
|
6
|
+
"bin": {
|
|
7
|
+
"autofleet-lint": "./bin/oxlint.cjs",
|
|
8
|
+
"autofleet-fmt": "./bin/oxfmt.cjs"
|
|
9
|
+
},
|
|
10
|
+
"scripts": {
|
|
11
|
+
"build": "echo 'No build needed - config files only'",
|
|
12
|
+
"postinstall": "node ./bin/postinstall.cjs"
|
|
13
|
+
},
|
|
14
|
+
"author": "Autofleet",
|
|
15
|
+
"license": "ISC",
|
|
16
|
+
"repository": {
|
|
17
|
+
"type": "git",
|
|
18
|
+
"url": "git+https://github.com/Autofleet/autorepo.git",
|
|
19
|
+
"directory": "packages/lint"
|
|
20
|
+
},
|
|
21
|
+
"files": [
|
|
22
|
+
"bin/",
|
|
23
|
+
".oxlintrc.json",
|
|
24
|
+
".oxfmtrc.json",
|
|
25
|
+
"MIGRATION_GAPS.md",
|
|
26
|
+
"README.md",
|
|
27
|
+
"RULES.md"
|
|
28
|
+
],
|
|
29
|
+
"dependencies": {
|
|
30
|
+
"oxfmt": "^0.41.0",
|
|
31
|
+
"oxlint": "^1.56.0"
|
|
32
|
+
},
|
|
33
|
+
"keywords": [
|
|
34
|
+
"oxlint",
|
|
35
|
+
"oxfmt",
|
|
36
|
+
"lint",
|
|
37
|
+
"format",
|
|
38
|
+
"config",
|
|
39
|
+
"autofleet",
|
|
40
|
+
"batteries-included",
|
|
41
|
+
"rust",
|
|
42
|
+
"fast"
|
|
43
|
+
]
|
|
44
|
+
}
|