@codacy/tools-eslint-9 0.24.0 → 0.25.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/README.md +6 -5
- package/dist/index.js +349 -267
- package/package.json +7 -4
- package/payload/package-lock.json +13278 -0
- package/payload/package.json +128 -0
package/dist/index.js
CHANGED
|
@@ -33,11 +33,11 @@ __export(index_exports, {
|
|
|
33
33
|
default: () => index_default
|
|
34
34
|
});
|
|
35
35
|
module.exports = __toCommonJS(index_exports);
|
|
36
|
-
var
|
|
36
|
+
var import_tooling4 = require("@codacy/tooling");
|
|
37
37
|
|
|
38
38
|
// src/adapter.ts
|
|
39
|
-
var
|
|
40
|
-
var
|
|
39
|
+
var import_tooling3 = require("@codacy/tooling");
|
|
40
|
+
var import_path4 = __toESM(require("path"));
|
|
41
41
|
var import_fs3 = __toESM(require("fs"));
|
|
42
42
|
var import_module = require("module");
|
|
43
43
|
var import_async_hooks = require("async_hooks");
|
|
@@ -33634,7 +33634,8 @@ var patterns_default = [
|
|
|
33634
33634
|
|
|
33635
33635
|
// src/config-builder.ts
|
|
33636
33636
|
var import_fs2 = __toESM(require("fs"));
|
|
33637
|
-
var
|
|
33637
|
+
var import_path3 = __toESM(require("path"));
|
|
33638
|
+
var import_tooling2 = require("@codacy/tooling");
|
|
33638
33639
|
|
|
33639
33640
|
// src/blacklist.ts
|
|
33640
33641
|
var import_fs = __toESM(require("fs"));
|
|
@@ -33835,114 +33836,120 @@ function shouldSkipRule(ruleId, pattern, ctx) {
|
|
|
33835
33836
|
}
|
|
33836
33837
|
|
|
33837
33838
|
// src/plugin-registry.ts
|
|
33838
|
-
|
|
33839
|
-
|
|
33840
|
-
return
|
|
33839
|
+
var import_tooling = require("@codacy/tooling");
|
|
33840
|
+
async function loadPlugin(root, packageName) {
|
|
33841
|
+
return (0, import_tooling.importFromRoot)(root, packageName);
|
|
33841
33842
|
}
|
|
33842
33843
|
var KNOWN_PLUGINS = [
|
|
33843
33844
|
// --- Scoped plugins (@scope/plugin) ---
|
|
33844
33845
|
{
|
|
33845
33846
|
prefix: "@angular-eslint",
|
|
33846
|
-
load: () => loadPlugin("@angular-eslint/eslint-plugin")
|
|
33847
|
+
load: (root) => loadPlugin(root, "@angular-eslint/eslint-plugin")
|
|
33847
33848
|
},
|
|
33848
33849
|
{
|
|
33849
33850
|
prefix: "@lwc/lwc",
|
|
33850
|
-
load: () => loadPlugin("@lwc/eslint-plugin-lwc")
|
|
33851
|
+
load: (root) => loadPlugin(root, "@lwc/eslint-plugin-lwc")
|
|
33851
33852
|
},
|
|
33852
33853
|
{
|
|
33853
33854
|
prefix: "@salesforce/lightning",
|
|
33854
|
-
load: () => loadPlugin("@salesforce/eslint-plugin-lightning")
|
|
33855
|
+
load: (root) => loadPlugin(root, "@salesforce/eslint-plugin-lightning")
|
|
33855
33856
|
},
|
|
33856
33857
|
{
|
|
33857
33858
|
prefix: "@shopify",
|
|
33858
|
-
load: () => loadPlugin("@shopify/eslint-plugin")
|
|
33859
|
+
load: (root) => loadPlugin(root, "@shopify/eslint-plugin")
|
|
33859
33860
|
},
|
|
33860
33861
|
{
|
|
33861
33862
|
prefix: "@stylistic",
|
|
33862
|
-
load: () => loadPlugin("@stylistic/eslint-plugin")
|
|
33863
|
+
load: (root) => loadPlugin(root, "@stylistic/eslint-plugin")
|
|
33863
33864
|
},
|
|
33864
33865
|
{
|
|
33865
33866
|
prefix: "@tanstack/query",
|
|
33866
|
-
load: () => loadPlugin("@tanstack/eslint-plugin-query")
|
|
33867
|
+
load: (root) => loadPlugin(root, "@tanstack/eslint-plugin-query")
|
|
33867
33868
|
},
|
|
33868
33869
|
{
|
|
33869
33870
|
prefix: "@typescript-eslint",
|
|
33870
|
-
load: async () => {
|
|
33871
|
-
const mod = await
|
|
33871
|
+
load: async (root) => {
|
|
33872
|
+
const mod = await (0, import_tooling.importFromRoot)(root, "typescript-eslint", { raw: true });
|
|
33872
33873
|
return mod.default?.plugin ?? mod.plugin;
|
|
33873
33874
|
}
|
|
33874
33875
|
},
|
|
33875
33876
|
{
|
|
33876
33877
|
prefix: "@vitest",
|
|
33877
|
-
load: () => loadPlugin("@vitest/eslint-plugin")
|
|
33878
|
+
load: (root) => loadPlugin(root, "@vitest/eslint-plugin")
|
|
33878
33879
|
},
|
|
33879
33880
|
// --- Non-scoped plugins (eslint-plugin-xxx) ---
|
|
33880
|
-
{ prefix: "angular", load: () => loadPlugin("eslint-plugin-angular") },
|
|
33881
|
-
{ prefix: "ava", load: () => loadPlugin("eslint-plugin-ava") },
|
|
33882
|
-
{ prefix: "backbone", load: () => loadPlugin("eslint-plugin-backbone") },
|
|
33883
|
-
{ prefix: "check-file", load: () => loadPlugin("eslint-plugin-check-file") },
|
|
33884
|
-
{ prefix: "compat", load: () => loadPlugin("eslint-plugin-compat") },
|
|
33885
|
-
{ prefix: "cypress", load: () => loadPlugin("eslint-plugin-cypress") },
|
|
33886
|
-
{ prefix: "ember", load: () => loadPlugin("eslint-plugin-ember") },
|
|
33887
|
-
{ prefix: "ember-suave", load: () => loadPlugin("eslint-plugin-ember-suave") },
|
|
33888
|
-
{ prefix: "es-x", load: () => loadPlugin("eslint-plugin-es-x") },
|
|
33889
|
-
{ prefix: "eslint-plugin", load: () => loadPlugin("eslint-plugin-eslint-plugin") },
|
|
33890
|
-
{ prefix: "fp", load: () => loadPlugin("eslint-plugin-fp") },
|
|
33891
|
-
{ prefix: "functional", load: () => loadPlugin("eslint-plugin-functional") },
|
|
33892
|
-
{ prefix: "i18next", load: () => loadPlugin("eslint-plugin-i18next") },
|
|
33893
|
-
{ prefix: "import", load: () => loadPlugin("eslint-plugin-import") },
|
|
33894
|
-
{ prefix: "jasmine", load: () => loadPlugin("eslint-plugin-jasmine") },
|
|
33895
|
-
{ prefix: "jest", load: () => loadPlugin("eslint-plugin-jest") },
|
|
33896
|
-
{ prefix: "jest-dom", load: () => loadPlugin("eslint-plugin-jest-dom") },
|
|
33897
|
-
{ prefix: "jest-extended", load: () => loadPlugin("eslint-plugin-jest-extended") },
|
|
33898
|
-
{ prefix: "jest-formatting", load: () => loadPlugin("eslint-plugin-jest-formatting") },
|
|
33899
|
-
{ prefix: "jsdoc", load: () => loadPlugin("eslint-plugin-jsdoc") },
|
|
33900
|
-
{ prefix: "jsonc", load: () => loadPlugin("eslint-plugin-jsonc") },
|
|
33901
|
-
{ prefix: "jsx-a11y", load: () => loadPlugin("eslint-plugin-jsx-a11y") },
|
|
33902
|
-
{ prefix: "lit", load: () => loadPlugin("eslint-plugin-lit") },
|
|
33903
|
-
{ prefix: "lodash", load: () => loadPlugin("eslint-plugin-lodash") },
|
|
33904
|
-
{ prefix: "lodash-fp", load: () => loadPlugin("eslint-plugin-lodash-fp") },
|
|
33905
|
-
{ prefix: "meteor", load: () => loadPlugin("eslint-plugin-meteor") },
|
|
33906
|
-
{ prefix: "mocha", load: () => loadPlugin("eslint-plugin-mocha") },
|
|
33907
|
-
{ prefix: "n", load: () => loadPlugin("eslint-plugin-n") },
|
|
33908
|
-
{ prefix: "nuxt", load: () => loadPlugin("eslint-plugin-nuxt") },
|
|
33909
|
-
{ prefix: "perfectionist", load: () => loadPlugin("eslint-plugin-perfectionist") },
|
|
33910
|
-
{ prefix: "playwright", load: () => loadPlugin("eslint-plugin-playwright") },
|
|
33911
|
-
{ prefix: "prettier", load: () => loadPlugin("eslint-plugin-prettier") },
|
|
33912
|
-
{ prefix: "promise", load: () => loadPlugin("eslint-plugin-promise") },
|
|
33913
|
-
{ prefix: "react", load: () => loadPlugin("eslint-plugin-react") },
|
|
33914
|
-
{ prefix: "react-hooks", load: () => loadPlugin("eslint-plugin-react-hooks") },
|
|
33915
|
-
{ prefix: "react-perf", load: () => loadPlugin("eslint-plugin-react-perf") },
|
|
33916
|
-
{ prefix: "react-redux", load: () => loadPlugin("eslint-plugin-react-redux") },
|
|
33917
|
-
{ prefix: "redux-saga", load: () => loadPlugin("eslint-plugin-redux-saga") },
|
|
33918
|
-
{ prefix: "regexp", load: () => loadPlugin("eslint-plugin-regexp") },
|
|
33919
|
-
{ prefix: "security", load: () => loadPlugin("eslint-plugin-security") },
|
|
33920
|
-
{ prefix: "security-node", load: () => loadPlugin("eslint-plugin-security-node") },
|
|
33921
|
-
{ prefix: "sonarjs", load: () => loadPlugin("eslint-plugin-sonarjs") },
|
|
33922
|
-
{ prefix: "sort", load: () => loadPlugin("eslint-plugin-sort") },
|
|
33881
|
+
{ prefix: "angular", load: (root) => loadPlugin(root, "eslint-plugin-angular") },
|
|
33882
|
+
{ prefix: "ava", load: (root) => loadPlugin(root, "eslint-plugin-ava") },
|
|
33883
|
+
{ prefix: "backbone", load: (root) => loadPlugin(root, "eslint-plugin-backbone") },
|
|
33884
|
+
{ prefix: "check-file", load: (root) => loadPlugin(root, "eslint-plugin-check-file") },
|
|
33885
|
+
{ prefix: "compat", load: (root) => loadPlugin(root, "eslint-plugin-compat") },
|
|
33886
|
+
{ prefix: "cypress", load: (root) => loadPlugin(root, "eslint-plugin-cypress") },
|
|
33887
|
+
{ prefix: "ember", load: (root) => loadPlugin(root, "eslint-plugin-ember") },
|
|
33888
|
+
{ prefix: "ember-suave", load: (root) => loadPlugin(root, "eslint-plugin-ember-suave") },
|
|
33889
|
+
{ prefix: "es-x", load: (root) => loadPlugin(root, "eslint-plugin-es-x") },
|
|
33890
|
+
{ prefix: "eslint-plugin", load: (root) => loadPlugin(root, "eslint-plugin-eslint-plugin") },
|
|
33891
|
+
{ prefix: "fp", load: (root) => loadPlugin(root, "eslint-plugin-fp") },
|
|
33892
|
+
{ prefix: "functional", load: (root) => loadPlugin(root, "eslint-plugin-functional") },
|
|
33893
|
+
{ prefix: "i18next", load: (root) => loadPlugin(root, "eslint-plugin-i18next") },
|
|
33894
|
+
{ prefix: "import", load: (root) => loadPlugin(root, "eslint-plugin-import") },
|
|
33895
|
+
{ prefix: "jasmine", load: (root) => loadPlugin(root, "eslint-plugin-jasmine") },
|
|
33896
|
+
{ prefix: "jest", load: (root) => loadPlugin(root, "eslint-plugin-jest") },
|
|
33897
|
+
{ prefix: "jest-dom", load: (root) => loadPlugin(root, "eslint-plugin-jest-dom") },
|
|
33898
|
+
{ prefix: "jest-extended", load: (root) => loadPlugin(root, "eslint-plugin-jest-extended") },
|
|
33899
|
+
{ prefix: "jest-formatting", load: (root) => loadPlugin(root, "eslint-plugin-jest-formatting") },
|
|
33900
|
+
{ prefix: "jsdoc", load: (root) => loadPlugin(root, "eslint-plugin-jsdoc") },
|
|
33901
|
+
{ prefix: "jsonc", load: (root) => loadPlugin(root, "eslint-plugin-jsonc") },
|
|
33902
|
+
{ prefix: "jsx-a11y", load: (root) => loadPlugin(root, "eslint-plugin-jsx-a11y") },
|
|
33903
|
+
{ prefix: "lit", load: (root) => loadPlugin(root, "eslint-plugin-lit") },
|
|
33904
|
+
{ prefix: "lodash", load: (root) => loadPlugin(root, "eslint-plugin-lodash") },
|
|
33905
|
+
{ prefix: "lodash-fp", load: (root) => loadPlugin(root, "eslint-plugin-lodash-fp") },
|
|
33906
|
+
{ prefix: "meteor", load: (root) => loadPlugin(root, "eslint-plugin-meteor") },
|
|
33907
|
+
{ prefix: "mocha", load: (root) => loadPlugin(root, "eslint-plugin-mocha") },
|
|
33908
|
+
{ prefix: "n", load: (root) => loadPlugin(root, "eslint-plugin-n") },
|
|
33909
|
+
{ prefix: "nuxt", load: (root) => loadPlugin(root, "eslint-plugin-nuxt") },
|
|
33910
|
+
{ prefix: "perfectionist", load: (root) => loadPlugin(root, "eslint-plugin-perfectionist") },
|
|
33911
|
+
{ prefix: "playwright", load: (root) => loadPlugin(root, "eslint-plugin-playwright") },
|
|
33912
|
+
{ prefix: "prettier", load: (root) => loadPlugin(root, "eslint-plugin-prettier") },
|
|
33913
|
+
{ prefix: "promise", load: (root) => loadPlugin(root, "eslint-plugin-promise") },
|
|
33914
|
+
{ prefix: "react", load: (root) => loadPlugin(root, "eslint-plugin-react") },
|
|
33915
|
+
{ prefix: "react-hooks", load: (root) => loadPlugin(root, "eslint-plugin-react-hooks") },
|
|
33916
|
+
{ prefix: "react-perf", load: (root) => loadPlugin(root, "eslint-plugin-react-perf") },
|
|
33917
|
+
{ prefix: "react-redux", load: (root) => loadPlugin(root, "eslint-plugin-react-redux") },
|
|
33918
|
+
{ prefix: "redux-saga", load: (root) => loadPlugin(root, "eslint-plugin-redux-saga") },
|
|
33919
|
+
{ prefix: "regexp", load: (root) => loadPlugin(root, "eslint-plugin-regexp") },
|
|
33920
|
+
{ prefix: "security", load: (root) => loadPlugin(root, "eslint-plugin-security") },
|
|
33921
|
+
{ prefix: "security-node", load: (root) => loadPlugin(root, "eslint-plugin-security-node") },
|
|
33922
|
+
{ prefix: "sonarjs", load: (root) => loadPlugin(root, "eslint-plugin-sonarjs") },
|
|
33923
|
+
{ prefix: "sort", load: (root) => loadPlugin(root, "eslint-plugin-sort") },
|
|
33923
33924
|
{
|
|
33924
33925
|
prefix: "sort-destructure-keys",
|
|
33925
|
-
load: () => loadPlugin("eslint-plugin-sort-destructure-keys")
|
|
33926
|
-
},
|
|
33927
|
-
{ prefix: "storybook", load: () => loadPlugin("eslint-plugin-storybook") },
|
|
33928
|
-
{ prefix: "suitescript", load: () => loadPlugin("eslint-plugin-suitescript") },
|
|
33929
|
-
{ prefix: "svelte", load: () => loadPlugin("eslint-plugin-svelte") },
|
|
33930
|
-
{ prefix: "tailwindcss", load: () => loadPlugin("eslint-plugin-tailwindcss") },
|
|
33931
|
-
{ prefix: "test-selectors", load: () => loadPlugin("eslint-plugin-test-selectors") },
|
|
33932
|
-
{ prefix: "testing-library", load: () => loadPlugin("eslint-plugin-testing-library") },
|
|
33933
|
-
{
|
|
33934
|
-
|
|
33935
|
-
|
|
33936
|
-
|
|
33937
|
-
{ prefix: "
|
|
33938
|
-
{ prefix: "
|
|
33939
|
-
{ prefix: "
|
|
33940
|
-
{ prefix: "
|
|
33941
|
-
{
|
|
33942
|
-
|
|
33926
|
+
load: (root) => loadPlugin(root, "eslint-plugin-sort-destructure-keys")
|
|
33927
|
+
},
|
|
33928
|
+
{ prefix: "storybook", load: (root) => loadPlugin(root, "eslint-plugin-storybook") },
|
|
33929
|
+
{ prefix: "suitescript", load: (root) => loadPlugin(root, "eslint-plugin-suitescript") },
|
|
33930
|
+
{ prefix: "svelte", load: (root) => loadPlugin(root, "eslint-plugin-svelte") },
|
|
33931
|
+
{ prefix: "tailwindcss", load: (root) => loadPlugin(root, "eslint-plugin-tailwindcss") },
|
|
33932
|
+
{ prefix: "test-selectors", load: (root) => loadPlugin(root, "eslint-plugin-test-selectors") },
|
|
33933
|
+
{ prefix: "testing-library", load: (root) => loadPlugin(root, "eslint-plugin-testing-library") },
|
|
33934
|
+
{
|
|
33935
|
+
prefix: "typescript-sort-keys",
|
|
33936
|
+
load: (root) => loadPlugin(root, "eslint-plugin-typescript-sort-keys")
|
|
33937
|
+
},
|
|
33938
|
+
{ prefix: "unicorn", load: (root) => loadPlugin(root, "eslint-plugin-unicorn") },
|
|
33939
|
+
{ prefix: "unused-imports", load: (root) => loadPlugin(root, "eslint-plugin-unused-imports") },
|
|
33940
|
+
{ prefix: "vue", load: (root) => loadPlugin(root, "eslint-plugin-vue") },
|
|
33941
|
+
{ prefix: "vue-scoped-css", load: (root) => loadPlugin(root, "eslint-plugin-vue-scoped-css") },
|
|
33942
|
+
{
|
|
33943
|
+
prefix: "vuejs-accessibility",
|
|
33944
|
+
load: (root) => loadPlugin(root, "eslint-plugin-vuejs-accessibility")
|
|
33945
|
+
},
|
|
33946
|
+
{ prefix: "vuetify", load: (root) => loadPlugin(root, "eslint-plugin-vuetify") },
|
|
33947
|
+
{ prefix: "wdio", load: (root) => loadPlugin(root, "eslint-plugin-wdio") },
|
|
33948
|
+
{ prefix: "xss", load: (root) => loadPlugin(root, "eslint-plugin-xss") },
|
|
33949
|
+
{ prefix: "yml", load: (root) => loadPlugin(root, "eslint-plugin-yml") }
|
|
33943
33950
|
];
|
|
33944
33951
|
var PLUGIN_INDEX = new Map(KNOWN_PLUGINS.map((p) => [p.prefix, p]));
|
|
33945
|
-
async function loadRequiredPlugins(ruleIds) {
|
|
33952
|
+
async function loadRequiredPlugins(ruleIds, payloadRoot) {
|
|
33946
33953
|
const neededPrefixes = /* @__PURE__ */ new Set();
|
|
33947
33954
|
for (const id of ruleIds) {
|
|
33948
33955
|
const prefix = extractPluginPrefix(id);
|
|
@@ -33954,7 +33961,7 @@ async function loadRequiredPlugins(ruleIds) {
|
|
|
33954
33961
|
const loadPromises = [...neededPrefixes].map(async (prefix) => {
|
|
33955
33962
|
const def = PLUGIN_INDEX.get(prefix);
|
|
33956
33963
|
try {
|
|
33957
|
-
const plugin = await def.load();
|
|
33964
|
+
const plugin = await def.load(payloadRoot);
|
|
33958
33965
|
plugins.set(prefix, plugin);
|
|
33959
33966
|
} catch {
|
|
33960
33967
|
}
|
|
@@ -33974,6 +33981,157 @@ function extractPluginPrefix(ruleId) {
|
|
|
33974
33981
|
return ruleId.split("/")[0];
|
|
33975
33982
|
}
|
|
33976
33983
|
|
|
33984
|
+
// src/payload.ts
|
|
33985
|
+
var import_path2 = __toESM(require("path"));
|
|
33986
|
+
|
|
33987
|
+
// src/pattern-mappings.json
|
|
33988
|
+
var pattern_mappings_default = {
|
|
33989
|
+
react: {
|
|
33990
|
+
prefixes: [
|
|
33991
|
+
"ESLint9_react_",
|
|
33992
|
+
"ESLint9_react-hooks_",
|
|
33993
|
+
"ESLint9_react-perf_",
|
|
33994
|
+
"ESLint9_react-redux_",
|
|
33995
|
+
"ESLint9_jsx-a11y_",
|
|
33996
|
+
"ESLint9_@stylistic_jsx-",
|
|
33997
|
+
"ESLint9_sonarjs_jsx-no-leaked-render",
|
|
33998
|
+
"ESLint9_sonarjs_no-hook-setter-in-body",
|
|
33999
|
+
"ESLint9_sonarjs_no-useless-react-setstate",
|
|
34000
|
+
"ESLint9_sonarjs_prefer-read-only-props"
|
|
34001
|
+
]
|
|
34002
|
+
},
|
|
34003
|
+
vue: {
|
|
34004
|
+
prefixes: [
|
|
34005
|
+
"ESLint9_vue_",
|
|
34006
|
+
"ESLint9_vue-scoped-css_",
|
|
34007
|
+
"ESLint9_vuejs-accessibility_",
|
|
34008
|
+
"ESLint9_vuetify_",
|
|
34009
|
+
"ESLint9_jsonc_vue-custom-block",
|
|
34010
|
+
"ESLint9_yml_vue-custom-block"
|
|
34011
|
+
]
|
|
34012
|
+
},
|
|
34013
|
+
angular: {
|
|
34014
|
+
prefixes: ["ESLint9_@angular-eslint_"]
|
|
34015
|
+
},
|
|
34016
|
+
"angular-js": {
|
|
34017
|
+
prefixes: ["ESLint9_angular_"]
|
|
34018
|
+
},
|
|
34019
|
+
"lang:TypeScript": {
|
|
34020
|
+
prefixes: ["ESLint9_@typescript-eslint_"]
|
|
34021
|
+
},
|
|
34022
|
+
svelte: {
|
|
34023
|
+
prefixes: ["ESLint9_svelte_"]
|
|
34024
|
+
},
|
|
34025
|
+
lit: {
|
|
34026
|
+
prefixes: ["ESLint9_lit_"]
|
|
34027
|
+
},
|
|
34028
|
+
ember: {
|
|
34029
|
+
prefixes: ["ESLint9_ember_", "ESLint9_ember-suave_"]
|
|
34030
|
+
},
|
|
34031
|
+
nuxt: {
|
|
34032
|
+
prefixes: ["ESLint9_nuxt_"]
|
|
34033
|
+
},
|
|
34034
|
+
jest: {
|
|
34035
|
+
prefixes: [
|
|
34036
|
+
"ESLint9_jest_",
|
|
34037
|
+
"ESLint9_jest-dom_",
|
|
34038
|
+
"ESLint9_jest-extended_",
|
|
34039
|
+
"ESLint9_jest-formatting_"
|
|
34040
|
+
]
|
|
34041
|
+
},
|
|
34042
|
+
vitest: {
|
|
34043
|
+
prefixes: ["ESLint9_@vitest_"]
|
|
34044
|
+
},
|
|
34045
|
+
cypress: {
|
|
34046
|
+
prefixes: ["ESLint9_cypress_"]
|
|
34047
|
+
},
|
|
34048
|
+
mocha: {
|
|
34049
|
+
prefixes: ["ESLint9_mocha_"]
|
|
34050
|
+
},
|
|
34051
|
+
playwright: {
|
|
34052
|
+
prefixes: ["ESLint9_playwright_"]
|
|
34053
|
+
},
|
|
34054
|
+
ava: {
|
|
34055
|
+
prefixes: ["ESLint9_ava_"]
|
|
34056
|
+
},
|
|
34057
|
+
jasmine: {
|
|
34058
|
+
prefixes: ["ESLint9_jasmine_"]
|
|
34059
|
+
},
|
|
34060
|
+
"testing-library": {
|
|
34061
|
+
prefixes: ["ESLint9_testing-library_"]
|
|
34062
|
+
},
|
|
34063
|
+
storybook: {
|
|
34064
|
+
prefixes: ["ESLint9_storybook_"]
|
|
34065
|
+
},
|
|
34066
|
+
"tailwind-css": {
|
|
34067
|
+
prefixes: ["ESLint9_tailwindcss_"]
|
|
34068
|
+
},
|
|
34069
|
+
lodash: {
|
|
34070
|
+
prefixes: ["ESLint9_lodash_", "ESLint9_lodash-fp_"]
|
|
34071
|
+
},
|
|
34072
|
+
redux: {
|
|
34073
|
+
prefixes: ["ESLint9_redux-saga_"]
|
|
34074
|
+
},
|
|
34075
|
+
i18next: {
|
|
34076
|
+
prefixes: ["ESLint9_i18next_"]
|
|
34077
|
+
},
|
|
34078
|
+
backbone: {
|
|
34079
|
+
prefixes: ["ESLint9_backbone_"]
|
|
34080
|
+
},
|
|
34081
|
+
tanstack: {
|
|
34082
|
+
prefixes: ["ESLint9_@tanstack_"]
|
|
34083
|
+
},
|
|
34084
|
+
shopify: {
|
|
34085
|
+
prefixes: ["ESLint9_@shopify_"]
|
|
34086
|
+
},
|
|
34087
|
+
"lightning-web-components": {
|
|
34088
|
+
prefixes: ["ESLint9_@lwc_"]
|
|
34089
|
+
},
|
|
34090
|
+
salesforce: {
|
|
34091
|
+
prefixes: ["ESLint9_@salesforce_"]
|
|
34092
|
+
},
|
|
34093
|
+
meteor: {
|
|
34094
|
+
prefixes: ["ESLint9_meteor_"]
|
|
34095
|
+
},
|
|
34096
|
+
suitescript: {
|
|
34097
|
+
prefixes: ["ESLint9_suitescript_"]
|
|
34098
|
+
},
|
|
34099
|
+
"eslint-plugin": {
|
|
34100
|
+
prefixes: ["ESLint9_eslint-plugin_"]
|
|
34101
|
+
}
|
|
34102
|
+
};
|
|
34103
|
+
|
|
34104
|
+
// src/metadata.ts
|
|
34105
|
+
var descriptor = {
|
|
34106
|
+
id: "ESLint9",
|
|
34107
|
+
shortName: "eslint-9",
|
|
34108
|
+
displayName: "ESLint 9",
|
|
34109
|
+
preferredVersion: "9.39.5",
|
|
34110
|
+
languages: ["Javascript", "TypeScript"],
|
|
34111
|
+
// ESLint and Biome are alternative JS/TS linters — auto-init keeps only one.
|
|
34112
|
+
// ESLint 9 is the default pick when no local config file decides it.
|
|
34113
|
+
alternativeGroup: "ecmascript-lint",
|
|
34114
|
+
alternativeGroupDefault: true,
|
|
34115
|
+
filePatterns: ["**/*.js", "**/*.jsx", "**/*.mjs", "**/*.cjs", "**/*.ts", "**/*.tsx"],
|
|
34116
|
+
supportedOS: ["linux", "darwin", "win32"],
|
|
34117
|
+
supportedArch: ["x64", "arm64"],
|
|
34118
|
+
supportedRunners: ["local", "container"],
|
|
34119
|
+
frameworkMappings: pattern_mappings_default
|
|
34120
|
+
};
|
|
34121
|
+
|
|
34122
|
+
// src/payload.ts
|
|
34123
|
+
var PACKAGE_ROOT = import_path2.default.resolve(__dirname, "..");
|
|
34124
|
+
var PAYLOAD = {
|
|
34125
|
+
adapterId: descriptor.id,
|
|
34126
|
+
displayName: descriptor.displayName,
|
|
34127
|
+
version: descriptor.preferredVersion,
|
|
34128
|
+
manifestDir: import_path2.default.join(PACKAGE_ROOT, "payload"),
|
|
34129
|
+
probe: "eslint",
|
|
34130
|
+
adjacentFrom: PACKAGE_ROOT,
|
|
34131
|
+
// A v8 tree must never be handed to the v9 adapter.
|
|
34132
|
+
isCompatible: (version) => version.startsWith("9.")
|
|
34133
|
+
};
|
|
34134
|
+
|
|
33977
34135
|
// src/config-builder.ts
|
|
33978
34136
|
var TSCONFIG_CANDIDATES = [
|
|
33979
34137
|
"tsconfig.json",
|
|
@@ -33984,7 +34142,7 @@ var TSCONFIG_CANDIDATES = [
|
|
|
33984
34142
|
function hasTypeScriptProjectConfig(repositoryRoot) {
|
|
33985
34143
|
for (const name of TSCONFIG_CANDIDATES) {
|
|
33986
34144
|
try {
|
|
33987
|
-
import_fs2.default.accessSync(
|
|
34145
|
+
import_fs2.default.accessSync(import_path3.default.join(repositoryRoot, name));
|
|
33988
34146
|
return true;
|
|
33989
34147
|
} catch {
|
|
33990
34148
|
}
|
|
@@ -34035,7 +34193,10 @@ function decodePatternId(patternId) {
|
|
|
34035
34193
|
function encodePatternId(ruleId) {
|
|
34036
34194
|
return `${PREFIX}${ruleId.replace(/_/g, "__").replace(/\//g, "_")}`;
|
|
34037
34195
|
}
|
|
34038
|
-
async function buildESLintConfig(patterns, ctx = {
|
|
34196
|
+
async function buildESLintConfig(patterns, ctx = {
|
|
34197
|
+
repositoryRoot: process.cwd(),
|
|
34198
|
+
payloadRoot: PACKAGE_ROOT
|
|
34199
|
+
}) {
|
|
34039
34200
|
const ruleEntries = [];
|
|
34040
34201
|
for (const p of patterns) {
|
|
34041
34202
|
const ruleId = decodePatternId(p.patternId);
|
|
@@ -34043,7 +34204,7 @@ async function buildESLintConfig(patterns, ctx = { repositoryRoot: process.cwd()
|
|
|
34043
34204
|
ruleEntries.push({ ruleId, pattern: p });
|
|
34044
34205
|
}
|
|
34045
34206
|
const allRuleIds = ruleEntries.map((e) => e.ruleId);
|
|
34046
|
-
const plugins = await loadRequiredPlugins(allRuleIds);
|
|
34207
|
+
const plugins = await loadRequiredPlugins(allRuleIds, ctx.payloadRoot);
|
|
34047
34208
|
const coreRules = {};
|
|
34048
34209
|
const pluginRuleGroups = /* @__PURE__ */ new Map();
|
|
34049
34210
|
for (const { ruleId, pattern } of ruleEntries) {
|
|
@@ -34078,7 +34239,7 @@ async function buildESLintConfig(patterns, ctx = { repositoryRoot: process.cwd()
|
|
|
34078
34239
|
const tsRules = pluginRuleGroups.get("@typescript-eslint");
|
|
34079
34240
|
if (tsRules && tsPlugin) {
|
|
34080
34241
|
const tsLanguageOptions = {
|
|
34081
|
-
parser: await loadTsParser()
|
|
34242
|
+
parser: await loadTsParser(ctx.payloadRoot)
|
|
34082
34243
|
};
|
|
34083
34244
|
if (hasTypeScriptProjectConfig(ctx.repositoryRoot)) {
|
|
34084
34245
|
tsLanguageOptions.parserOptions = { projectService: true };
|
|
@@ -34193,8 +34354,8 @@ function parseParamValue(value) {
|
|
|
34193
34354
|
}
|
|
34194
34355
|
return value;
|
|
34195
34356
|
}
|
|
34196
|
-
async function loadTsParser() {
|
|
34197
|
-
const mod = await
|
|
34357
|
+
async function loadTsParser(payloadRoot) {
|
|
34358
|
+
const mod = await (0, import_tooling2.importFromRoot)(payloadRoot, "typescript-eslint", { raw: true });
|
|
34198
34359
|
return mod.default?.parser ?? mod.parser;
|
|
34199
34360
|
}
|
|
34200
34361
|
function pluginExposesRule(plugin, prefix, fullRuleId) {
|
|
@@ -34207,141 +34368,6 @@ function pluginExposesRule(plugin, prefix, fullRuleId) {
|
|
|
34207
34368
|
return Object.prototype.hasOwnProperty.call(rules, shortName);
|
|
34208
34369
|
}
|
|
34209
34370
|
|
|
34210
|
-
// src/pattern-mappings.json
|
|
34211
|
-
var pattern_mappings_default = {
|
|
34212
|
-
react: {
|
|
34213
|
-
prefixes: [
|
|
34214
|
-
"ESLint9_react_",
|
|
34215
|
-
"ESLint9_react-hooks_",
|
|
34216
|
-
"ESLint9_react-perf_",
|
|
34217
|
-
"ESLint9_react-redux_",
|
|
34218
|
-
"ESLint9_jsx-a11y_",
|
|
34219
|
-
"ESLint9_@stylistic_jsx-",
|
|
34220
|
-
"ESLint9_sonarjs_jsx-no-leaked-render",
|
|
34221
|
-
"ESLint9_sonarjs_no-hook-setter-in-body",
|
|
34222
|
-
"ESLint9_sonarjs_no-useless-react-setstate",
|
|
34223
|
-
"ESLint9_sonarjs_prefer-read-only-props"
|
|
34224
|
-
]
|
|
34225
|
-
},
|
|
34226
|
-
vue: {
|
|
34227
|
-
prefixes: [
|
|
34228
|
-
"ESLint9_vue_",
|
|
34229
|
-
"ESLint9_vue-scoped-css_",
|
|
34230
|
-
"ESLint9_vuejs-accessibility_",
|
|
34231
|
-
"ESLint9_vuetify_",
|
|
34232
|
-
"ESLint9_jsonc_vue-custom-block",
|
|
34233
|
-
"ESLint9_yml_vue-custom-block"
|
|
34234
|
-
]
|
|
34235
|
-
},
|
|
34236
|
-
angular: {
|
|
34237
|
-
prefixes: ["ESLint9_@angular-eslint_"]
|
|
34238
|
-
},
|
|
34239
|
-
"angular-js": {
|
|
34240
|
-
prefixes: ["ESLint9_angular_"]
|
|
34241
|
-
},
|
|
34242
|
-
"lang:TypeScript": {
|
|
34243
|
-
prefixes: ["ESLint9_@typescript-eslint_"]
|
|
34244
|
-
},
|
|
34245
|
-
svelte: {
|
|
34246
|
-
prefixes: ["ESLint9_svelte_"]
|
|
34247
|
-
},
|
|
34248
|
-
lit: {
|
|
34249
|
-
prefixes: ["ESLint9_lit_"]
|
|
34250
|
-
},
|
|
34251
|
-
ember: {
|
|
34252
|
-
prefixes: ["ESLint9_ember_", "ESLint9_ember-suave_"]
|
|
34253
|
-
},
|
|
34254
|
-
nuxt: {
|
|
34255
|
-
prefixes: ["ESLint9_nuxt_"]
|
|
34256
|
-
},
|
|
34257
|
-
jest: {
|
|
34258
|
-
prefixes: [
|
|
34259
|
-
"ESLint9_jest_",
|
|
34260
|
-
"ESLint9_jest-dom_",
|
|
34261
|
-
"ESLint9_jest-extended_",
|
|
34262
|
-
"ESLint9_jest-formatting_"
|
|
34263
|
-
]
|
|
34264
|
-
},
|
|
34265
|
-
vitest: {
|
|
34266
|
-
prefixes: ["ESLint9_@vitest_"]
|
|
34267
|
-
},
|
|
34268
|
-
cypress: {
|
|
34269
|
-
prefixes: ["ESLint9_cypress_"]
|
|
34270
|
-
},
|
|
34271
|
-
mocha: {
|
|
34272
|
-
prefixes: ["ESLint9_mocha_"]
|
|
34273
|
-
},
|
|
34274
|
-
playwright: {
|
|
34275
|
-
prefixes: ["ESLint9_playwright_"]
|
|
34276
|
-
},
|
|
34277
|
-
ava: {
|
|
34278
|
-
prefixes: ["ESLint9_ava_"]
|
|
34279
|
-
},
|
|
34280
|
-
jasmine: {
|
|
34281
|
-
prefixes: ["ESLint9_jasmine_"]
|
|
34282
|
-
},
|
|
34283
|
-
"testing-library": {
|
|
34284
|
-
prefixes: ["ESLint9_testing-library_"]
|
|
34285
|
-
},
|
|
34286
|
-
storybook: {
|
|
34287
|
-
prefixes: ["ESLint9_storybook_"]
|
|
34288
|
-
},
|
|
34289
|
-
"tailwind-css": {
|
|
34290
|
-
prefixes: ["ESLint9_tailwindcss_"]
|
|
34291
|
-
},
|
|
34292
|
-
lodash: {
|
|
34293
|
-
prefixes: ["ESLint9_lodash_", "ESLint9_lodash-fp_"]
|
|
34294
|
-
},
|
|
34295
|
-
redux: {
|
|
34296
|
-
prefixes: ["ESLint9_redux-saga_"]
|
|
34297
|
-
},
|
|
34298
|
-
i18next: {
|
|
34299
|
-
prefixes: ["ESLint9_i18next_"]
|
|
34300
|
-
},
|
|
34301
|
-
backbone: {
|
|
34302
|
-
prefixes: ["ESLint9_backbone_"]
|
|
34303
|
-
},
|
|
34304
|
-
tanstack: {
|
|
34305
|
-
prefixes: ["ESLint9_@tanstack_"]
|
|
34306
|
-
},
|
|
34307
|
-
shopify: {
|
|
34308
|
-
prefixes: ["ESLint9_@shopify_"]
|
|
34309
|
-
},
|
|
34310
|
-
"lightning-web-components": {
|
|
34311
|
-
prefixes: ["ESLint9_@lwc_"]
|
|
34312
|
-
},
|
|
34313
|
-
salesforce: {
|
|
34314
|
-
prefixes: ["ESLint9_@salesforce_"]
|
|
34315
|
-
},
|
|
34316
|
-
meteor: {
|
|
34317
|
-
prefixes: ["ESLint9_meteor_"]
|
|
34318
|
-
},
|
|
34319
|
-
suitescript: {
|
|
34320
|
-
prefixes: ["ESLint9_suitescript_"]
|
|
34321
|
-
},
|
|
34322
|
-
"eslint-plugin": {
|
|
34323
|
-
prefixes: ["ESLint9_eslint-plugin_"]
|
|
34324
|
-
}
|
|
34325
|
-
};
|
|
34326
|
-
|
|
34327
|
-
// src/metadata.ts
|
|
34328
|
-
var descriptor = {
|
|
34329
|
-
id: "ESLint9",
|
|
34330
|
-
shortName: "eslint-9",
|
|
34331
|
-
displayName: "ESLint 9",
|
|
34332
|
-
preferredVersion: "9.39.5",
|
|
34333
|
-
languages: ["Javascript", "TypeScript"],
|
|
34334
|
-
// ESLint and Biome are alternative JS/TS linters — auto-init keeps only one.
|
|
34335
|
-
// ESLint 9 is the default pick when no local config file decides it.
|
|
34336
|
-
alternativeGroup: "ecmascript-lint",
|
|
34337
|
-
alternativeGroupDefault: true,
|
|
34338
|
-
filePatterns: ["**/*.js", "**/*.jsx", "**/*.mjs", "**/*.cjs", "**/*.ts", "**/*.tsx"],
|
|
34339
|
-
supportedOS: ["linux", "darwin", "win32"],
|
|
34340
|
-
supportedArch: ["x64", "arm64"],
|
|
34341
|
-
supportedRunners: ["local", "container"],
|
|
34342
|
-
frameworkMappings: pattern_mappings_default
|
|
34343
|
-
};
|
|
34344
|
-
|
|
34345
34371
|
// src/adapter.ts
|
|
34346
34372
|
var yieldToEventLoop = () => (0, import_promises.setTimeout)(0);
|
|
34347
34373
|
var TOOL_ID2 = "ESLint9";
|
|
@@ -34349,12 +34375,12 @@ var ESLINT_MAX_FILE_SIZE_BYTES = 512 * 1024;
|
|
|
34349
34375
|
var LINT_BATCH_SIZE = 50;
|
|
34350
34376
|
var ESLINT_SKIP_DIRS = /* @__PURE__ */ new Set([".yarn", "vendor", ".next", ".nuxt"]);
|
|
34351
34377
|
function shouldSkipFile(filePath, repositoryRoot) {
|
|
34352
|
-
const relPath =
|
|
34378
|
+
const relPath = import_path4.default.relative(repositoryRoot, filePath).replace(/\\/g, "/");
|
|
34353
34379
|
const segments = relPath.split("/");
|
|
34354
34380
|
for (const seg of segments) {
|
|
34355
34381
|
if (ESLINT_SKIP_DIRS.has(seg)) return `path contains skip directory "${seg}"`;
|
|
34356
34382
|
}
|
|
34357
|
-
if (/\.min\.[cm]?[jt]sx?$/.test(
|
|
34383
|
+
if (/\.min\.[cm]?[jt]sx?$/.test(import_path4.default.basename(filePath))) return "minified file";
|
|
34358
34384
|
try {
|
|
34359
34385
|
const stat = import_fs3.default.statSync(filePath);
|
|
34360
34386
|
if (stat.size > ESLINT_MAX_FILE_SIZE_BYTES) {
|
|
@@ -34399,7 +34425,7 @@ var PROBE_SNIPPETS = [
|
|
|
34399
34425
|
async function probeConfig(eslint, repositoryRoot) {
|
|
34400
34426
|
for (const { filePath, source } of PROBE_SNIPPETS) {
|
|
34401
34427
|
try {
|
|
34402
|
-
await eslint.lintText(source, { filePath:
|
|
34428
|
+
await eslint.lintText(source, { filePath: import_path4.default.join(repositoryRoot, filePath) });
|
|
34403
34429
|
} catch (err) {
|
|
34404
34430
|
return err instanceof Error ? err : new Error(String(err));
|
|
34405
34431
|
}
|
|
@@ -34462,7 +34488,7 @@ function removeRulesByPluginFromFlatConfig(config, pluginPrefix) {
|
|
|
34462
34488
|
}
|
|
34463
34489
|
async function resolveProjectESLint(repositoryRoot) {
|
|
34464
34490
|
try {
|
|
34465
|
-
const projectRequire = (0, import_module.createRequire)(
|
|
34491
|
+
const projectRequire = (0, import_module.createRequire)(import_path4.default.join(repositoryRoot, "__placeholder__.js"));
|
|
34466
34492
|
const mod = projectRequire("eslint");
|
|
34467
34493
|
const version = mod.ESLint?.version ?? "";
|
|
34468
34494
|
const major = parseInt(version.split(".")[0], 10);
|
|
@@ -34472,6 +34498,12 @@ async function resolveProjectESLint(repositoryRoot) {
|
|
|
34472
34498
|
return void 0;
|
|
34473
34499
|
}
|
|
34474
34500
|
}
|
|
34501
|
+
async function resolveLocalProjectESLint(repositoryRoot) {
|
|
34502
|
+
const hasFlatConfig = LOCAL_CONFIG_FILES.some(
|
|
34503
|
+
(name) => import_fs3.default.existsSync(import_path4.default.join(repositoryRoot, name))
|
|
34504
|
+
);
|
|
34505
|
+
return hasFlatConfig ? resolveProjectESLint(repositoryRoot) : void 0;
|
|
34506
|
+
}
|
|
34475
34507
|
var consoleCaptureStorage = new import_async_hooks.AsyncLocalStorage();
|
|
34476
34508
|
var consoleGlobalsPatched = false;
|
|
34477
34509
|
function patchConsoleGlobals() {
|
|
@@ -34523,14 +34555,49 @@ var adapter = {
|
|
|
34523
34555
|
website: "https://eslint.org",
|
|
34524
34556
|
prerequisites: [],
|
|
34525
34557
|
/**
|
|
34526
|
-
*
|
|
34558
|
+
* Resolves the ESLint 9 payload (rejecting any non-9.x tree), verifies it is
|
|
34559
|
+
* loadable, and returns its version and where it was found — or, when it is
|
|
34560
|
+
* not installed anywhere, the roots searched and how to install it.
|
|
34561
|
+
*
|
|
34562
|
+
* Without a payload, a repository that has a flat config and its own ESLint 9
|
|
34563
|
+
* is still reported available, as `"global"` (the user's install, never
|
|
34564
|
+
* modified). Local-config mode runs on that ESLint anyway. This check cannot
|
|
34565
|
+
* see the Codacy config, so in Codacy-patterns mode such a repository gets an
|
|
34566
|
+
* actionable "install the payload" error from `analyze()` instead of a skip.
|
|
34527
34567
|
*/
|
|
34528
34568
|
async checkAvailability(ctx) {
|
|
34529
34569
|
ctx.logger.debug("Checking availability", { toolId: TOOL_ID2 });
|
|
34570
|
+
const payload = (0, import_tooling3.resolvePayload)(ctx, PAYLOAD);
|
|
34571
|
+
if (!payload.found) {
|
|
34572
|
+
const project = await resolveLocalProjectESLint(ctx.repositoryRoot);
|
|
34573
|
+
if (project) {
|
|
34574
|
+
ctx.logger.debug("ESLint payload not installed; using the project's ESLint", {
|
|
34575
|
+
toolId: TOOL_ID2,
|
|
34576
|
+
version: project.version
|
|
34577
|
+
});
|
|
34578
|
+
return {
|
|
34579
|
+
available: true,
|
|
34580
|
+
version: project.version,
|
|
34581
|
+
path: ctx.repositoryRoot,
|
|
34582
|
+
installation: "global"
|
|
34583
|
+
};
|
|
34584
|
+
}
|
|
34585
|
+
ctx.logger.debug("ESLint not available", { toolId: TOOL_ID2, reason: payload.reason });
|
|
34586
|
+
return (0, import_tooling3.payloadUnavailable)(payload, PAYLOAD);
|
|
34587
|
+
}
|
|
34530
34588
|
try {
|
|
34531
|
-
const { ESLint } = await
|
|
34589
|
+
const { ESLint } = await (0, import_tooling3.importFromRoot)(
|
|
34590
|
+
payload.root,
|
|
34591
|
+
"eslint",
|
|
34592
|
+
{ raw: true }
|
|
34593
|
+
);
|
|
34532
34594
|
ctx.logger.debug("ESLint available", { toolId: TOOL_ID2, version: ESLint.version });
|
|
34533
|
-
return {
|
|
34595
|
+
return {
|
|
34596
|
+
available: true,
|
|
34597
|
+
version: ESLint.version,
|
|
34598
|
+
path: payload.root,
|
|
34599
|
+
installation: payload.source
|
|
34600
|
+
};
|
|
34534
34601
|
} catch (err) {
|
|
34535
34602
|
const reason = `eslint package not loadable: ${err instanceof Error ? err.message : String(err)}`;
|
|
34536
34603
|
ctx.logger.debug("ESLint not available", { toolId: TOOL_ID2, reason });
|
|
@@ -34541,14 +34608,13 @@ var adapter = {
|
|
|
34541
34608
|
}
|
|
34542
34609
|
},
|
|
34543
34610
|
/**
|
|
34544
|
-
*
|
|
34611
|
+
* Installs the pinned ESLint 9 payload — ESLint, its plugins and parsers,
|
|
34612
|
+
* together in one tree — into the Codacy-managed directory with `npm ci`
|
|
34613
|
+
* against the committed lockfile. Refuses in container mode.
|
|
34545
34614
|
*/
|
|
34546
34615
|
async install(ctx) {
|
|
34547
34616
|
ctx.logger.info("Starting install", { toolId: TOOL_ID2 });
|
|
34548
|
-
|
|
34549
|
-
toolId: TOOL_ID2
|
|
34550
|
-
});
|
|
34551
|
-
return { success: true, installedVersion: adapter.preferredVersion };
|
|
34617
|
+
return (0, import_tooling3.installNpmPayload)(ctx, PAYLOAD);
|
|
34552
34618
|
},
|
|
34553
34619
|
/**
|
|
34554
34620
|
* Looks for ESLint flat config files in the repository root.
|
|
@@ -34556,7 +34622,7 @@ var adapter = {
|
|
|
34556
34622
|
async checkLocalConfigurationFile(ctx) {
|
|
34557
34623
|
ctx.logger.debug("Checking for local config", { toolId: TOOL_ID2 });
|
|
34558
34624
|
for (const name of LOCAL_CONFIG_FILES) {
|
|
34559
|
-
const candidate =
|
|
34625
|
+
const candidate = import_path4.default.join(ctx.repositoryRoot, name);
|
|
34560
34626
|
try {
|
|
34561
34627
|
import_fs3.default.accessSync(candidate);
|
|
34562
34628
|
ctx.logger.debug("Local config found", { toolId: TOOL_ID2, path: candidate });
|
|
@@ -34580,12 +34646,12 @@ var adapter = {
|
|
|
34580
34646
|
const startedAt = /* @__PURE__ */ new Date();
|
|
34581
34647
|
const issues = [];
|
|
34582
34648
|
const errors = [];
|
|
34583
|
-
const allAbsoluteFiles = ctx.targetFiles.map((f) =>
|
|
34649
|
+
const allAbsoluteFiles = ctx.targetFiles.map((f) => import_path4.default.resolve(ctx.repositoryRoot, f));
|
|
34584
34650
|
const absoluteFiles = [];
|
|
34585
34651
|
for (const f of allAbsoluteFiles) {
|
|
34586
34652
|
const skipReason = shouldSkipFile(f, ctx.repositoryRoot);
|
|
34587
34653
|
if (skipReason) {
|
|
34588
|
-
const relPath =
|
|
34654
|
+
const relPath = import_path4.default.relative(ctx.repositoryRoot, f);
|
|
34589
34655
|
ctx.logger.debug("Skipping file", { toolId: TOOL_ID2, file: relPath, reason: skipReason });
|
|
34590
34656
|
} else {
|
|
34591
34657
|
absoluteFiles.push(f);
|
|
@@ -34601,43 +34667,59 @@ var adapter = {
|
|
|
34601
34667
|
}
|
|
34602
34668
|
if (absoluteFiles.length === 0) {
|
|
34603
34669
|
const completedAt2 = /* @__PURE__ */ new Date();
|
|
34604
|
-
return (0,
|
|
34670
|
+
return (0, import_tooling3.buildResult)(TOOL_ID2, startedAt, completedAt2, issues, errors, ctx.targetFiles.length);
|
|
34605
34671
|
}
|
|
34606
34672
|
let ESLintClass;
|
|
34607
|
-
try {
|
|
34608
|
-
const mod = await import("eslint");
|
|
34609
|
-
ESLintClass = mod.ESLint;
|
|
34610
|
-
} catch (err) {
|
|
34611
|
-
const completedAt2 = /* @__PURE__ */ new Date();
|
|
34612
|
-
errors.push({
|
|
34613
|
-
toolId: TOOL_ID2,
|
|
34614
|
-
phase: "toolInvoke",
|
|
34615
|
-
kind: "InvocationError",
|
|
34616
|
-
message: `Failed to load eslint: ${err instanceof Error ? err.message : String(err)}`,
|
|
34617
|
-
level: "error"
|
|
34618
|
-
});
|
|
34619
|
-
return (0, import_tooling.buildResult)(TOOL_ID2, startedAt, completedAt2, issues, errors, ctx.targetFiles.length);
|
|
34620
|
-
}
|
|
34621
|
-
const eslintOptions = { cwd: ctx.repositoryRoot };
|
|
34622
34673
|
const usingLocalConfig = Boolean(
|
|
34623
34674
|
codacyConfig.useLocalConfigurationFile && codacyConfig.localConfigurationFile
|
|
34624
34675
|
);
|
|
34625
|
-
|
|
34626
|
-
|
|
34627
|
-
|
|
34628
|
-
|
|
34629
|
-
|
|
34676
|
+
const projectESLint = usingLocalConfig ? await resolveProjectESLint(ctx.repositoryRoot) : void 0;
|
|
34677
|
+
let payloadRoot = "";
|
|
34678
|
+
if (projectESLint) {
|
|
34679
|
+
ESLintClass = projectESLint.ESLintClass;
|
|
34680
|
+
ctx.logger.info("Using project ESLint", {
|
|
34681
|
+
toolId: TOOL_ID2,
|
|
34682
|
+
version: projectESLint.version
|
|
34683
|
+
});
|
|
34684
|
+
} else {
|
|
34685
|
+
const payload = (0, import_tooling3.resolvePayload)(ctx, PAYLOAD);
|
|
34686
|
+
if (!payload.found) {
|
|
34687
|
+
errors.push({
|
|
34630
34688
|
toolId: TOOL_ID2,
|
|
34631
|
-
|
|
34689
|
+
phase: "toolInvoke",
|
|
34690
|
+
kind: "InvocationError",
|
|
34691
|
+
message: `Failed to load eslint: ${payload.reason}. Install it with: codacy-analysis install --tool ${TOOL_ID2}`,
|
|
34692
|
+
level: "error"
|
|
34632
34693
|
});
|
|
34633
|
-
|
|
34634
|
-
|
|
34694
|
+
return (0, import_tooling3.buildResult)(TOOL_ID2, startedAt, /* @__PURE__ */ new Date(), issues, errors, ctx.targetFiles.length);
|
|
34695
|
+
}
|
|
34696
|
+
try {
|
|
34697
|
+
payloadRoot = payload.root;
|
|
34698
|
+
const mod = await (0, import_tooling3.importFromRoot)(payloadRoot, "eslint", {
|
|
34699
|
+
raw: true
|
|
34700
|
+
});
|
|
34701
|
+
ESLintClass = mod.ESLint;
|
|
34702
|
+
} catch (err) {
|
|
34703
|
+
const completedAt2 = /* @__PURE__ */ new Date();
|
|
34704
|
+
errors.push({
|
|
34705
|
+
toolId: TOOL_ID2,
|
|
34706
|
+
phase: "toolInvoke",
|
|
34707
|
+
kind: "InvocationError",
|
|
34708
|
+
message: `Failed to load eslint: ${err instanceof Error ? err.message : String(err)}`,
|
|
34709
|
+
level: "error"
|
|
34710
|
+
});
|
|
34711
|
+
return (0, import_tooling3.buildResult)(TOOL_ID2, startedAt, completedAt2, issues, errors, ctx.targetFiles.length);
|
|
34635
34712
|
}
|
|
34713
|
+
}
|
|
34714
|
+
const eslintOptions = { cwd: ctx.repositoryRoot };
|
|
34715
|
+
if (usingLocalConfig) {
|
|
34716
|
+
if (!projectESLint) eslintOptions.overrideConfigFile = codacyConfig.localConfigurationFile;
|
|
34636
34717
|
} else if (codacyConfig.patterns.length > 0) {
|
|
34637
34718
|
const buildStartMs = Date.now();
|
|
34638
34719
|
try {
|
|
34639
34720
|
const config = await buildESLintConfig(codacyConfig.patterns, {
|
|
34640
|
-
repositoryRoot: ctx.repositoryRoot
|
|
34721
|
+
repositoryRoot: ctx.repositoryRoot,
|
|
34722
|
+
payloadRoot
|
|
34641
34723
|
});
|
|
34642
34724
|
eslintOptions.overrideConfig = config;
|
|
34643
34725
|
eslintOptions.overrideConfigFile = true;
|
|
@@ -34655,13 +34737,13 @@ var adapter = {
|
|
|
34655
34737
|
message: `Failed to build ESLint config: ${err instanceof Error ? err.message : String(err)}`,
|
|
34656
34738
|
level: "error"
|
|
34657
34739
|
});
|
|
34658
|
-
return (0,
|
|
34740
|
+
return (0, import_tooling3.buildResult)(TOOL_ID2, startedAt, /* @__PURE__ */ new Date(), issues, errors, ctx.targetFiles.length);
|
|
34659
34741
|
}
|
|
34660
34742
|
} else {
|
|
34661
34743
|
ctx.logger.info("Skipping analysis: no local config and no patterns enabled", {
|
|
34662
34744
|
toolId: TOOL_ID2
|
|
34663
34745
|
});
|
|
34664
|
-
return (0,
|
|
34746
|
+
return (0, import_tooling3.buildResult)(TOOL_ID2, startedAt, /* @__PURE__ */ new Date(), issues, errors, ctx.targetFiles.length);
|
|
34665
34747
|
}
|
|
34666
34748
|
const enabledPatterns = new Set(codacyConfig.patterns.map((p) => p.patternId));
|
|
34667
34749
|
const MAX_CONFIG_RETRIES = 30;
|
|
@@ -34812,7 +34894,7 @@ var adapter = {
|
|
|
34812
34894
|
ctx.onProgress?.(`Processing results from ${results.length} files`);
|
|
34813
34895
|
for (const fileResult of results) {
|
|
34814
34896
|
if (fileResult.messages.length === 0) continue;
|
|
34815
|
-
const relPath =
|
|
34897
|
+
const relPath = import_path4.default.relative(ctx.repositoryRoot, fileResult.filePath);
|
|
34816
34898
|
let lines;
|
|
34817
34899
|
for (const msg of fileResult.messages) {
|
|
34818
34900
|
if (!msg.ruleId) continue;
|
|
@@ -34827,7 +34909,7 @@ var adapter = {
|
|
|
34827
34909
|
suggestion = msg.suggestions[0].desc;
|
|
34828
34910
|
}
|
|
34829
34911
|
if (lines === void 0) {
|
|
34830
|
-
lines = await (0,
|
|
34912
|
+
lines = await (0, import_tooling3.readFileLines)(fileResult.filePath);
|
|
34831
34913
|
}
|
|
34832
34914
|
issues.push({
|
|
34833
34915
|
filePath: relPath,
|
|
@@ -34838,7 +34920,7 @@ var adapter = {
|
|
|
34838
34920
|
endLine: msg.endLine,
|
|
34839
34921
|
endColumn: msg.endColumn,
|
|
34840
34922
|
message: msg.message,
|
|
34841
|
-
lineContent: (0,
|
|
34923
|
+
lineContent: (0, import_tooling3.getLineContent)(lines, msg.line),
|
|
34842
34924
|
category: meta.category,
|
|
34843
34925
|
severity: meta.severity,
|
|
34844
34926
|
suggestion
|
|
@@ -34873,9 +34955,9 @@ var adapter = {
|
|
|
34873
34955
|
errorCount: errors.length,
|
|
34874
34956
|
durationMs
|
|
34875
34957
|
});
|
|
34876
|
-
return (0,
|
|
34958
|
+
return (0, import_tooling3.buildResult)(TOOL_ID2, startedAt, completedAt, issues, errors, ctx.targetFiles.length);
|
|
34877
34959
|
}
|
|
34878
34960
|
};
|
|
34879
34961
|
|
|
34880
34962
|
// src/index.ts
|
|
34881
|
-
var index_default = (0,
|
|
34963
|
+
var index_default = (0, import_tooling4.defineToolAdapter)(adapter);
|