eslint-plugin-etc-misc 1.1.2 → 1.1.4
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/dist/plugin.cjs +133 -1
- package/dist/plugin.cjs.map +3 -3
- package/dist/rules/no-vulnerable.d.ts.map +1 -1
- package/dist/rules/no-vulnerable.js +148 -1
- package/dist/rules/no-vulnerable.js.map +1 -1
- package/docs/AGENTS.md +186 -0
- package/docs/docusaurus/AGENTS.md +27 -0
- package/docs/docusaurus/sidebars.rules.ts +1 -1
- package/docs/rules/no-expression-empty-lines.md +3 -1
- package/docs/rules/no-function-declare-after-return.md +6 -0
- package/docs/rules/no-use-extend-native.md +6 -0
- package/docs/rules/no-vulnerable.md +12 -0
- package/package.json +1 -1
package/dist/plugin.cjs
CHANGED
|
@@ -3745,8 +3745,111 @@ var deprecatedRule14 = withDeprecatedRuleLifecycle(rule53, {
|
|
|
3745
3745
|
var no_value_tostring_default = deprecatedRule14;
|
|
3746
3746
|
|
|
3747
3747
|
// dist/rules/no-vulnerable.js
|
|
3748
|
+
var import_node_fs = require("node:fs");
|
|
3749
|
+
var import_node_module = require("node:module");
|
|
3750
|
+
var import_node_path5 = require("node:path");
|
|
3748
3751
|
var import_recheck = require("recheck");
|
|
3749
3752
|
var import_ts_extras38 = require("ts-extras");
|
|
3753
|
+
var requireFromWorkingDirectory = (0, import_node_module.createRequire)((0, import_node_path5.join)(process.cwd(), "package.json"));
|
|
3754
|
+
var isUnknownRecord2 = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
3755
|
+
var isModuleNotFoundError = (error) => {
|
|
3756
|
+
if (!isUnknownRecord2(error)) {
|
|
3757
|
+
return false;
|
|
3758
|
+
}
|
|
3759
|
+
return (0, import_ts_extras38.keyIn)(error, "code") && error["code"] === "MODULE_NOT_FOUND";
|
|
3760
|
+
};
|
|
3761
|
+
var createRequireFromPluginPackage = () => {
|
|
3762
|
+
try {
|
|
3763
|
+
return (0, import_node_module.createRequire)(requireFromWorkingDirectory.resolve("eslint-plugin-etc-misc/package.json"));
|
|
3764
|
+
} catch (error) {
|
|
3765
|
+
if (isModuleNotFoundError(error)) {
|
|
3766
|
+
return requireFromWorkingDirectory;
|
|
3767
|
+
}
|
|
3768
|
+
throw error;
|
|
3769
|
+
}
|
|
3770
|
+
};
|
|
3771
|
+
var requireFromPluginPackage = createRequireFromPluginPackage();
|
|
3772
|
+
var isExistingFile = (filePath) => {
|
|
3773
|
+
try {
|
|
3774
|
+
return (0, import_node_fs.statSync)(filePath).isFile();
|
|
3775
|
+
} catch {
|
|
3776
|
+
return false;
|
|
3777
|
+
}
|
|
3778
|
+
};
|
|
3779
|
+
var shouldOverrideRuntimePath = (currentPath) => !(0, import_ts_extras38.isDefined)(currentPath) || !isExistingFile(currentPath) || (0, import_node_path5.basename)(currentPath).toLowerCase() === "package.json";
|
|
3780
|
+
var resolvePackageSiblingFile = (packageJsonSpecifier, siblingFileName) => {
|
|
3781
|
+
try {
|
|
3782
|
+
const packageJsonPath = requireFromPluginPackage.resolve(packageJsonSpecifier);
|
|
3783
|
+
return (0, import_node_path5.join)((0, import_node_path5.dirname)(packageJsonPath), siblingFileName);
|
|
3784
|
+
} catch (error) {
|
|
3785
|
+
if (isModuleNotFoundError(error)) {
|
|
3786
|
+
return null;
|
|
3787
|
+
}
|
|
3788
|
+
throw error;
|
|
3789
|
+
}
|
|
3790
|
+
};
|
|
3791
|
+
var resolveRecheckJarPath = () => resolvePackageSiblingFile("recheck-jar/package.json", "recheck.jar");
|
|
3792
|
+
var resolveRecheckWindowsBinaryPath = () => {
|
|
3793
|
+
if (process.platform !== "win32" || process.arch !== "x64") {
|
|
3794
|
+
return null;
|
|
3795
|
+
}
|
|
3796
|
+
return resolvePackageSiblingFile("recheck-windows-x64/package.json", "recheck.exe");
|
|
3797
|
+
};
|
|
3798
|
+
var recheckJarPath = process.platform === "win32" ? resolveRecheckJarPath() : null;
|
|
3799
|
+
var recheckWindowsBinaryPath = process.platform === "win32" ? resolveRecheckWindowsBinaryPath() : null;
|
|
3800
|
+
var deleteRecheckEnvironmentValue = (key) => {
|
|
3801
|
+
if (key === "RECHECK_BIN") {
|
|
3802
|
+
delete process.env["RECHECK_BIN"];
|
|
3803
|
+
return;
|
|
3804
|
+
}
|
|
3805
|
+
delete process.env["RECHECK_JAR"];
|
|
3806
|
+
};
|
|
3807
|
+
var getRecheckEnvironmentValue = (key) => key === "RECHECK_BIN" ? process.env["RECHECK_BIN"] : process.env["RECHECK_JAR"];
|
|
3808
|
+
var setRecheckEnvironmentValue = (key, value) => {
|
|
3809
|
+
if (key === "RECHECK_BIN") {
|
|
3810
|
+
process.env["RECHECK_BIN"] = value;
|
|
3811
|
+
return;
|
|
3812
|
+
}
|
|
3813
|
+
process.env["RECHECK_JAR"] = value;
|
|
3814
|
+
};
|
|
3815
|
+
var getRecheckEnvironmentOverrides = () => {
|
|
3816
|
+
if (process.platform !== "win32") {
|
|
3817
|
+
return {};
|
|
3818
|
+
}
|
|
3819
|
+
const overrides = {};
|
|
3820
|
+
if (recheckJarPath !== null && isExistingFile(recheckJarPath) && shouldOverrideRuntimePath(getRecheckEnvironmentValue("RECHECK_JAR"))) {
|
|
3821
|
+
overrides.RECHECK_JAR = recheckJarPath;
|
|
3822
|
+
}
|
|
3823
|
+
if (recheckWindowsBinaryPath !== null && isExistingFile(recheckWindowsBinaryPath) && shouldOverrideRuntimePath(getRecheckEnvironmentValue("RECHECK_BIN"))) {
|
|
3824
|
+
overrides.RECHECK_BIN = recheckWindowsBinaryPath;
|
|
3825
|
+
}
|
|
3826
|
+
return overrides;
|
|
3827
|
+
};
|
|
3828
|
+
var restoreEnvironmentValue = (key, value) => {
|
|
3829
|
+
if (!(0, import_ts_extras38.isDefined)(value)) {
|
|
3830
|
+
deleteRecheckEnvironmentValue(key);
|
|
3831
|
+
return;
|
|
3832
|
+
}
|
|
3833
|
+
setRecheckEnvironmentValue(key, value);
|
|
3834
|
+
};
|
|
3835
|
+
var withRecheckEnvironmentOverrides = (callback) => {
|
|
3836
|
+
const overrides = getRecheckEnvironmentOverrides();
|
|
3837
|
+
const previousBin = getRecheckEnvironmentValue("RECHECK_BIN");
|
|
3838
|
+
const previousJar = getRecheckEnvironmentValue("RECHECK_JAR");
|
|
3839
|
+
if ((0, import_ts_extras38.isDefined)(overrides.RECHECK_BIN)) {
|
|
3840
|
+
setRecheckEnvironmentValue("RECHECK_BIN", overrides.RECHECK_BIN);
|
|
3841
|
+
}
|
|
3842
|
+
if ((0, import_ts_extras38.isDefined)(overrides.RECHECK_JAR)) {
|
|
3843
|
+
setRecheckEnvironmentValue("RECHECK_JAR", overrides.RECHECK_JAR);
|
|
3844
|
+
}
|
|
3845
|
+
try {
|
|
3846
|
+
return callback();
|
|
3847
|
+
} finally {
|
|
3848
|
+
restoreEnvironmentValue("RECHECK_BIN", previousBin);
|
|
3849
|
+
restoreEnvironmentValue("RECHECK_JAR", previousJar);
|
|
3850
|
+
}
|
|
3851
|
+
};
|
|
3852
|
+
var runRecheck = (source, flags, parameters) => withRecheckEnvironmentOverrides(() => (0, import_recheck.checkSync)(source, flags, parameters));
|
|
3750
3853
|
var getStaticStringValue = (node) => {
|
|
3751
3854
|
if (node.type === "Literal" && typeof node.value === "string") {
|
|
3752
3855
|
return node.value;
|
|
@@ -3796,13 +3899,42 @@ var getDiagnosticsErrorMessage = (error) => {
|
|
|
3796
3899
|
}
|
|
3797
3900
|
return "No additional details provided.";
|
|
3798
3901
|
};
|
|
3902
|
+
var getThrownErrorMessage = (error) => {
|
|
3903
|
+
if (error instanceof Error && error.message.length > 0) {
|
|
3904
|
+
return error.message;
|
|
3905
|
+
}
|
|
3906
|
+
if (typeof error === "string" && error.length > 0) {
|
|
3907
|
+
return error;
|
|
3908
|
+
}
|
|
3909
|
+
return "No additional details provided.";
|
|
3910
|
+
};
|
|
3799
3911
|
var rule54 = ruleCreator({
|
|
3800
3912
|
create: (context, [rawOptions]) => {
|
|
3801
3913
|
const options = rawOptions ?? {};
|
|
3802
3914
|
const { ignoreErrors = true, permittableComplexities = [], ...recheckParameters } = options;
|
|
3803
3915
|
const allowedComplexities = new Set(permittableComplexities);
|
|
3804
3916
|
const reportDiagnostics = (node, source, flags) => {
|
|
3805
|
-
const diagnostics = (
|
|
3917
|
+
const diagnostics = (() => {
|
|
3918
|
+
try {
|
|
3919
|
+
return runRecheck(source, flags, recheckParameters);
|
|
3920
|
+
} catch (error) {
|
|
3921
|
+
if (ignoreErrors) {
|
|
3922
|
+
return null;
|
|
3923
|
+
}
|
|
3924
|
+
context.report({
|
|
3925
|
+
data: {
|
|
3926
|
+
kind: "unexpected",
|
|
3927
|
+
message: getThrownErrorMessage(error)
|
|
3928
|
+
},
|
|
3929
|
+
messageId: "checkerError",
|
|
3930
|
+
node
|
|
3931
|
+
});
|
|
3932
|
+
return null;
|
|
3933
|
+
}
|
|
3934
|
+
})();
|
|
3935
|
+
if (diagnostics === null) {
|
|
3936
|
+
return;
|
|
3937
|
+
}
|
|
3806
3938
|
if (diagnostics.status === "safe") {
|
|
3807
3939
|
return;
|
|
3808
3940
|
}
|