@anolilab/lint-staged-config 1.1.2 → 2.0.1

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/CHANGELOG.md CHANGED
@@ -1,3 +1,31 @@
1
+ ## @anolilab/lint-staged-config [2.0.1](https://github.com/anolilab/javascript-style-guide/compare/@anolilab/lint-staged-config@2.0.0...@anolilab/lint-staged-config@2.0.1) (2023-07-19)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * Update logging instruction and tweak ESLint setting ([c61790a](https://github.com/anolilab/javascript-style-guide/commit/c61790afc2886685829ec10ed96fcbf9fc638641))
7
+
8
+ ## @anolilab/lint-staged-config [2.0.0](https://github.com/anolilab/javascript-style-guide/compare/@anolilab/lint-staged-config@1.1.2...@anolilab/lint-staged-config@2.0.0) (2023-07-18)
9
+
10
+
11
+ ### ⚠ BREAKING CHANGES
12
+
13
+ * fixing broken releases that semantic-release did create
14
+ Signed-off-by: prisis <d.bannert@anolilab.de>
15
+
16
+ ### Bug Fixes
17
+
18
+ * fixed broken releases ([d46de22](https://github.com/anolilab/javascript-style-guide/commit/d46de22a999cc09cc46f9a4d4e7682441705a861))
19
+ * Refactor code to use type annotations and Record utility type ([9021e22](https://github.com/anolilab/javascript-style-guide/commit/9021e221d0ad139e224d272f3238ddd136688028))
20
+ * update node version ([9a22309](https://github.com/anolilab/javascript-style-guide/commit/9a22309775cd2219320eed903ac3e22f66ffbe94))
21
+
22
+
23
+
24
+ ### Dependencies
25
+
26
+ * **@anolilab/package-json-utils:** upgraded to 3.0.1
27
+ * **@anolilab/semantic-release-preset:** upgraded to 6.0.1
28
+
1
29
  ## @anolilab/lint-staged-config [1.1.2](https://github.com/anolilab/javascript-style-guide/compare/@anolilab/lint-staged-config@1.1.1...@anolilab/lint-staged-config@1.1.2) (2023-07-06)
2
30
 
3
31
 
@@ -13,7 +41,6 @@
13
41
  * Revise optional chaining and promise handling in scripts ([4f1d996](https://github.com/anolilab/javascript-style-guide/commit/4f1d9965e862d72d3a50ef8652347d63ac5ef990))
14
42
 
15
43
 
16
-
17
44
  ### Dependencies
18
45
 
19
46
  * **@anolilab/package-json-utils:** upgraded to 2.0.1
@@ -0,0 +1,8 @@
1
+ import { a as a$1 } from './chunk-5L2ZI35J.mjs';
2
+ import { env } from 'process';
3
+
4
+ var e={[`**/*.{${["ts","mts","cts"].join(",")}}`]:n=>{let o=new Set;return n.forEach(s=>{try{let t=a$1("tsconfig.json",s);o.add(`tsc --noEmit --project ${t}`);}catch(t){env.DEBUG&&console.error(t);}}),[...o]}},a=e;
5
+
6
+ export { a };
7
+ //# sourceMappingURL=out.js.map
8
+ //# sourceMappingURL=chunk-475NPYYW.mjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/groups/typescript.ts"],"names":["env","group","filenames","commands","filePath","tsconfigPath","get_nearest_config_path_default","error","typescript_default"],"mappings":"yCACA,OAAS,OAAAA,MAAW,UAIpB,IAAMC,EAAgB,CAClB,CAAC,SAAS,CAAC,KAAM,MAAO,KAAK,EAAE,KAAK,GAAG,CAAC,GAAG,EAAIC,GAAwB,CACnE,IAAMC,EAAW,IAAI,IAErB,OAAAD,EAAU,QAASE,GAAa,CAC5B,GAAI,CAEA,IAAMC,EAAeC,EAAqB,gBAAiBF,CAAwB,EAEnFD,EAAS,IAAI,0BAA0BE,CAAY,EAAE,CACzD,OAASE,EAAP,CACMP,EAAI,OACJ,QAAQ,MAAMO,CAAK,CAE3B,CACJ,CAAC,EAEM,CAAC,GAAGJ,CAAQ,CACvB,CACJ,EAEOK,EAAQP","sourcesContent":["import type { Config } from \"lint-staged\";\nimport { env } from \"node:process\";\n\nimport getNearestConfigPath from \"../utils/get-nearest-config-path\";\n\nconst group: Config = {\n [`**/*.{${[\"ts\", \"mts\", \"cts\"].join(\",\")}}`]: (filenames: string[]) => {\n const commands = new Set<string>();\n\n filenames.forEach((filePath) => {\n try {\n // eslint-disable-next-line no-template-curly-in-string\n const tsconfigPath = getNearestConfigPath(\"tsconfig.json\", filePath as \"/${string}\");\n\n commands.add(`tsc --noEmit --project ${tsconfigPath}`);\n } catch (error: any) {\n if (env[\"DEBUG\"]) {\n console.error(error);\n }\n }\n });\n\n return [...commands];\n },\n};\n\nexport default group;\n"]}
1
+ {"version":3,"sources":["../src/groups/typescript.ts"],"names":["env","group","filenames","commands","filePath","tsconfigPath","get_nearest_config_path_default","error","typescript_default"],"mappings":"yCACA,OAAS,OAAAA,MAAW,UAIpB,IAAMC,EAAgB,CAClB,CAAC,SAAS,CAAC,KAAM,MAAO,KAAK,EAAE,KAAK,GAAG,CAAC,GAAG,EAAIC,GAAwB,CACnE,IAAMC,EAAW,IAAI,IAErB,OAAAD,EAAU,QAASE,GAAa,CAC5B,GAAI,CACA,IAAMC,EAAeC,EAAqB,gBAAiBF,CAAwB,EAEnFD,EAAS,IAAI,0BAA0BE,CAAY,EAAE,CACzD,OAASE,EAAP,CACMP,EAAI,OACJ,QAAQ,MAAMO,CAAK,CAE3B,CACJ,CAAC,EAEM,CAAC,GAAGJ,CAAQ,CACvB,CACJ,EAEOK,EAAQP","sourcesContent":["import type { Config } from \"lint-staged\";\nimport { env } from \"node:process\";\n\nimport getNearestConfigPath from \"../utils/get-nearest-config-path\";\n\nconst group: Config = {\n [`**/*.{${[\"ts\", \"mts\", \"cts\"].join(\",\")}}`]: (filenames: string[]) => {\n const commands = new Set<string>();\n\n filenames.forEach((filePath) => {\n try {\n const tsconfigPath = getNearestConfigPath(\"tsconfig.json\", filePath as \"/${string}\") as string;\n\n commands.add(`tsc --noEmit --project ${tsconfigPath}`);\n } catch (error) {\n if (env[\"DEBUG\"]) {\n console.error(error);\n }\n }\n });\n\n return [...commands];\n },\n};\n\nexport default group;\n"]}
@@ -2,8 +2,8 @@ import r from 'find-up';
2
2
  import { existsSync } from 'fs';
3
3
  import { join, dirname } from 'path';
4
4
 
5
- var h=e=>{let t=r.sync("package.json",{cwd:e});return t&&dirname(t)},c=e=>{let t=h(e??process.cwd());if(t?.startsWith("/"))return t;throw new Error(`Cannot determine the nearest root of the package for the file: ${e}!`)},p=e=>{let t=join(...e);if(t.startsWith("/"))return t;throw new TypeError("Joined path did not return an absolute path.")},f=(e,t)=>{let n=c(t),o=p([n,e]);if(existsSync(o))return o;throw new Error(`Cannot locate nearest "${e}" file!`)},d=f;
5
+ var h=e=>{let t=r.sync("package.json",{cwd:e});return t&&dirname(t)},c=e=>{let t=h(e??process.cwd());if(t?.startsWith("/"))return t;throw new Error(`Cannot determine the nearest root of the package for the file: ${e}!`)},f=e=>{let t=join(...e);if(t.startsWith("/"))return t;throw new TypeError("Joined path did not return an absolute path.")},p=(e,t)=>{let n=c(t),o=f([n,e]);if(existsSync(o))return o;throw new Error(`Cannot locate nearest "${e}" file!`)},m=p;
6
6
 
7
- export { d as a };
7
+ export { m as a };
8
8
  //# sourceMappingURL=out.js.map
9
- //# sourceMappingURL=chunk-WAVKF2WX.mjs.map
9
+ //# sourceMappingURL=chunk-5L2ZI35J.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/utils/get-nearest-config-path.ts"],"names":["findUp","existsSync","dirname","join","packageDirectorySync","cwd","filePath","getNearestPackageRootPath","packageDirectoryPath","joinPaths","paths","joined","getNearestConfigPath","fileName","packageRootPath","configPath","get_nearest_config_path_default"],"mappings":"AAAA,OAAOA,MAAY,UACnB,OAAS,cAAAC,MAAkB,KAC3B,OAAS,WAAAC,EAAS,QAAAC,MAAY,OAI9B,IAAMC,EAAwBC,GAAiB,CAC3C,IAAMC,EAAWN,EAAO,KAAK,eAAgB,CAAE,IAAAK,CAAI,CAAC,EAEpD,OAAOC,GAAYJ,EAAQI,CAAQ,CACvC,EAEMC,EAA6BF,GAA+B,CAC9D,IAAMG,EAAuBJ,EAAqBC,GAAO,QAAQ,IAAI,CAAC,EAEtE,GAAIG,GAAsB,WAAW,GAAG,EACpC,OAAOA,EAGX,MAAM,IAAI,MAAM,kEAAkEH,CAAG,GAAG,CAC5F,EAEMI,EAA8CC,GAA2B,CAC3E,IAAMC,EAASR,EAAK,GAAGO,CAAK,EAE5B,GAAIC,EAAO,WAAW,GAAG,EACrB,OAAOA,EAGX,MAAM,IAAI,UAAU,8CAA8C,CACtE,EAEMC,EAAuB,CAAmFC,EAAaR,IAA8B,CACvJ,IAAMS,EAAkBP,EAA0BF,CAAG,EAC/CU,EAAaN,EAAkB,CAACK,EAAsBD,CAAQ,CAAC,EAGrE,GAAIZ,EAAWc,CAAU,EACrB,OAAOA,EAGX,MAAM,IAAI,MAAM,0BAA0BF,CAAQ,SAAS,CAC/D,EAEOG,EAAQJ","sourcesContent":["import findUp from \"find-up\";\nimport { existsSync } from \"node:fs\";\nimport { dirname, join } from \"node:path\";\nimport type { Join } from \"type-fest\";\nimport type { AbsolutePath, ConfigFileName, ConfigPath } from \"./types\";\n\nconst packageDirectorySync = (cwd?: string) => {\n const filePath = findUp.sync(\"package.json\", { cwd });\n\n return filePath && dirname(filePath);\n};\n\nconst getNearestPackageRootPath = (cwd?: string): AbsolutePath => {\n const packageDirectoryPath = packageDirectorySync(cwd ?? process.cwd());\n\n if (packageDirectoryPath?.startsWith(\"/\")) {\n return packageDirectoryPath as AbsolutePath;\n }\n\n throw new Error(`Cannot determine the nearest root of the package for the file: ${cwd}!`);\n};\n\nconst joinPaths = <T extends ReadonlyArray<string>>(paths: T): Join<T, \"/\"> => {\n const joined = join(...paths);\n\n if (joined.startsWith(\"/\")) {\n return joined as Join<T, \"/\">;\n }\n\n throw new TypeError(`Joined path did not return an absolute path.`);\n};\n\nconst getNearestConfigPath = <N extends ConfigFileName = ConfigFileName, A extends AbsolutePath = AbsolutePath>(fileName: N, cwd?: A): ConfigPath<A, N> => {\n const packageRootPath = getNearestPackageRootPath(cwd);\n const configPath = joinPaths<[A, N]>([packageRootPath as A, fileName]);\n\n // eslint-disable-next-line security/detect-non-literal-fs-filename\n if (existsSync(configPath)) {\n return configPath;\n }\n\n throw new Error(`Cannot locate nearest \"${fileName}\" file!`);\n};\n\nexport default getNearestConfigPath;\n"]}
@@ -0,0 +1,10 @@
1
+ 'use strict';
2
+
3
+ var chunkMUEXM65V_js = require('./chunk-MUEXM65V.js');
4
+ var process = require('process');
5
+
6
+ var e={[`**/*.{${["ts","mts","cts"].join(",")}}`]:n=>{let o=new Set;return n.forEach(s=>{try{let t=chunkMUEXM65V_js.a("tsconfig.json",s);o.add(`tsc --noEmit --project ${t}`);}catch(t){process.env.DEBUG&&console.error(t);}}),[...o]}},a=e;
7
+
8
+ exports.a = a;
9
+ //# sourceMappingURL=out.js.map
10
+ //# sourceMappingURL=chunk-LGBPJJYW.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/groups/typescript.ts"],"names":["env","group","filenames","commands","filePath","tsconfigPath","get_nearest_config_path_default","error","typescript_default"],"mappings":"wCACA,OAAS,OAAAA,MAAW,UAIpB,IAAMC,EAAgB,CAClB,CAAC,SAAS,CAAC,KAAM,MAAO,KAAK,EAAE,KAAK,GAAG,CAAC,GAAG,EAAIC,GAAwB,CACnE,IAAMC,EAAW,IAAI,IAErB,OAAAD,EAAU,QAASE,GAAa,CAC5B,GAAI,CAEA,IAAMC,EAAeC,EAAqB,gBAAiBF,CAAwB,EAEnFD,EAAS,IAAI,0BAA0BE,CAAY,EAAE,CACzD,OAASE,EAAP,CACMP,EAAI,OACJ,QAAQ,MAAMO,CAAK,CAE3B,CACJ,CAAC,EAEM,CAAC,GAAGJ,CAAQ,CACvB,CACJ,EAEOK,EAAQP","sourcesContent":["import type { Config } from \"lint-staged\";\nimport { env } from \"node:process\";\n\nimport getNearestConfigPath from \"../utils/get-nearest-config-path\";\n\nconst group: Config = {\n [`**/*.{${[\"ts\", \"mts\", \"cts\"].join(\",\")}}`]: (filenames: string[]) => {\n const commands = new Set<string>();\n\n filenames.forEach((filePath) => {\n try {\n // eslint-disable-next-line no-template-curly-in-string\n const tsconfigPath = getNearestConfigPath(\"tsconfig.json\", filePath as \"/${string}\");\n\n commands.add(`tsc --noEmit --project ${tsconfigPath}`);\n } catch (error: any) {\n if (env[\"DEBUG\"]) {\n console.error(error);\n }\n }\n });\n\n return [...commands];\n },\n};\n\nexport default group;\n"]}
1
+ {"version":3,"sources":["../src/groups/typescript.ts"],"names":["env","group","filenames","commands","filePath","tsconfigPath","get_nearest_config_path_default","error","typescript_default"],"mappings":"wCACA,OAAS,OAAAA,MAAW,UAIpB,IAAMC,EAAgB,CAClB,CAAC,SAAS,CAAC,KAAM,MAAO,KAAK,EAAE,KAAK,GAAG,CAAC,GAAG,EAAIC,GAAwB,CACnE,IAAMC,EAAW,IAAI,IAErB,OAAAD,EAAU,QAASE,GAAa,CAC5B,GAAI,CACA,IAAMC,EAAeC,EAAqB,gBAAiBF,CAAwB,EAEnFD,EAAS,IAAI,0BAA0BE,CAAY,EAAE,CACzD,OAASE,EAAP,CACMP,EAAI,OACJ,QAAQ,MAAMO,CAAK,CAE3B,CACJ,CAAC,EAEM,CAAC,GAAGJ,CAAQ,CACvB,CACJ,EAEOK,EAAQP","sourcesContent":["import type { Config } from \"lint-staged\";\nimport { env } from \"node:process\";\n\nimport getNearestConfigPath from \"../utils/get-nearest-config-path\";\n\nconst group: Config = {\n [`**/*.{${[\"ts\", \"mts\", \"cts\"].join(\",\")}}`]: (filenames: string[]) => {\n const commands = new Set<string>();\n\n filenames.forEach((filePath) => {\n try {\n const tsconfigPath = getNearestConfigPath(\"tsconfig.json\", filePath as \"/${string}\") as string;\n\n commands.add(`tsc --noEmit --project ${tsconfigPath}`);\n } catch (error) {\n if (env[\"DEBUG\"]) {\n console.error(error);\n }\n }\n });\n\n return [...commands];\n },\n};\n\nexport default group;\n"]}
@@ -8,8 +8,8 @@ function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
8
8
 
9
9
  var r__default = /*#__PURE__*/_interopDefault(r);
10
10
 
11
- var h=e=>{let t=r__default.default.sync("package.json",{cwd:e});return t&&path.dirname(t)},c=e=>{let t=h(e??process.cwd());if(t?.startsWith("/"))return t;throw new Error(`Cannot determine the nearest root of the package for the file: ${e}!`)},p=e=>{let t=path.join(...e);if(t.startsWith("/"))return t;throw new TypeError("Joined path did not return an absolute path.")},f=(e,t)=>{let n=c(t),o=p([n,e]);if(fs.existsSync(o))return o;throw new Error(`Cannot locate nearest "${e}" file!`)},d=f;
11
+ var h=e=>{let t=r__default.default.sync("package.json",{cwd:e});return t&&path.dirname(t)},c=e=>{let t=h(e??process.cwd());if(t?.startsWith("/"))return t;throw new Error(`Cannot determine the nearest root of the package for the file: ${e}!`)},f=e=>{let t=path.join(...e);if(t.startsWith("/"))return t;throw new TypeError("Joined path did not return an absolute path.")},p=(e,t)=>{let n=c(t),o=f([n,e]);if(fs.existsSync(o))return o;throw new Error(`Cannot locate nearest "${e}" file!`)},m=p;
12
12
 
13
- exports.a = d;
13
+ exports.a = m;
14
14
  //# sourceMappingURL=out.js.map
15
- //# sourceMappingURL=chunk-B7BKRXC3.js.map
15
+ //# sourceMappingURL=chunk-MUEXM65V.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/utils/get-nearest-config-path.ts"],"names":["findUp","existsSync","dirname","join","packageDirectorySync","cwd","filePath","getNearestPackageRootPath","packageDirectoryPath","joinPaths","paths","joined","getNearestConfigPath","fileName","packageRootPath","configPath","get_nearest_config_path_default"],"mappings":"AAAA,OAAOA,MAAY,UACnB,OAAS,cAAAC,MAAkB,KAC3B,OAAS,WAAAC,EAAS,QAAAC,MAAY,OAI9B,IAAMC,EAAwBC,GAAiB,CAC3C,IAAMC,EAAWN,EAAO,KAAK,eAAgB,CAAE,IAAAK,CAAI,CAAC,EAEpD,OAAOC,GAAYJ,EAAQI,CAAQ,CACvC,EAEMC,EAA6BF,GAA+B,CAC9D,IAAMG,EAAuBJ,EAAqBC,GAAO,QAAQ,IAAI,CAAC,EAEtE,GAAIG,GAAsB,WAAW,GAAG,EACpC,OAAOA,EAGX,MAAM,IAAI,MAAM,kEAAkEH,CAAG,GAAG,CAC5F,EAEMI,EAA8CC,GAA2B,CAC3E,IAAMC,EAASR,EAAK,GAAGO,CAAK,EAE5B,GAAIC,EAAO,WAAW,GAAG,EACrB,OAAOA,EAGX,MAAM,IAAI,UAAU,8CAA8C,CACtE,EAEMC,EAAuB,CAAmFC,EAAaR,IAA8B,CACvJ,IAAMS,EAAkBP,EAA0BF,CAAG,EAC/CU,EAAaN,EAAkB,CAACK,EAAsBD,CAAQ,CAAC,EAGrE,GAAIZ,EAAWc,CAAU,EACrB,OAAOA,EAGX,MAAM,IAAI,MAAM,0BAA0BF,CAAQ,SAAS,CAC/D,EAEOG,EAAQJ","sourcesContent":["import findUp from \"find-up\";\nimport { existsSync } from \"node:fs\";\nimport { dirname, join } from \"node:path\";\nimport type { Join } from \"type-fest\";\nimport type { AbsolutePath, ConfigFileName, ConfigPath } from \"./types\";\n\nconst packageDirectorySync = (cwd?: string) => {\n const filePath = findUp.sync(\"package.json\", { cwd });\n\n return filePath && dirname(filePath);\n};\n\nconst getNearestPackageRootPath = (cwd?: string): AbsolutePath => {\n const packageDirectoryPath = packageDirectorySync(cwd ?? process.cwd());\n\n if (packageDirectoryPath?.startsWith(\"/\")) {\n return packageDirectoryPath as AbsolutePath;\n }\n\n throw new Error(`Cannot determine the nearest root of the package for the file: ${cwd}!`);\n};\n\nconst joinPaths = <T extends ReadonlyArray<string>>(paths: T): Join<T, \"/\"> => {\n const joined = join(...paths);\n\n if (joined.startsWith(\"/\")) {\n return joined as Join<T, \"/\">;\n }\n\n throw new TypeError(`Joined path did not return an absolute path.`);\n};\n\nconst getNearestConfigPath = <N extends ConfigFileName = ConfigFileName, A extends AbsolutePath = AbsolutePath>(fileName: N, cwd?: A): ConfigPath<A, N> => {\n const packageRootPath = getNearestPackageRootPath(cwd);\n const configPath = joinPaths<[A, N]>([packageRootPath as A, fileName]);\n\n // eslint-disable-next-line security/detect-non-literal-fs-filename\n if (existsSync(configPath)) {\n return configPath;\n }\n\n throw new Error(`Cannot locate nearest \"${fileName}\" file!`);\n};\n\nexport default getNearestConfigPath;\n"]}
@@ -0,0 +1,12 @@
1
+ import { a } from './chunk-5L2ZI35J.mjs';
2
+ import { b as b$1, a as a$1 } from './chunk-32WCNCA6.mjs';
3
+ import { pkg, hasDependency, hasDevDependency } from '@anolilab/package-json-utils';
4
+ import { dirname } from 'path';
5
+ import { ESLint } from 'eslint';
6
+ import { quote } from 'shell-quote';
7
+
8
+ !global.anolilabLintStagedPackageJsonConfig&&pkg&&(global.anolilabLintStagedPackageJsonConfig=pkg.anolilab?.["lint-staged-config"]);var C=global.anolilabLintStagedPackageJsonConfig??{},u=C;var S=n=>{let i={};return n.forEach(s=>{let t=dirname(s);i[t]||(i[t]=[]),i[t].push(s);}),i},p=S;var E=async n=>{let i=new ESLint,s=await Promise.all(n.map(async o=>await i.isPathIgnored(o)));return n.filter((o,a)=>!s[a]).map(o=>`"${a$1?o:quote([o])}"`)},h=E;var e=u?.settings?.eslint??{},b=["react-hooks/exhaustive-deps: off"],r=".eslintrc",F=()=>{let n=[];e["max-warnings"]!==void 0&&Number.isNaN(e["max-warnings"])?n.push(`--max-warnings=${e["max-warnings"]}`):e["max-warnings"]!==!1&&n.push("--max-warnings=0");let i=[];e.rules!==void 0&&Array.isArray(e.rules)?i.push([...e.rules,...b].filter(t=>t.trim().length>0).map(t=>`"${t.trim()}"`)):i.push(b.map(t=>`"${t.trim()}"`)),i.length>0&&n.push(`--rule ${i.join(" --rule ")}`);let s=[...e["fix-type"]??["layout"]].filter(t=>t.trim().length>0);return s.length>0&&n.push(`--fix-type ${s.join(",")}`,"--fix"),e.cache&&n.push("--cache"),n},A=async n=>{let i=await h(n),s=F();if(e.config)return s.push(`--config ${e.config}`),[`cross-env NO_LOGS=true eslint ${s.join(" ")} ${i.join(" ")}`];let t=p(i),o=[];return Object.values(t).forEach(a$1=>{let l;[r,`${r}.js`,`${r}.cjs`,`${r}.json`,`${r}.yaml`,`${r}.yml`].forEach($=>{if(!l)try{l=a($,a$1[0]);}catch{}}),l&&o.push(`cross-env NO_LOGS=true eslint ${s.join(" ")} --config ${l} ${a$1.join(" ")}`);}),o},g=A;var x=["cjs","js","mjs","cts","ts","mts","yml","yaml","jsx","tsx","mdx","toml"];global.hasAnolilabLintStagedMarkdownCli||(global.hasAnolilabLintStagedMarkdownCli=hasDependency("markdownlint-cli")||hasDevDependency("markdownlint-cli"));global.hasAnolilabLintStagedMarkdownCli2||(global.hasAnolilabLintStagedMarkdownCli2=hasDependency("markdownlint-cli2")||hasDevDependency("markdownlint-cli2"));!global.hasAnolilabLintStagedMarkdownCli&&!global.hasAnolilabLintStagedMarkdownCli2&&x.push("md");var N={[`**/*.{${["json","json5","jsonc"].join(",")}}`]:async n=>[...await g(n)],[`**/*.{${[x].join(",")}}`]:async n=>[`prettier --write ${b$1(n)}`,...await g(n)]},K=N;
9
+
10
+ export { u as a, K as b };
11
+ //# sourceMappingURL=out.js.map
12
+ //# sourceMappingURL=chunk-V5RHC5X7.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/groups/eslint/index.ts","../src/utils/lint-staged-config.ts","../src/groups/eslint/group-file-paths-by-directory-name.ts","../src/groups/eslint/remove-ignored-files.ts","../src/groups/eslint/create-eslint-commands.ts"],"names":["hasDependency","hasDevDependency","pkg","config","lint_staged_config_default","dirname","groupFilePathsByDirectoryName","filePaths","groups","filePath","directoryName","group_file_paths_by_directory_name_default","ESLint","quote","removeIgnoredFiles","filenames","eslint","ignoredFiles","filename","_","index","is_windows_default","remove_ignored_files_default","eslintSettings","eslintGlobalRulesForFix","configFile","createEslintArguments","eslintArguments","rules","rule","r","fixType","type","createEslintCommands","filteredFiles","groupedFilesNames","eslintCommands","configName","get_nearest_config_path_default","create_eslint_commands_default","extensions","group","concat_files_default","eslint_default"],"mappings":"yFAAA,OAAS,iBAAAA,EAAe,oBAAAC,MAAwB,+BCAhD,OAAS,OAAAC,MAAW,+BAEhB,CAAC,OAAO,qCAAuCA,IAE/C,OAAO,oCAAsCA,EAAI,WAAc,oBAAoB,GAGvF,IAAMC,EAA8C,OAAO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EAAQN,EJlHf,IAAMO,EAAa,CAAC,MAAO,KAAM,MAAO,MAAO,KAAM,MAAO,MAAO,OAAQ,MAAO,MAAO,MAAO,MAAM,EAEjG,OAAO,mCACR,OAAO,iCAAmCxC,EAAc,kBAAkB,GAAKC,EAAiB,kBAAkB,GAGjH,OAAO,oCACR,OAAO,kCAAoCD,EAAc,mBAAmB,GAAKC,EAAiB,mBAAmB,GAGrH,CAAC,OAAO,kCAAoC,CAAC,OAAO,mCACpDuC,EAAW,KAAK,IAAI,EAGxB,IAAMC,EAAgB,CAClB,CAAC,SAAS,CAAC,OAAQ,QAAS,OAAO,EAAE,KAAK,GAAG,CAAC,GAAG,EAAG,MAAO1B,GAAwB,CAAC,GAAI,MAAMwB,EAAqBxB,CAAS,CAAE,EAC9H,CAAC,SAAS,CAACyB,CAAU,EAAE,KAAK,GAAG,CAAC,GAAG,EAAG,MAAOzB,GAAwB,CACjE,oBAAoB2B,EAAY3B,CAAS,CAAC,GAC1C,GAAI,MAAMwB,EAAqBxB,CAAS,CAC5C,CACJ,EAEO4B,EAAQF","sourcesContent":["import { hasDependency, hasDevDependency } from \"@anolilab/package-json-utils\";\nimport type { Config } from \"lint-staged\";\n\nimport concatFiles from \"../../utils/concat-files\";\nimport createEslintCommands from \"./create-eslint-commands\";\n\nconst extensions = [\"cjs\", \"js\", \"mjs\", \"cts\", \"ts\", \"mts\", \"yml\", \"yaml\", \"jsx\", \"tsx\", \"mdx\", \"toml\"];\n\nif (!global.hasAnolilabLintStagedMarkdownCli) {\n global.hasAnolilabLintStagedMarkdownCli = hasDependency(\"markdownlint-cli\") || hasDevDependency(\"markdownlint-cli\");\n}\n\nif (!global.hasAnolilabLintStagedMarkdownCli2) {\n global.hasAnolilabLintStagedMarkdownCli2 = hasDependency(\"markdownlint-cli2\") || hasDevDependency(\"markdownlint-cli2\");\n}\n\nif (!global.hasAnolilabLintStagedMarkdownCli && !global.hasAnolilabLintStagedMarkdownCli2) {\n extensions.push(\"md\");\n}\n\nconst group: Config = {\n [`**/*.{${[\"json\", \"json5\", \"jsonc\"].join(\",\")}}`]: async (filenames: string[]) => [...(await createEslintCommands(filenames))],\n [`**/*.{${[extensions].join(\",\")}}`]: async (filenames: string[]) => [\n `prettier --write ${concatFiles(filenames)}`,\n ...(await createEslintCommands(filenames)),\n ],\n};\n\nexport default group;\n","import { pkg } from \"@anolilab/package-json-utils\";\n\nif (!global.anolilabLintStagedPackageJsonConfig && pkg) {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment,@typescript-eslint/no-unsafe-member-access\n global.anolilabLintStagedPackageJsonConfig = pkg[\"anolilab\"]?.[\"lint-staged-config\"];\n}\n\nconst config: Record<string, boolean | undefined> = global.anolilabLintStagedPackageJsonConfig ?? {};\n\nexport default config;\n","import { dirname } from \"node:path\";\n\nconst groupFilePathsByDirectoryName = (filePaths: string[]): Record<string, string[]> => {\n const groups: Record<string, string[]> = {};\n\n filePaths.forEach((filePath) => {\n const directoryName = dirname(filePath);\n\n // eslint-disable-next-line security/detect-object-injection\n if (!groups[directoryName]) {\n // eslint-disable-next-line security/detect-object-injection\n groups[directoryName] = [];\n }\n // eslint-disable-next-line security/detect-object-injection\n (groups[directoryName] as string[]).push(filePath);\n });\n\n return groups;\n};\n\nexport default groupFilePathsByDirectoryName;\n","// eslint-disable-next-line import/no-extraneous-dependencies\nimport { ESLint } from \"eslint\";\nimport { quote } from \"shell-quote\";\n\nimport isWindows from \"../../utils/is-windows\";\n\nconst removeIgnoredFiles = async (filenames: string[]): Promise<string[]> => {\n const eslint = new ESLint();\n // eslint-disable-next-line compat/compat\n const ignoredFiles = await Promise.all(filenames.map(async (filename) => await eslint.isPathIgnored(filename)));\n // eslint-disable-next-line security/detect-object-injection\n const filteredFiles = filenames.filter((_, index) => !ignoredFiles[index]);\n\n return filteredFiles.map((filename) => `\"${isWindows ? filename : quote([filename])}\"`);\n};\n\nexport default removeIgnoredFiles;\n","import getNearestConfigPath from \"../../utils/get-nearest-config-path\";\nimport anolilabLintStagedConfig from \"../../utils/lint-staged-config\";\nimport groupFilePathsByDirectoryName from \"./group-file-paths-by-directory-name\";\nimport removeIgnoredFiles from \"./remove-ignored-files\";\n\ninterface EslintConfig {\n cache?: boolean;\n config?: string;\n \"fix-type\"?: string[];\n \"max-warnings\"?: number | string | false;\n rules?: string[];\n}\n\ninterface ESLintSettings {\n settings?: {\n eslint?: EslintConfig;\n };\n}\n\n// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition\nconst eslintSettings: EslintConfig = (anolilabLintStagedConfig as ESLintSettings)?.settings?.eslint ?? ({} as EslintConfig);\n\nconst eslintGlobalRulesForFix = [\n // react-hooks/eslint and react in general is very strict about exhaustively\n // declaring the dependencies when using the useEffect, useCallback... hooks.\n //\n // In some specific scenarios declaring the deps seems 'less' wanted or 'less' applicable\n // by the developer, leading to some exceptions in the code. That said it should be avoided.\n //\n // While the 'react-hooks/exhaustive-deps' rule is a good rule of thumb, it's not recommended to\n // automatically fix it from lint-staged as it can potentially break a legit intent.\n //\n // Reminder that a good practice is to always declare the dependencies when using the hooks,\n // and if not applicable, add an eslint disable comment to the useEffect, useCallback... such as:\n //\n // // eslint-disable-next-line react-hooks/exhaustive-deps\n //\n // Another approach can be to use hooks such as https://github.com/kentcdodds/use-deep-compare-effect to quickly bypass\n // shallow rendering limitations.\n //\n // @see https://reactjs.org/docs/hooks-rules.html\n // @see https://eslint.org/docs/2.13.1/user-guide/configuring#disabling-rules-with-inline-comments\n \"react-hooks/exhaustive-deps: off\",\n];\n\nconst configFile = \".eslintrc\";\n\nconst createEslintArguments = (): string[] => {\n const eslintArguments: string[] = [];\n\n if (eslintSettings[\"max-warnings\"] !== undefined && Number.isNaN(eslintSettings[\"max-warnings\"])) {\n eslintArguments.push(`--max-warnings=${eslintSettings[\"max-warnings\"]}`);\n } else if (eslintSettings[\"max-warnings\"] !== false) {\n eslintArguments.push(\"--max-warnings=0\");\n }\n\n const rules = [];\n\n if (eslintSettings.rules !== undefined && Array.isArray(eslintSettings.rules)) {\n rules.push([...eslintSettings.rules, ...eslintGlobalRulesForFix].filter((rule) => rule.trim().length > 0).map((r) => `\"${r.trim()}\"`));\n } else {\n rules.push(eslintGlobalRulesForFix.map((r) => `\"${r.trim()}\"`));\n }\n\n if (rules.length > 0) {\n eslintArguments.push(`--rule ${rules.join(\" --rule \")}`);\n }\n\n // For lint-staged it's safer to not apply the fix command if it changes the AST\n // @see https://eslint.org/docs/user-guide/command-line-interface#--fix-type\n const fixType = [...(eslintSettings[\"fix-type\"] ?? [\"layout\"])].filter((type) => type.trim().length > 0);\n\n if (fixType.length > 0) {\n eslintArguments.push(`--fix-type ${fixType.join(\",\")}`, \"--fix\");\n }\n\n if (eslintSettings.cache) {\n eslintArguments.push(\"--cache\");\n }\n\n return eslintArguments;\n};\n\nconst createEslintCommands = async (filenames: string[]): Promise<string[]> => {\n const filteredFiles = await removeIgnoredFiles(filenames);\n\n const eslintArguments = createEslintArguments();\n\n if (eslintSettings.config) {\n eslintArguments.push(`--config ${eslintSettings.config}`);\n\n return [`cross-env NO_LOGS=true eslint ${eslintArguments.join(\" \")} ${filteredFiles.join(\" \")}`];\n }\n\n const groupedFilesNames = groupFilePathsByDirectoryName(filteredFiles);\n const eslintCommands: string[] = [];\n\n Object.values(groupedFilesNames).forEach((filePaths) => {\n let config: string | undefined;\n\n [configFile, `${configFile}.js`, `${configFile}.cjs`, `${configFile}.json`, `${configFile}.yaml`, `${configFile}.yml`].forEach((configName) => {\n if (config) {\n return;\n }\n\n try {\n config = getNearestConfigPath(configName, filePaths[0] as \"/${string}\") as string;\n } catch {\n // Ignore\n }\n });\n\n if (config) {\n eslintCommands.push(`cross-env NO_LOGS=true eslint ${eslintArguments.join(\" \")} --config ${config} ${filePaths.join(\" \")}`);\n }\n });\n\n return eslintCommands;\n};\n\nexport default createEslintCommands;\n"]}
@@ -0,0 +1,15 @@
1
+ 'use strict';
2
+
3
+ var chunkMUEXM65V_js = require('./chunk-MUEXM65V.js');
4
+ var chunk26UFUGBI_js = require('./chunk-26UFUGBI.js');
5
+ var packageJsonUtils = require('@anolilab/package-json-utils');
6
+ var path = require('path');
7
+ var eslint = require('eslint');
8
+ var shellQuote = require('shell-quote');
9
+
10
+ !global.anolilabLintStagedPackageJsonConfig&&packageJsonUtils.pkg&&(global.anolilabLintStagedPackageJsonConfig=packageJsonUtils.pkg.anolilab?.["lint-staged-config"]);var C=global.anolilabLintStagedPackageJsonConfig??{},u=C;var S=n=>{let i={};return n.forEach(s=>{let t=path.dirname(s);i[t]||(i[t]=[]),i[t].push(s);}),i},p=S;var E=async n=>{let i=new eslint.ESLint,s=await Promise.all(n.map(async o=>await i.isPathIgnored(o)));return n.filter((o,a)=>!s[a]).map(o=>`"${chunk26UFUGBI_js.a?o:shellQuote.quote([o])}"`)},h=E;var e=u?.settings?.eslint??{},b=["react-hooks/exhaustive-deps: off"],r=".eslintrc",F=()=>{let n=[];e["max-warnings"]!==void 0&&Number.isNaN(e["max-warnings"])?n.push(`--max-warnings=${e["max-warnings"]}`):e["max-warnings"]!==!1&&n.push("--max-warnings=0");let i=[];e.rules!==void 0&&Array.isArray(e.rules)?i.push([...e.rules,...b].filter(t=>t.trim().length>0).map(t=>`"${t.trim()}"`)):i.push(b.map(t=>`"${t.trim()}"`)),i.length>0&&n.push(`--rule ${i.join(" --rule ")}`);let s=[...e["fix-type"]??["layout"]].filter(t=>t.trim().length>0);return s.length>0&&n.push(`--fix-type ${s.join(",")}`,"--fix"),e.cache&&n.push("--cache"),n},A=async n=>{let i=await h(n),s=F();if(e.config)return s.push(`--config ${e.config}`),[`cross-env NO_LOGS=true eslint ${s.join(" ")} ${i.join(" ")}`];let t=p(i),o=[];return Object.values(t).forEach(a=>{let l;[r,`${r}.js`,`${r}.cjs`,`${r}.json`,`${r}.yaml`,`${r}.yml`].forEach($=>{if(!l)try{l=chunkMUEXM65V_js.a($,a[0]);}catch{}}),l&&o.push(`cross-env NO_LOGS=true eslint ${s.join(" ")} --config ${l} ${a.join(" ")}`);}),o},g=A;var x=["cjs","js","mjs","cts","ts","mts","yml","yaml","jsx","tsx","mdx","toml"];global.hasAnolilabLintStagedMarkdownCli||(global.hasAnolilabLintStagedMarkdownCli=packageJsonUtils.hasDependency("markdownlint-cli")||packageJsonUtils.hasDevDependency("markdownlint-cli"));global.hasAnolilabLintStagedMarkdownCli2||(global.hasAnolilabLintStagedMarkdownCli2=packageJsonUtils.hasDependency("markdownlint-cli2")||packageJsonUtils.hasDevDependency("markdownlint-cli2"));!global.hasAnolilabLintStagedMarkdownCli&&!global.hasAnolilabLintStagedMarkdownCli2&&x.push("md");var N={[`**/*.{${["json","json5","jsonc"].join(",")}}`]:async n=>[...await g(n)],[`**/*.{${[x].join(",")}}`]:async n=>[`prettier --write ${chunk26UFUGBI_js.b(n)}`,...await g(n)]},K=N;
11
+
12
+ exports.a = u;
13
+ exports.b = K;
14
+ //# sourceMappingURL=out.js.map
15
+ //# sourceMappingURL=chunk-ZPLALNOC.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/groups/eslint/index.ts","../src/utils/lint-staged-config.ts","../src/groups/eslint/group-file-paths-by-directory-name.ts","../src/groups/eslint/remove-ignored-files.ts","../src/groups/eslint/create-eslint-commands.ts"],"names":["hasDependency","hasDevDependency","pkg","config","lint_staged_config_default","dirname","groupFilePathsByDirectoryName","filePaths","groups","filePath","directoryName","group_file_paths_by_directory_name_default","ESLint","quote","removeIgnoredFiles","filenames","eslint","ignoredFiles","filename","_","index","is_windows_default","remove_ignored_files_default","eslintSettings","eslintGlobalRulesForFix","configFile","createEslintArguments","eslintArguments","rules","rule","r","fixType","type","createEslintCommands","filteredFiles","groupedFilesNames","eslintCommands","configName","get_nearest_config_path_default","create_eslint_commands_default","extensions","group","concat_files_default","eslint_default"],"mappings":"uFAAA,OAAS,iBAAAA,EAAe,oBAAAC,MAAwB,+BCAhD,OAAS,OAAAC,MAAW,+BAEhB,CAAC,OAAO,qCAAuCA,IAE/C,OAAO,oCAAsCA,EAAI,WAA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AAE,CAElI,CAAC,EAEM6B,CACX,EAEOG,EAAQN,EJlHf,IAAMO,EAAa,CAAC,MAAO,KAAM,MAAO,MAAO,KAAM,MAAO,MAAO,OAAQ,MAAO,MAAO,MAAO,MAAM,EAEjG,OAAO,mCACR,OAAO,iCAAmCxC,EAAc,kBAAkB,GAAKC,EAAiB,kBAAkB,GAGjH,OAAO,oCACR,OAAO,kCAAoCD,EAAc,mBAAmB,GAAKC,EAAiB,mBAAmB,GAGrH,CAAC,OAAO,kCAAoC,CAAC,OAAO,mCACpDuC,EAAW,KAAK,IAAI,EAGxB,IAAMC,EAAgB,CAClB,CAAC,SAAS,CAAC,OAAQ,QAAS,OAAO,EAAE,KAAK,GAAG,CAAC,GAAG,EAAG,MAAO1B,GAAwB,CAAC,GAAI,MAAMwB,EAAqBxB,CAAS,CAAE,EAC9H,CAAC,SAAS,CAACyB,CAAU,EAAE,KAAK,GAAG,CAAC,GAAG,EAAG,MAAOzB,GAAwB,CACjE,oBAAoB2B,EAAY3B,CAAS,CAAC,GAC1C,GAAI,MAAMwB,EAAqBxB,CAAS,CAC5C,CACJ,EAEO4B,EAAQF","sourcesContent":["import { hasDependency, hasDevDependency } from \"@anolilab/package-json-utils\";\nimport type { Config } from \"lint-staged\";\n\nimport concatFiles from \"../../utils/concat-files\";\nimport createEslintCommands from \"./create-eslint-commands\";\n\nconst extensions = [\"cjs\", \"js\", \"mjs\", \"cts\", \"ts\", \"mts\", \"yml\", \"yaml\", \"jsx\", \"tsx\", \"mdx\", \"toml\"];\n\nif (!global.hasAnolilabLintStagedMarkdownCli) {\n global.hasAnolilabLintStagedMarkdownCli = hasDependency(\"markdownlint-cli\") || hasDevDependency(\"markdownlint-cli\");\n}\n\nif (!global.hasAnolilabLintStagedMarkdownCli2) {\n global.hasAnolilabLintStagedMarkdownCli2 = hasDependency(\"markdownlint-cli2\") || hasDevDependency(\"markdownlint-cli2\");\n}\n\nif (!global.hasAnolilabLintStagedMarkdownCli && !global.hasAnolilabLintStagedMarkdownCli2) {\n extensions.push(\"md\");\n}\n\nconst group: Config = {\n [`**/*.{${[\"json\", \"json5\", \"jsonc\"].join(\",\")}}`]: async (filenames: string[]) => [...(await createEslintCommands(filenames))],\n [`**/*.{${[extensions].join(\",\")}}`]: async (filenames: string[]) => [\n `prettier --write ${concatFiles(filenames)}`,\n ...(await createEslintCommands(filenames)),\n ],\n};\n\nexport default group;\n","import { pkg } from \"@anolilab/package-json-utils\";\n\nif (!global.anolilabLintStagedPackageJsonConfig && pkg) {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment,@typescript-eslint/no-unsafe-member-access\n global.anolilabLintStagedPackageJsonConfig = pkg[\"anolilab\"]?.[\"lint-staged-config\"];\n}\n\nconst config: Record<string, boolean | undefined> = global.anolilabLintStagedPackageJsonConfig ?? {};\n\nexport default config;\n","import { dirname } from \"node:path\";\n\nconst groupFilePathsByDirectoryName = (filePaths: string[]): Record<string, string[]> => {\n const groups: Record<string, string[]> = {};\n\n filePaths.forEach((filePath) => {\n const directoryName = dirname(filePath);\n\n // eslint-disable-next-line security/detect-object-injection\n if (!groups[directoryName]) {\n // eslint-disable-next-line security/detect-object-injection\n groups[directoryName] = [];\n }\n // eslint-disable-next-line security/detect-object-injection\n (groups[directoryName] as string[]).push(filePath);\n });\n\n return groups;\n};\n\nexport default groupFilePathsByDirectoryName;\n","// eslint-disable-next-line import/no-extraneous-dependencies\nimport { ESLint } from \"eslint\";\nimport { quote } from \"shell-quote\";\n\nimport isWindows from \"../../utils/is-windows\";\n\nconst removeIgnoredFiles = async (filenames: string[]): Promise<string[]> => {\n const eslint = new ESLint();\n // eslint-disable-next-line compat/compat\n const ignoredFiles = await Promise.all(filenames.map(async (filename) => await eslint.isPathIgnored(filename)));\n // eslint-disable-next-line security/detect-object-injection\n const filteredFiles = filenames.filter((_, index) => !ignoredFiles[index]);\n\n return filteredFiles.map((filename) => `\"${isWindows ? filename : quote([filename])}\"`);\n};\n\nexport default removeIgnoredFiles;\n","import getNearestConfigPath from \"../../utils/get-nearest-config-path\";\nimport anolilabLintStagedConfig from \"../../utils/lint-staged-config\";\nimport groupFilePathsByDirectoryName from \"./group-file-paths-by-directory-name\";\nimport removeIgnoredFiles from \"./remove-ignored-files\";\n\ninterface EslintConfig {\n cache?: boolean;\n config?: string;\n \"fix-type\"?: string[];\n \"max-warnings\"?: number | string | false;\n rules?: string[];\n}\n\ninterface ESLintSettings {\n settings?: {\n eslint?: EslintConfig;\n };\n}\n\n// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition\nconst eslintSettings: EslintConfig = (anolilabLintStagedConfig as ESLintSettings)?.settings?.eslint ?? ({} as EslintConfig);\n\nconst eslintGlobalRulesForFix = [\n // react-hooks/eslint and react in general is very strict about exhaustively\n // declaring the dependencies when using the useEffect, useCallback... hooks.\n //\n // In some specific scenarios declaring the deps seems 'less' wanted or 'less' applicable\n // by the developer, leading to some exceptions in the code. That said it should be avoided.\n //\n // While the 'react-hooks/exhaustive-deps' rule is a good rule of thumb, it's not recommended to\n // automatically fix it from lint-staged as it can potentially break a legit intent.\n //\n // Reminder that a good practice is to always declare the dependencies when using the hooks,\n // and if not applicable, add an eslint disable comment to the useEffect, useCallback... such as:\n //\n // // eslint-disable-next-line react-hooks/exhaustive-deps\n //\n // Another approach can be to use hooks such as https://github.com/kentcdodds/use-deep-compare-effect to quickly bypass\n // shallow rendering limitations.\n //\n // @see https://reactjs.org/docs/hooks-rules.html\n // @see https://eslint.org/docs/2.13.1/user-guide/configuring#disabling-rules-with-inline-comments\n \"react-hooks/exhaustive-deps: off\",\n];\n\nconst configFile = \".eslintrc\";\n\nconst createEslintArguments = (): string[] => {\n const eslintArguments: string[] = [];\n\n if (eslintSettings[\"max-warnings\"] !== undefined && Number.isNaN(eslintSettings[\"max-warnings\"])) {\n eslintArguments.push(`--max-warnings=${eslintSettings[\"max-warnings\"]}`);\n } else if (eslintSettings[\"max-warnings\"] !== false) {\n eslintArguments.push(\"--max-warnings=0\");\n }\n\n const rules = [];\n\n if (eslintSettings.rules !== undefined && Array.isArray(eslintSettings.rules)) {\n rules.push([...eslintSettings.rules, ...eslintGlobalRulesForFix].filter((rule) => rule.trim().length > 0).map((r) => `\"${r.trim()}\"`));\n } else {\n rules.push(eslintGlobalRulesForFix.map((r) => `\"${r.trim()}\"`));\n }\n\n if (rules.length > 0) {\n eslintArguments.push(`--rule ${rules.join(\" --rule \")}`);\n }\n\n // For lint-staged it's safer to not apply the fix command if it changes the AST\n // @see https://eslint.org/docs/user-guide/command-line-interface#--fix-type\n const fixType = [...(eslintSettings[\"fix-type\"] ?? [\"layout\"])].filter((type) => type.trim().length > 0);\n\n if (fixType.length > 0) {\n eslintArguments.push(`--fix-type ${fixType.join(\",\")}`, \"--fix\");\n }\n\n if (eslintSettings.cache) {\n eslintArguments.push(\"--cache\");\n }\n\n return eslintArguments;\n};\n\nconst createEslintCommands = async (filenames: string[]): Promise<string[]> => {\n const filteredFiles = await removeIgnoredFiles(filenames);\n\n const eslintArguments = createEslintArguments();\n\n if (eslintSettings.config) {\n eslintArguments.push(`--config ${eslintSettings.config}`);\n\n return [`cross-env NO_LOGS=true eslint ${eslintArguments.join(\" \")} ${filteredFiles.join(\" \")}`];\n }\n\n const groupedFilesNames = groupFilePathsByDirectoryName(filteredFiles);\n const eslintCommands: string[] = [];\n\n Object.values(groupedFilesNames).forEach((filePaths) => {\n let config: string | undefined;\n\n [configFile, `${configFile}.js`, `${configFile}.cjs`, `${configFile}.json`, `${configFile}.yaml`, `${configFile}.yml`].forEach((configName) => {\n if (config) {\n return;\n }\n\n try {\n config = getNearestConfigPath(configName, filePaths[0] as \"/${string}\") as string;\n } catch {\n // Ignore\n }\n });\n\n if (config) {\n eslintCommands.push(`cross-env NO_LOGS=true eslint ${eslintArguments.join(\" \")} --config ${config} ${filePaths.join(\" \")}`);\n }\n });\n\n return eslintCommands;\n};\n\nexport default createEslintCommands;\n"]}
@@ -1,11 +1,11 @@
1
1
  'use strict';
2
2
 
3
- var chunkWJEJ2JPI_js = require('../../chunk-WJEJ2JPI.js');
4
- require('../../chunk-B7BKRXC3.js');
3
+ var chunkZPLALNOC_js = require('../../chunk-ZPLALNOC.js');
4
+ require('../../chunk-MUEXM65V.js');
5
5
  require('../../chunk-26UFUGBI.js');
6
6
 
7
7
 
8
8
 
9
- module.exports = chunkWJEJ2JPI_js.b;
9
+ module.exports = chunkZPLALNOC_js.b;
10
10
  //# sourceMappingURL=out.js.map
11
11
  //# sourceMappingURL=index.js.map
@@ -1,5 +1,5 @@
1
- export { b as default } from '../../chunk-ORP5CV3J.mjs';
2
- import '../../chunk-WAVKF2WX.mjs';
1
+ export { b as default } from '../../chunk-V5RHC5X7.mjs';
2
+ import '../../chunk-5L2ZI35J.mjs';
3
3
  import '../../chunk-32WCNCA6.mjs';
4
4
  //# sourceMappingURL=out.js.map
5
5
  //# sourceMappingURL=index.mjs.map
@@ -1,10 +1,10 @@
1
1
  'use strict';
2
2
 
3
- var chunkNQXBNZPO_js = require('../chunk-NQXBNZPO.js');
4
- require('../chunk-B7BKRXC3.js');
3
+ var chunkLGBPJJYW_js = require('../chunk-LGBPJJYW.js');
4
+ require('../chunk-MUEXM65V.js');
5
5
 
6
6
 
7
7
 
8
- module.exports = chunkNQXBNZPO_js.a;
8
+ module.exports = chunkLGBPJJYW_js.a;
9
9
  //# sourceMappingURL=out.js.map
10
10
  //# sourceMappingURL=typescript.js.map
@@ -1,4 +1,4 @@
1
- export { a as default } from '../chunk-EMISBJRA.mjs';
2
- import '../chunk-WAVKF2WX.mjs';
1
+ export { a as default } from '../chunk-475NPYYW.mjs';
2
+ import '../chunk-5L2ZI35J.mjs';
3
3
  //# sourceMappingURL=out.js.map
4
4
  //# sourceMappingURL=typescript.mjs.map
package/dist/index.js CHANGED
@@ -1,8 +1,8 @@
1
1
  'use strict';
2
2
 
3
- var chunkNQXBNZPO_js = require('./chunk-NQXBNZPO.js');
4
- var chunkWJEJ2JPI_js = require('./chunk-WJEJ2JPI.js');
5
- require('./chunk-B7BKRXC3.js');
3
+ var chunkLGBPJJYW_js = require('./chunk-LGBPJJYW.js');
4
+ var chunkZPLALNOC_js = require('./chunk-ZPLALNOC.js');
5
+ require('./chunk-MUEXM65V.js');
6
6
  var chunkGWSF22B6_js = require('./chunk-GWSF22B6.js');
7
7
  var chunkCZNOXHD3_js = require('./chunk-CZNOXHD3.js');
8
8
  var chunk6EWZW5LF_js = require('./chunk-6EWZW5LF.js');
@@ -12,13 +12,13 @@ require('./chunk-26UFUGBI.js');
12
12
  var process = require('process');
13
13
  var packageJsonUtils = require('@anolilab/package-json-utils');
14
14
 
15
- var N=[{config:chunkWJEJ2JPI_js.b,configName:"eslint",dependencies:["prettier","eslint"]},{config:chunkGWSF22B6_js.a,configName:"json",dependencies:["prettier","sort-package-json"]},{config:chunkCZNOXHD3_js.a,configName:"markdown",dependencies:["prettier","markdownlint-cli","markdownlint-cli2"]},{config:chunk6EWZW5LF_js.a,configName:"secretlint",dependencies:["secretlint"]},{config:chunkFZFCZD6I_js.a,configName:"stylesheets",dependencies:["stylelint"]},{config:chunkVAUDCZ4C_js.a,configName:"tests",dependencies:["vite","jest","ava"]},{config:chunkNQXBNZPO_js.a,configName:"typescript",dependencies:["typescript"]}],g={},r=[],a={};N.forEach(s=>{let{config:o,configName:i,dependencies:l}=s;if(chunkWJEJ2JPI_js.a.plugin?.[i]!==!1){let t=[];l.forEach(e=>{(packageJsonUtils.hasDependency(e)||packageJsonUtils.hasDevDependency(e))&&t.push(e);}),t.length>0?(g={...g,...o},r.push(i)):(a[i]={},l.forEach(e=>{a[i][e]=packageJsonUtils.hasDependency(e)||packageJsonUtils.hasDevDependency(e);}));}});var k={...g};var L=()=>{},j=s=>process.env.NO_LOGS?L:o=>console.log(`${s}${o}`),O=j(""),n=O;if(!global.hasAnolilabStagedLintConfigLoaded){process.env.DEBUG&&(n(`
15
+ var y=[{config:chunkZPLALNOC_js.b,configName:"eslint",dependencies:["prettier","eslint"]},{config:chunkGWSF22B6_js.a,configName:"json",dependencies:["prettier","sort-package-json"]},{config:chunkCZNOXHD3_js.a,configName:"markdown",dependencies:["prettier","markdownlint-cli","markdownlint-cli2"]},{config:chunk6EWZW5LF_js.a,configName:"secretlint",dependencies:["secretlint"]},{config:chunkFZFCZD6I_js.a,configName:"stylesheets",dependencies:["stylelint"]},{config:chunkVAUDCZ4C_js.a,configName:"tests",dependencies:["vite","jest","ava"]},{config:chunkLGBPJJYW_js.a,configName:"typescript",dependencies:["typescript"]}],g={},r=[],a={};y.forEach(t=>{let{config:n,configName:i,dependencies:l}=t;if(chunkZPLALNOC_js.a.plugin?.[i]!==!1){let s=[];l.forEach(e=>{(packageJsonUtils.hasDependency(e)||packageJsonUtils.hasDevDependency(e))&&s.push(e);}),s.length>0?(g={...g,...n},r.push(i)):(a[i]={},l.forEach(e=>{a[i][e]=packageJsonUtils.hasDependency(e)||packageJsonUtils.hasDevDependency(e);}));}});var w={...g};var j=()=>{},k=t=>process.env.NO_LOGS?j:n=>console.log(`${t}${n}`),O=k(""),o=O;if(!global.hasAnolilabStagedLintConfigLoaded){process.env.DEBUG&&(o(`
16
16
  @anolilab/lint-stage-config loaded the following plugins:
17
- `),r.forEach(o=>{n(` ${o}`);}));let s=!1;Object.entries(a).forEach(([o,i])=>{Object.values(i).some(Boolean)&&(s=!0,n(`
18
- Your package.json container dependencies for the "${o}" plugin, please add the following dependencies with your chosen package manager to enable this plugin:`),Object.entries(i).forEach(([t,e])=>{e||n(` ${t}`);}));}),s&&(n(`
19
- To disable this message, add the following to your package.json:`),n(` "anolilab": { "lint-stage-config": { plugin: { "plugin-name": false } } }
20
- `)),n('To disable all logging, add the following to your eslint command call "NO_LOGS=true eslint ..."'),global.hasAnolilabStagedLintConfigLoaded=!0;}
17
+ `),r.forEach(n=>{o(` ${n}`);}));let t=!1;Object.entries(a).forEach(([n,i])=>{Object.values(i).some(Boolean)&&(t=!0,o(`
18
+ Your package.json container dependencies for the "${n}" plugin, please add the following dependencies with your chosen package manager to enable this plugin:`),Object.entries(i).forEach(([s,e])=>{e||o(` ${s}`);}));}),t&&(o(`
19
+ To disable this message, add the following to your package.json:`),o(` "anolilab": { "lint-stage-config": { plugin: { "plugin-name": false } } }
20
+ `)),o('To disable all logging, add the following to your lint-staged command call "NO_LOGS=true lint-staged ..."'),global.hasAnolilabStagedLintConfigLoaded=!0;}
21
21
 
22
- module.exports = k;
22
+ module.exports = w;
23
23
  //# sourceMappingURL=out.js.map
24
24
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts","../src/config.ts","../src/utils/logger.ts"],"names":["env","hasDependency","hasDevDependency","groups","eslint_default","json_default","markdown_default","secretlint_default","stylesheets_default","tests_default","typescript_default","loadedPlugins","loadedPluginsNames","possiblePlugins","plugin","config","configName","dependencies","lint_staged_config_default","foundDependencies","dependency","loaded","noop","consolePrefix","prefix","message","consoleLog","logger_default","pluginName","hasLogged","installed"],"mappings":"uVAAA,OAAS,OAAAA,MAAW,UCApB,OAAS,iBAAAC,EAAe,oBAAAC,MAAwB,+BAkBhD,IAAMC,EAAiB,CACnB,CACI,OAAQC,EACR,WAAY,SACZ,aAAc,CAAC,WAAY,QAAQ,CACvC,EACA,CACI,OAAQC,EACR,WAAY,OACZ,aAAc,CAAC,WAAY,mBAAmB,CAClD,EACA,CACI,OAAQC,EACR,WAAY,WACZ,aAAc,CAAC,WAAY,mBAAoB,mBAAmB,CACtE,EACA,CACI,OAAQC,EACR,WAAY,aACZ,aAAc,CAAC,YAAY,CAC/B,EACA,CACI,OAAQC,EACR,WAAY,cACZ,aAAc,CAAC,WAAW,CAC9B,EACA,CACI,OAAQC,EACR,WAAY,QACZ,aAAc,CAAC,OAAQ,OAAQ,KAAK,CACxC,EACA,CACI,OAAQC,EACR,WAAY,aACZ,aAAc,CAAC,YAAY,CAC/B,CACJ,EAEIC,EAAwB,CAAC,EACvBC,EAA+B,CAAC,EAEhCC,EAA0E,CAAC,EAEjFV,EAAO,QAASW,GAA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ET,CAAC,EAGGS,IACAF,EAAW;AAAA,iEAAoE,EAC/EA,EAAW;AAAA,CAAiF,GAGhGA,EAAW,iGAAiG,EAE5G,OAAO,kCAAoC,EAC/C","sourcesContent":["import { env } from \"node:process\";\n\nimport { loadedPluginsNames, possiblePlugins } from \"./config\";\nimport consoleLog from \"./utils/logger\";\n\n// Workaround VS Code trying to run this file twice!\nif (!global.hasAnolilabStagedLintConfigLoaded) {\n if (env[\"DEBUG\"]) {\n consoleLog(\"\\n@anolilab/lint-stage-config loaded the following plugins:\\n\");\n\n loadedPluginsNames.forEach((pluginName) => {\n consoleLog(` ${pluginName}`);\n });\n }\n\n let hasLogged = false;\n\n Object.entries(possiblePlugins).forEach(([plugin, dependencies]) => {\n const hasOneDependency = Object.values(dependencies).some(Boolean);\n\n if (hasOneDependency) {\n hasLogged = true;\n consoleLog(\n `\\nYour package.json container dependencies for the \"${plugin}\" plugin, please add the following dependencies with your chosen package manager to enable this plugin:`,\n );\n\n Object.entries(dependencies).forEach(([dependency, installed]) => {\n if (!installed) {\n consoleLog(` ${dependency}`);\n }\n });\n }\n });\n\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition\n if (hasLogged) {\n consoleLog(\"\\nTo disable this message, add the following to your package.json:\");\n consoleLog(' \"anolilab\": { \"lint-stage-config\": { plugin: { \"plugin-name\": false } } }\\n');\n }\n\n consoleLog('To disable all logging, add the following to your eslint command call \"NO_LOGS=true eslint ...\"');\n\n global.hasAnolilabStagedLintConfigLoaded = true;\n}\n\nexport { loadedPlugins as default } from \"./config\";\n","import { hasDependency, hasDevDependency } from \"@anolilab/package-json-utils\";\nimport type { Config } from \"lint-staged\";\n\nimport eslintConfig from \"./groups/eslint\";\nimport jsonConfig from \"./groups/json\";\nimport markdownConfig from \"./groups/markdown\";\nimport secretlintConfig from \"./groups/secretlint\";\nimport stylesheetsConfig from \"./groups/stylesheets\";\nimport testsConfig from \"./groups/tests\";\nimport typescriptConfig from \"./groups/typescript\";\nimport anolilabLintStagedConfig from \"./utils/lint-staged-config\";\n\ntype Groups = {\n config: Config;\n configName: string;\n dependencies: string[];\n}[];\n\nconst groups: Groups = [\n {\n config: eslintConfig,\n configName: \"eslint\",\n dependencies: [\"prettier\", \"eslint\"],\n },\n {\n config: jsonConfig,\n configName: \"json\",\n dependencies: [\"prettier\", \"sort-package-json\"],\n },\n {\n config: markdownConfig,\n configName: \"markdown\",\n dependencies: [\"prettier\", \"markdownlint-cli\", \"markdownlint-cli2\"],\n },\n {\n config: secretlintConfig,\n configName: \"secretlint\",\n dependencies: [\"secretlint\"],\n },\n {\n config: stylesheetsConfig,\n configName: \"stylesheets\",\n dependencies: [\"stylelint\"],\n },\n {\n config: testsConfig,\n configName: \"tests\",\n dependencies: [\"vite\", \"jest\", \"ava\"],\n },\n {\n config: typescriptConfig,\n configName: \"typescript\",\n dependencies: [\"typescript\"],\n },\n];\n\nlet loadedPlugins: Config = {};\nconst loadedPluginsNames: string[] = [];\n\nconst possiblePlugins: { [rule: string]: { [packageName: string]: boolean } } = {};\n\ngroups.forEach((plugin) => {\n const { config, configName, dependencies } = plugin;\n\n // eslint-disable-next-line security/detect-object-injection\n if ((anolilabLintStagedConfig as unknown as { [key: string]: { [key: string]: false | undefined } })[\"plugin\"]?.[configName] !== false) {\n const foundDependencies = [];\n\n dependencies.forEach((dependency) => {\n if (hasDependency(dependency) || hasDevDependency(dependency)) {\n foundDependencies.push(dependency);\n }\n });\n\n if (foundDependencies.length > 0) {\n loadedPlugins = { ...loadedPlugins, ...config };\n loadedPluginsNames.push(configName);\n } else {\n // eslint-disable-next-line security/detect-object-injection\n possiblePlugins[configName] = {};\n\n dependencies.forEach((dependency) => {\n // eslint-disable-next-line security/detect-object-injection\n (possiblePlugins[configName] as { [key: string]: boolean })[dependency] = hasDependency(dependency) || hasDevDependency(dependency);\n });\n }\n }\n});\n\nconst loaded: Config = { ...loadedPlugins };\n\nexport { loaded as loadedPlugins, loadedPluginsNames, possiblePlugins };\n","import { env } from \"node:process\";\n\nconst noop = () => undefined;\n\nconst consolePrefix = (prefix: string) => (env[\"NO_LOGS\"] ? noop : (message: string) => console.log(`${prefix}${message}`));\n\nconst consoleLog = consolePrefix(\"\");\n\nexport default consoleLog;\n"]}
1
+ {"version":3,"sources":["../src/index.ts","../src/config.ts","../src/utils/logger.ts"],"names":["env","hasDependency","hasDevDependency","groups","eslint_default","json_default","markdown_default","secretlint_default","stylesheets_default","tests_default","typescript_default","loadedPlugins","loadedPluginsNames","possiblePlugins","plugin","config","configName","dependencies","lint_staged_config_default","foundDependencies","dependency","loaded","noop","consolePrefix","prefix","message","consoleLog","logger_default","pluginName","hasLogged","installed"],"mappings":"uVAAA,OAAS,OAAAA,MAAW,UCApB,OAAS,iBAAAC,EAAe,oBAAAC,MAAwB,+BAkBhD,IAAMC,EAAiB,CACnB,CACI,OAAQC,EACR,WAAY,SACZ,aAAc,CAAC,WAAY,QAAQ,CACvC,EACA,CACI,OAAQC,EACR,WAAY,OACZ,aAAc,CAAC,WAAY,mBAAmB,CAClD,EACA,CACI,OAAQC,EACR,WAAY,WACZ,aAAc,CAAC,WAAY,mBAAoB,mBAAmB,CACtE,EACA,CACI,OAAQC,EACR,WAAY,aACZ,aAAc,CAAC,YAAY,CAC/B,EACA,CACI,OAAQC,EACR,WAAY,cACZ,aAAc,CAAC,WAAW,CAC9B,EACA,CACI,OAAQC,EACR,WAAY,QACZ,aAAc,CAAC,OAAQ,OAAQ,KAAK,CACxC,EACA,CACI,OAAQC,EACR,WAAY,aACZ,aAAc,CAAC,YAAY,CAC/B,CACJ,EAEIC,EAAwB,CAAC,EACvBC,EAA+B,CAAC,EAEhCC,EAA2D,CAAC,EAElEV,EAAO,QAASW,GAAW,CACvB,GAAM,CAAE,OAAAC,EAAQ,WAAAC,EAAY,aAAAC,CAAa,EAAIH,EAG7C,GAAKI,EAA0F,SAAYF,CAAU,IAAM,GAAO,CAC9H,IAAMG,EAAoB,CAAC,EAE3BF,EAAa,QAASG,GAAe,EAC7BnB,EA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config\";\nimport consoleLog from \"./utils/logger\";\n\n// Workaround VS Code trying to run this file twice!\nif (!global.hasAnolilabStagedLintConfigLoaded) {\n if (env[\"DEBUG\"]) {\n consoleLog(\"\\n@anolilab/lint-stage-config loaded the following plugins:\\n\");\n\n loadedPluginsNames.forEach((pluginName) => {\n consoleLog(` ${pluginName}`);\n });\n }\n\n let hasLogged = false;\n\n Object.entries(possiblePlugins).forEach(([plugin, dependencies]) => {\n const hasOneDependency = Object.values(dependencies).some(Boolean);\n\n if (hasOneDependency) {\n hasLogged = true;\n consoleLog(\n `\\nYour package.json container dependencies for the \"${plugin}\" plugin, please add the following dependencies with your chosen package manager to enable this plugin:`,\n );\n\n Object.entries(dependencies).forEach(([dependency, installed]) => {\n if (!installed) {\n consoleLog(` ${dependency}`);\n }\n });\n }\n });\n\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition\n if (hasLogged) {\n consoleLog(\"\\nTo disable this message, add the following to your package.json:\");\n consoleLog(' \"anolilab\": { \"lint-stage-config\": { plugin: { \"plugin-name\": false } } }\\n');\n }\n\n consoleLog('To disable all logging, add the following to your lint-staged command call \"NO_LOGS=true lint-staged ...\"');\n\n global.hasAnolilabStagedLintConfigLoaded = true;\n}\n\nexport { loadedPlugins as default } from \"./config\";\n","import { hasDependency, hasDevDependency } from \"@anolilab/package-json-utils\";\nimport type { Config } from \"lint-staged\";\n\nimport eslintConfig from \"./groups/eslint\";\nimport jsonConfig from \"./groups/json\";\nimport markdownConfig from \"./groups/markdown\";\nimport secretlintConfig from \"./groups/secretlint\";\nimport stylesheetsConfig from \"./groups/stylesheets\";\nimport testsConfig from \"./groups/tests\";\nimport typescriptConfig from \"./groups/typescript\";\nimport anolilabLintStagedConfig from \"./utils/lint-staged-config\";\n\ntype Groups = {\n config: Config;\n configName: string;\n dependencies: string[];\n}[];\n\nconst groups: Groups = [\n {\n config: eslintConfig,\n configName: \"eslint\",\n dependencies: [\"prettier\", \"eslint\"],\n },\n {\n config: jsonConfig,\n configName: \"json\",\n dependencies: [\"prettier\", \"sort-package-json\"],\n },\n {\n config: markdownConfig,\n configName: \"markdown\",\n dependencies: [\"prettier\", \"markdownlint-cli\", \"markdownlint-cli2\"],\n },\n {\n config: secretlintConfig,\n configName: \"secretlint\",\n dependencies: [\"secretlint\"],\n },\n {\n config: stylesheetsConfig,\n configName: \"stylesheets\",\n dependencies: [\"stylelint\"],\n },\n {\n config: testsConfig,\n configName: \"tests\",\n dependencies: [\"vite\", \"jest\", \"ava\"],\n },\n {\n config: typescriptConfig,\n configName: \"typescript\",\n dependencies: [\"typescript\"],\n },\n];\n\nlet loadedPlugins: Config = {};\nconst loadedPluginsNames: string[] = [];\n\nconst possiblePlugins: Record<string, Record<string, boolean>> = {};\n\ngroups.forEach((plugin) => {\n const { config, configName, dependencies } = plugin;\n\n // eslint-disable-next-line security/detect-object-injection\n if ((anolilabLintStagedConfig as unknown as Record<string, Record<string, false | undefined>>)[\"plugin\"]?.[configName] !== false) {\n const foundDependencies = [];\n\n dependencies.forEach((dependency) => {\n if (hasDependency(dependency) || hasDevDependency(dependency)) {\n foundDependencies.push(dependency);\n }\n });\n\n if (foundDependencies.length > 0) {\n loadedPlugins = { ...loadedPlugins, ...config };\n loadedPluginsNames.push(configName);\n } else {\n // eslint-disable-next-line security/detect-object-injection\n possiblePlugins[configName] = {};\n\n dependencies.forEach((dependency) => {\n // eslint-disable-next-line security/detect-object-injection\n (possiblePlugins[configName] as Record<string, boolean>)[dependency] = hasDependency(dependency) || hasDevDependency(dependency);\n });\n }\n }\n});\n\nconst loaded: Config = { ...loadedPlugins };\n\nexport { loaded as loadedPlugins, loadedPluginsNames, possiblePlugins };\n","import { env } from \"node:process\";\n\nconst noop = () => undefined;\n\nconst consolePrefix = (prefix: string) => (env[\"NO_LOGS\"] ? noop : (message: string) => console.log(`${prefix}${message}`));\n\nconst consoleLog = consolePrefix(\"\");\n\nexport default consoleLog;\n"]}
package/dist/index.mjs CHANGED
@@ -1,6 +1,6 @@
1
- import { a as a$7 } from './chunk-EMISBJRA.mjs';
2
- import { a as a$1, b } from './chunk-ORP5CV3J.mjs';
3
- import './chunk-WAVKF2WX.mjs';
1
+ import { a as a$7 } from './chunk-475NPYYW.mjs';
2
+ import { a as a$1, b } from './chunk-V5RHC5X7.mjs';
3
+ import './chunk-5L2ZI35J.mjs';
4
4
  import { a as a$2 } from './chunk-YBLR7X5F.mjs';
5
5
  import { a as a$3 } from './chunk-KNLP6LX4.mjs';
6
6
  import { a as a$4 } from './chunk-4RVIFLAT.mjs';
@@ -10,13 +10,13 @@ import './chunk-32WCNCA6.mjs';
10
10
  import { env } from 'process';
11
11
  import { hasDependency, hasDevDependency } from '@anolilab/package-json-utils';
12
12
 
13
- var N=[{config:b,configName:"eslint",dependencies:["prettier","eslint"]},{config:a$2,configName:"json",dependencies:["prettier","sort-package-json"]},{config:a$3,configName:"markdown",dependencies:["prettier","markdownlint-cli","markdownlint-cli2"]},{config:a$4,configName:"secretlint",dependencies:["secretlint"]},{config:a$5,configName:"stylesheets",dependencies:["stylelint"]},{config:a$6,configName:"tests",dependencies:["vite","jest","ava"]},{config:a$7,configName:"typescript",dependencies:["typescript"]}],g={},r=[],a={};N.forEach(s=>{let{config:o,configName:i,dependencies:l}=s;if(a$1.plugin?.[i]!==!1){let t=[];l.forEach(e=>{(hasDependency(e)||hasDevDependency(e))&&t.push(e);}),t.length>0?(g={...g,...o},r.push(i)):(a[i]={},l.forEach(e=>{a[i][e]=hasDependency(e)||hasDevDependency(e);}));}});var k={...g};var L=()=>{},j=s=>env.NO_LOGS?L:o=>console.log(`${s}${o}`),O=j(""),n=O;if(!global.hasAnolilabStagedLintConfigLoaded){env.DEBUG&&(n(`
13
+ var y=[{config:b,configName:"eslint",dependencies:["prettier","eslint"]},{config:a$2,configName:"json",dependencies:["prettier","sort-package-json"]},{config:a$3,configName:"markdown",dependencies:["prettier","markdownlint-cli","markdownlint-cli2"]},{config:a$4,configName:"secretlint",dependencies:["secretlint"]},{config:a$5,configName:"stylesheets",dependencies:["stylelint"]},{config:a$6,configName:"tests",dependencies:["vite","jest","ava"]},{config:a$7,configName:"typescript",dependencies:["typescript"]}],g={},r=[],a={};y.forEach(t=>{let{config:n,configName:i,dependencies:l}=t;if(a$1.plugin?.[i]!==!1){let s=[];l.forEach(e=>{(hasDependency(e)||hasDevDependency(e))&&s.push(e);}),s.length>0?(g={...g,...n},r.push(i)):(a[i]={},l.forEach(e=>{a[i][e]=hasDependency(e)||hasDevDependency(e);}));}});var w={...g};var j=()=>{},k=t=>env.NO_LOGS?j:n=>console.log(`${t}${n}`),O=k(""),o=O;if(!global.hasAnolilabStagedLintConfigLoaded){env.DEBUG&&(o(`
14
14
  @anolilab/lint-stage-config loaded the following plugins:
15
- `),r.forEach(o=>{n(` ${o}`);}));let s=!1;Object.entries(a).forEach(([o,i])=>{Object.values(i).some(Boolean)&&(s=!0,n(`
16
- Your package.json container dependencies for the "${o}" plugin, please add the following dependencies with your chosen package manager to enable this plugin:`),Object.entries(i).forEach(([t,e])=>{e||n(` ${t}`);}));}),s&&(n(`
17
- To disable this message, add the following to your package.json:`),n(` "anolilab": { "lint-stage-config": { plugin: { "plugin-name": false } } }
18
- `)),n('To disable all logging, add the following to your eslint command call "NO_LOGS=true eslint ..."'),global.hasAnolilabStagedLintConfigLoaded=!0;}
15
+ `),r.forEach(n=>{o(` ${n}`);}));let t=!1;Object.entries(a).forEach(([n,i])=>{Object.values(i).some(Boolean)&&(t=!0,o(`
16
+ Your package.json container dependencies for the "${n}" plugin, please add the following dependencies with your chosen package manager to enable this plugin:`),Object.entries(i).forEach(([s,e])=>{e||o(` ${s}`);}));}),t&&(o(`
17
+ To disable this message, add the following to your package.json:`),o(` "anolilab": { "lint-stage-config": { plugin: { "plugin-name": false } } }
18
+ `)),o('To disable all logging, add the following to your lint-staged command call "NO_LOGS=true lint-staged ..."'),global.hasAnolilabStagedLintConfigLoaded=!0;}
19
19
 
20
- export { k as default };
20
+ export { w as default };
21
21
  //# sourceMappingURL=out.js.map
22
22
  //# sourceMappingURL=index.mjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts","../src/config.ts","../src/utils/logger.ts"],"names":["env","hasDependency","hasDevDependency","groups","eslint_default","json_default","markdown_default","secretlint_default","stylesheets_default","tests_default","typescript_default","loadedPlugins","loadedPluginsNames","possiblePlugins","plugin","config","configName","dependencies","lint_staged_config_default","foundDependencies","dependency","loaded","noop","consolePrefix","prefix","message","consoleLog","logger_default","pluginName","hasLogged","installed"],"mappings":"gWAAA,OAAS,OAAAA,MAAW,UCApB,OAAS,iBAAAC,EAAe,oBAAAC,MAAwB,+BAkBhD,IAAMC,EAAiB,CACnB,CACI,OAAQC,EACR,WAAY,SACZ,aAAc,CAAC,WAAY,QAAQ,CACvC,EACA,CACI,OAAQC,EACR,WAAY,OACZ,aAAc,CAAC,WAAY,mBAAmB,CAClD,EACA,CACI,OAAQC,EACR,WAAY,WACZ,aAAc,CAAC,WAAY,mBAAoB,mBAAmB,CACtE,EACA,CACI,OAAQC,EACR,WAAY,aACZ,aAAc,CAAC,YAAY,CAC/B,EACA,CACI,OAAQC,EACR,WAAY,cACZ,aAAc,CAAC,WAAW,CAC9B,EACA,CACI,OAAQC,EACR,WAAY,QACZ,aAAc,CAAC,OAAQ,OAAQ,KAAK,CACxC,EACA,CACI,OAAQC,EACR,WAAY,aACZ,aAAc,CAAC,YAAY,CAC/B,CACJ,EAEIC,EAAwB,CAAC,EACvBC,EAA+B,CAAC,EAEhCC,EAA0E,CAAC,EAEjFV,EAAO,QAASW,GAAW,CACvB,GAAM,CAAE,OAAAC,EAAQ,WAAAC,EAAY,aAAAC,CAAa,EAAIH,EAG7C,GAAKI,EAAgG,SAAYF,CAAU,IAAM,GAAO,CACpI,IAAMG,EAAoB,CAAC,EAE3BF,EAAa,QAASG,GAAe,EAC7BnB,EAAcmB,CAAU,GAAKlB,EAAiBkB,CAAU,IACxDD,EAAkB,KAAKC,CAAU,CAEzC,CAAC,EAEGD,EAAkB,OAAS,GAC3BR,EAAgB,CAAE,GAAGA,EAAe,GAAGI,CAAO,EAC9CH,EAAmB,KAAKI,CAAU,IAGlCH,EAAgBG,CAAU,EAAI,CAAC,EAE/BC,EAAa,QAASG,GAAe,CAEhCP,EAAgBG,CAAU,EAAiCI,CAAU,EAAInB,EAAcmB,CAAU,GAAKlB,EAAiBkB,CAAU,CACtI,CAAC,EAET,CACJ,CAAC,EAED,IAAMC,EAAiB,CAAE,GAAGV,CAAc,ECzF1C,OAAS,OAAAX,MAAW,UAEpB,IAAMsB,EAAO,IAAG,GAEVC,EAAiBC,GAAoBxB,EAAI,QAAasB,EAAQG,GAAoB,QAAQ,IAAI,GAAGD,CAAM,GAAGC,CAAO,EAAE,EAEnHC,EAAaH,EAAc,EAAE,EAE5BI,EAAQD,EFFf,GAAI,CAAC,OAAO,kCAAmC,CACvC1B,EAAI,QACJ2B,EAAW;AAAA;AAAA,CAA+D,EAE1Ef,EAAmB,QAASgB,GAAe,CACvCD,EAAW,OAAOC,CAAU,EAAE,CAClC,CAAC,GAGL,IAAIC,EAAY,GAEhB,OAAO,QAAQhB,CAAe,EAAE,QAAQ,CAAC,CAACC,EAAQG,CAAY,IAAM,CACvC,OAAO,OAAOA,CAAY,EAAE,KAAK,OAAO,IAG7DY,EAAY,GACZF,EACI;AAAA,oDAAuDb,CAAM,yGACjE,EAEA,OAAO,QAAQG,CAAY,EAAE,QAAQ,CAAC,CAACG,EAAYU,CAAS,IAAM,CACzDA,GACDH,EAAW,OAAOP,CAAU,EAAE,CAEtC,CAAC,EAET,CAAC,EAGGS,IACAF,EAAW;AAAA,iEAAoE,EAC/EA,EAAW;AAAA,CAAiF,GAGhGA,EAAW,iGAAiG,EAE5G,OAAO,kCAAoC,EAC/C","sourcesContent":["import { env } from \"node:process\";\n\nimport { loadedPluginsNames, possiblePlugins } from \"./config\";\nimport consoleLog from \"./utils/logger\";\n\n// Workaround VS Code trying to run this file twice!\nif (!global.hasAnolilabStagedLintConfigLoaded) {\n if (env[\"DEBUG\"]) {\n consoleLog(\"\\n@anolilab/lint-stage-config loaded the following plugins:\\n\");\n\n loadedPluginsNames.forEach((pluginName) => {\n consoleLog(` ${pluginName}`);\n });\n }\n\n let hasLogged = false;\n\n Object.entries(possiblePlugins).forEach(([plugin, dependencies]) => {\n const hasOneDependency = Object.values(dependencies).some(Boolean);\n\n if (hasOneDependency) {\n hasLogged = true;\n consoleLog(\n `\\nYour package.json container dependencies for the \"${plugin}\" plugin, please add the following dependencies with your chosen package manager to enable this plugin:`,\n );\n\n Object.entries(dependencies).forEach(([dependency, installed]) => {\n if (!installed) {\n consoleLog(` ${dependency}`);\n }\n });\n }\n });\n\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition\n if (hasLogged) {\n consoleLog(\"\\nTo disable this message, add the following to your package.json:\");\n consoleLog(' \"anolilab\": { \"lint-stage-config\": { plugin: { \"plugin-name\": false } } }\\n');\n }\n\n consoleLog('To disable all logging, add the following to your eslint command call \"NO_LOGS=true eslint ...\"');\n\n global.hasAnolilabStagedLintConfigLoaded = true;\n}\n\nexport { loadedPlugins as default } from \"./config\";\n","import { hasDependency, hasDevDependency } from \"@anolilab/package-json-utils\";\nimport type { Config } from \"lint-staged\";\n\nimport eslintConfig from \"./groups/eslint\";\nimport jsonConfig from \"./groups/json\";\nimport markdownConfig from \"./groups/markdown\";\nimport secretlintConfig from \"./groups/secretlint\";\nimport stylesheetsConfig from \"./groups/stylesheets\";\nimport testsConfig from \"./groups/tests\";\nimport typescriptConfig from \"./groups/typescript\";\nimport anolilabLintStagedConfig from \"./utils/lint-staged-config\";\n\ntype Groups = {\n config: Config;\n configName: string;\n dependencies: string[];\n}[];\n\nconst groups: Groups = [\n {\n config: eslintConfig,\n configName: \"eslint\",\n dependencies: [\"prettier\", \"eslint\"],\n },\n {\n config: jsonConfig,\n configName: \"json\",\n dependencies: [\"prettier\", \"sort-package-json\"],\n },\n {\n config: markdownConfig,\n configName: \"markdown\",\n dependencies: [\"prettier\", \"markdownlint-cli\", \"markdownlint-cli2\"],\n },\n {\n config: secretlintConfig,\n configName: \"secretlint\",\n dependencies: [\"secretlint\"],\n },\n {\n config: stylesheetsConfig,\n configName: \"stylesheets\",\n dependencies: [\"stylelint\"],\n },\n {\n config: testsConfig,\n configName: \"tests\",\n dependencies: [\"vite\", \"jest\", \"ava\"],\n },\n {\n config: typescriptConfig,\n configName: \"typescript\",\n dependencies: [\"typescript\"],\n },\n];\n\nlet loadedPlugins: Config = {};\nconst loadedPluginsNames: string[] = [];\n\nconst possiblePlugins: { [rule: string]: { [packageName: string]: boolean } } = {};\n\ngroups.forEach((plugin) => {\n const { config, configName, dependencies } = plugin;\n\n // eslint-disable-next-line security/detect-object-injection\n if ((anolilabLintStagedConfig as unknown as { [key: string]: { [key: string]: false | undefined } })[\"plugin\"]?.[configName] !== false) {\n const foundDependencies = [];\n\n dependencies.forEach((dependency) => {\n if (hasDependency(dependency) || hasDevDependency(dependency)) {\n foundDependencies.push(dependency);\n }\n });\n\n if (foundDependencies.length > 0) {\n loadedPlugins = { ...loadedPlugins, ...config };\n loadedPluginsNames.push(configName);\n } else {\n // eslint-disable-next-line security/detect-object-injection\n possiblePlugins[configName] = {};\n\n dependencies.forEach((dependency) => {\n // eslint-disable-next-line security/detect-object-injection\n (possiblePlugins[configName] as { [key: string]: boolean })[dependency] = hasDependency(dependency) || hasDevDependency(dependency);\n });\n }\n }\n});\n\nconst loaded: Config = { ...loadedPlugins };\n\nexport { loaded as loadedPlugins, loadedPluginsNames, possiblePlugins };\n","import { env } from \"node:process\";\n\nconst noop = () => undefined;\n\nconst consolePrefix = (prefix: string) => (env[\"NO_LOGS\"] ? noop : (message: string) => console.log(`${prefix}${message}`));\n\nconst consoleLog = consolePrefix(\"\");\n\nexport default consoleLog;\n"]}
1
+ {"version":3,"sources":["../src/index.ts","../src/config.ts","../src/utils/logger.ts"],"names":["env","hasDependency","hasDevDependency","groups","eslint_default","json_default","markdown_default","secretlint_default","stylesheets_default","tests_default","typescript_default","loadedPlugins","loadedPluginsNames","possiblePlugins","plugin","config","configName","dependencies","lint_staged_config_default","foundDependencies","dependency","loaded","noop","consolePrefix","prefix","message","consoleLog","logger_default","pluginName","hasLogged","installed"],"mappings":"gWAAA,OAAS,OAAAA,MAAW,UCApB,OAAS,iBAAAC,EAAe,oBAAAC,MAAwB,+BAkBhD,IAAMC,EAAiB,CACnB,CACI,OAAQC,EACR,WAAY,SACZ,aAAc,CAAC,WAAY,QAAQ,CACvC,EACA,CACI,OAAQC,EACR,WAAY,OACZ,aAAc,CAAC,WAAY,mBAAmB,CAClD,EACA,CACI,OAAQC,EACR,WAAY,WACZ,aAAc,CAAC,WAAY,mBAAoB,mBAAmB,CACtE,EACA,CACI,OAAQC,EACR,WAAY,aACZ,aAAc,CAAC,YAAY,CAC/B,EACA,CACI,OAAQC,EACR,WAAY,cACZ,aAAc,CAAC,WAAW,CAC9B,EACA,CACI,OAAQC,EACR,WAAY,QACZ,aAAc,CAAC,OAAQ,OAAQ,KAAK,CACxC,EACA,CACI,OAAQC,EACR,WAAY,aACZ,aAAc,CAAC,YAAY,CAC/B,CACJ,EAEIC,EAAwB,CAAC,EACvBC,EAA+B,CAAC,EAEhCC,EAA2D,CAAC,EAElEV,EAAO,QAASW,GAAW,CACvB,GAAM,CAAE,OAAAC,EAAQ,WAAAC,EAAY,aAAAC,CAAa,EAAIH,EAG7C,GAAKI,EAA0F,SAAYF,CAAU,IAAM,GAAO,CAC9H,IAAMG,EAAoB,CAAC,EAE3BF,EAAa,QAASG,GAAe,EAC7BnB,EAAcmB,CAAU,GAAKlB,EAAiBkB,CAAU,IACxDD,EAAkB,KAAKC,CAAU,CAEzC,CAAC,EAEGD,EAAkB,OAAS,GAC3BR,EAAgB,CAAE,GAAGA,EAAe,GAAGI,CAAO,EAC9CH,EAAmB,KAAKI,CAAU,IAGlCH,EAAgBG,CAAU,EAAI,CAAC,EAE/BC,EAAa,QAASG,GAAe,CAEhCP,EAAgBG,CAAU,EAA8BI,CAAU,EAAInB,EAAcmB,CAAU,GAAKlB,EAAiBkB,CAAU,CACnI,CAAC,EAET,CACJ,CAAC,EAED,IAAMC,EAAiB,CAAE,GAAGV,CAAc,ECzF1C,OAAS,OAAAX,MAAW,UAEpB,IAAMsB,EAAO,IAAG,GAEVC,EAAiBC,GAAoBxB,EAAI,QAAasB,EAAQG,GAAoB,QAAQ,IAAI,GAAGD,CAAM,GAAGC,CAAO,EAAE,EAEnHC,EAAaH,EAAc,EAAE,EAE5BI,EAAQD,EFFf,GAAI,CAAC,OAAO,kCAAmC,CACvC1B,EAAI,QACJ2B,EAAW;AAAA;AAAA,CAA+D,EAE1Ef,EAAmB,QAASgB,GAAe,CACvCD,EAAW,OAAOC,CAAU,EAAE,CAClC,CAAC,GAGL,IAAIC,EAAY,GAEhB,OAAO,QAAQhB,CAAe,EAAE,QAAQ,CAAC,CAACC,EAAQG,CAAY,IAAM,CACvC,OAAO,OAAOA,CAAY,EAAE,KAAK,OAAO,IAG7DY,EAAY,GACZF,EACI;AAAA,oDAAuDb,CAAM,yGACjE,EAEA,OAAO,QAAQG,CAAY,EAAE,QAAQ,CAAC,CAACG,EAAYU,CAAS,IAAM,CACzDA,GACDH,EAAW,OAAOP,CAAU,EAAE,CAEtC,CAAC,EAET,CAAC,EAGGS,IACAF,EAAW;AAAA,iEAAoE,EAC/EA,EAAW;AAAA,CAAiF,GAGhGA,EAAW,2GAA2G,EAEtH,OAAO,kCAAoC,EAC/C","sourcesContent":["import { env } from \"node:process\";\n\nimport { loadedPluginsNames, possiblePlugins } from \"./config\";\nimport consoleLog from \"./utils/logger\";\n\n// Workaround VS Code trying to run this file twice!\nif (!global.hasAnolilabStagedLintConfigLoaded) {\n if (env[\"DEBUG\"]) {\n consoleLog(\"\\n@anolilab/lint-stage-config loaded the following plugins:\\n\");\n\n loadedPluginsNames.forEach((pluginName) => {\n consoleLog(` ${pluginName}`);\n });\n }\n\n let hasLogged = false;\n\n Object.entries(possiblePlugins).forEach(([plugin, dependencies]) => {\n const hasOneDependency = Object.values(dependencies).some(Boolean);\n\n if (hasOneDependency) {\n hasLogged = true;\n consoleLog(\n `\\nYour package.json container dependencies for the \"${plugin}\" plugin, please add the following dependencies with your chosen package manager to enable this plugin:`,\n );\n\n Object.entries(dependencies).forEach(([dependency, installed]) => {\n if (!installed) {\n consoleLog(` ${dependency}`);\n }\n });\n }\n });\n\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition\n if (hasLogged) {\n consoleLog(\"\\nTo disable this message, add the following to your package.json:\");\n consoleLog(' \"anolilab\": { \"lint-stage-config\": { plugin: { \"plugin-name\": false } } }\\n');\n }\n\n consoleLog('To disable all logging, add the following to your lint-staged command call \"NO_LOGS=true lint-staged ...\"');\n\n global.hasAnolilabStagedLintConfigLoaded = true;\n}\n\nexport { loadedPlugins as default } from \"./config\";\n","import { hasDependency, hasDevDependency } from \"@anolilab/package-json-utils\";\nimport type { Config } from \"lint-staged\";\n\nimport eslintConfig from \"./groups/eslint\";\nimport jsonConfig from \"./groups/json\";\nimport markdownConfig from \"./groups/markdown\";\nimport secretlintConfig from \"./groups/secretlint\";\nimport stylesheetsConfig from \"./groups/stylesheets\";\nimport testsConfig from \"./groups/tests\";\nimport typescriptConfig from \"./groups/typescript\";\nimport anolilabLintStagedConfig from \"./utils/lint-staged-config\";\n\ntype Groups = {\n config: Config;\n configName: string;\n dependencies: string[];\n}[];\n\nconst groups: Groups = [\n {\n config: eslintConfig,\n configName: \"eslint\",\n dependencies: [\"prettier\", \"eslint\"],\n },\n {\n config: jsonConfig,\n configName: \"json\",\n dependencies: [\"prettier\", \"sort-package-json\"],\n },\n {\n config: markdownConfig,\n configName: \"markdown\",\n dependencies: [\"prettier\", \"markdownlint-cli\", \"markdownlint-cli2\"],\n },\n {\n config: secretlintConfig,\n configName: \"secretlint\",\n dependencies: [\"secretlint\"],\n },\n {\n config: stylesheetsConfig,\n configName: \"stylesheets\",\n dependencies: [\"stylelint\"],\n },\n {\n config: testsConfig,\n configName: \"tests\",\n dependencies: [\"vite\", \"jest\", \"ava\"],\n },\n {\n config: typescriptConfig,\n configName: \"typescript\",\n dependencies: [\"typescript\"],\n },\n];\n\nlet loadedPlugins: Config = {};\nconst loadedPluginsNames: string[] = [];\n\nconst possiblePlugins: Record<string, Record<string, boolean>> = {};\n\ngroups.forEach((plugin) => {\n const { config, configName, dependencies } = plugin;\n\n // eslint-disable-next-line security/detect-object-injection\n if ((anolilabLintStagedConfig as unknown as Record<string, Record<string, false | undefined>>)[\"plugin\"]?.[configName] !== false) {\n const foundDependencies = [];\n\n dependencies.forEach((dependency) => {\n if (hasDependency(dependency) || hasDevDependency(dependency)) {\n foundDependencies.push(dependency);\n }\n });\n\n if (foundDependencies.length > 0) {\n loadedPlugins = { ...loadedPlugins, ...config };\n loadedPluginsNames.push(configName);\n } else {\n // eslint-disable-next-line security/detect-object-injection\n possiblePlugins[configName] = {};\n\n dependencies.forEach((dependency) => {\n // eslint-disable-next-line security/detect-object-injection\n (possiblePlugins[configName] as Record<string, boolean>)[dependency] = hasDependency(dependency) || hasDevDependency(dependency);\n });\n }\n }\n});\n\nconst loaded: Config = { ...loadedPlugins };\n\nexport { loaded as loadedPlugins, loadedPluginsNames, possiblePlugins };\n","import { env } from \"node:process\";\n\nconst noop = () => undefined;\n\nconst consolePrefix = (prefix: string) => (env[\"NO_LOGS\"] ? noop : (message: string) => console.log(`${prefix}${message}`));\n\nconst consoleLog = consolePrefix(\"\");\n\nexport default consoleLog;\n"]}
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- var chunkB7BKRXC3_js = require('./chunk-B7BKRXC3.js');
3
+ var chunkMUEXM65V_js = require('./chunk-MUEXM65V.js');
4
4
  var packageJsonUtils = require('@anolilab/package-json-utils');
5
5
  var fs = require('fs');
6
6
  var path = require('path');
@@ -35,7 +35,7 @@ if [ "$IS_WINDOWS" = "true" ]; then
35
35
  exec < /dev/tty
36
36
  fi
37
37
  fi
38
- `,"utf-8");let h=path.join(o,"pre-commit"),e=!1;try{chunkB7BKRXC3_js.a("pnpm-lock.yaml"),e=!0;}catch{e=!1;}c(h)||await a(h,`#!/bin/sh
38
+ `,"utf-8");let h=path.join(o,"pre-commit"),e=!1;try{chunkMUEXM65V_js.a("pnpm-lock.yaml"),e=!0;}catch{e=!1;}c(h)||await a(h,`#!/bin/sh
39
39
 
40
40
  . "$(dirname "$0")/_/husky.sh"
41
41
  . "$(dirname "$0")/common.sh"
@@ -1,4 +1,4 @@
1
- import { a as a$1 } from './chunk-WAVKF2WX.mjs';
1
+ import { a as a$1 } from './chunk-5L2ZI35J.mjs';
2
2
  import { projectPath, packageIsTypeModule, hasDependency, hasDevDependency } from '@anolilab/package-json-utils';
3
3
  import { writeFile, mkdir, existsSync } from 'fs';
4
4
  import { join } from 'path';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@anolilab/lint-staged-config",
3
- "version": "1.1.2",
3
+ "version": "2.0.1",
4
4
  "description": "Shareable Lint-Staged Config for any project.",
5
5
  "keywords": [
6
6
  "anolilab",
@@ -93,40 +93,40 @@
93
93
  "test:coverage": "vitest --config ./vitest.config.ts --run --coverage"
94
94
  },
95
95
  "dependencies": {
96
- "@anolilab/package-json-utils": "2.0.1",
96
+ "@anolilab/package-json-utils": "3.0.1",
97
97
  "cross-env": "^7.0.3",
98
98
  "find-up": "5.0.0",
99
99
  "shell-quote": "^1.8.1"
100
100
  },
101
101
  "devDependencies": {
102
- "@anolilab/semantic-release-preset": "5.0.1",
102
+ "@anolilab/semantic-release-preset": "6.0.1",
103
103
  "@total-typescript/ts-reset": "^0.4.2",
104
104
  "@types/lint-staged": "^13.2.0",
105
105
  "@types/shell-quote": "^1.7.1",
106
- "@vitest/coverage-v8": "^0.32.4",
106
+ "@vitest/coverage-v8": "^0.33.0",
107
107
  "husky": "^8.0.3",
108
108
  "lint-staged": "^13.2.3",
109
109
  "rimraf": "^5.0.1",
110
- "semantic-release": "^21.0.6",
110
+ "semantic-release": "^21.0.7",
111
111
  "tsup": "^7.1.0",
112
- "type-fest": "^3.12.0",
112
+ "type-fest": "^4.0.0",
113
113
  "typescript": "5.1.6",
114
- "vitest": "^0.32.4"
114
+ "vitest": "^0.33.0"
115
115
  },
116
116
  "peerDependencies": {
117
117
  "husky": "^8.x",
118
118
  "lint-staged": "^13.x"
119
119
  },
120
120
  "optionalDependencies": {
121
- "eslint": "^8.44.0",
122
- "jest": "^29.5.0",
123
- "prettier": "^2.8.8",
124
- "secretlint": "^7.0.2",
125
- "stylelint": "^15.9.0",
126
- "vite": "^4.3.9"
121
+ "eslint": "^8.45.0",
122
+ "jest": "^29.6.1",
123
+ "prettier": "^3.0.0",
124
+ "secretlint": "^7.0.3",
125
+ "stylelint": "^15.10.1",
126
+ "vite": "^4.4.4"
127
127
  },
128
128
  "engines": {
129
- "node": ">=16"
129
+ "node": ">=18"
130
130
  },
131
131
  "publishConfig": {
132
132
  "access": "public",
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/utils/get-nearest-config-path.ts"],"names":["findUp","existsSync","dirname","join","packageDirectorySync","cwd","filePath","getNearestPackageRootPath","packageDirectoryPath","joinPaths","paths","joined","getNearestConfigPath","fileName","packageRootPath","configPath","get_nearest_config_path_default"],"mappings":"AAAA,OAAOA,MAAY,UACnB,OAAS,cAAAC,MAAkB,KAC3B,OAAS,WAAAC,EAAS,QAAAC,MAAY,OAG9B,IAAMC,EAAwBC,GAAiB,CAC3C,IAAMC,EAAWN,EAAO,KAAK,eAAgB,CAAE,IAAAK,CAAI,CAAC,EAEpD,OAAOC,GAAYJ,EAAQI,CAAQ,CACvC,EAEMC,EAA6BF,GAA+B,CAC9D,IAAMG,EAAuBJ,EAAqBC,GAAO,QAAQ,IAAI,CAAC,EAEtE,GAAIG,GAAsB,WAAW,GAAG,EACpC,OAAOA,EAGX,MAAM,IAAI,MAAM,kEAAkEH,CAAG,GAAG,CAC5F,EAEMI,EAA8CC,GAA2B,CAC3E,IAAMC,EAASR,EAAK,GAAGO,CAAK,EAE5B,GAAIC,EAAO,WAAW,GAAG,EACrB,OAAOA,EAGX,MAAM,IAAI,UAAU,8CAA8C,CACtE,EAEMC,EAAuB,CAAkEC,EAAaR,IAA8B,CACtI,IAAMS,EAAkBP,EAA0BF,CAAG,EAC/CU,EAAaN,EAAkB,CAACK,EAAsBD,CAAQ,CAAC,EAGrE,GAAIZ,EAAWc,CAAU,EACrB,OAAOA,EAGX,MAAM,IAAI,MAAM,0BAA0BF,CAAQ,SAAS,CAC/D,EAMOG,EAAQJ","sourcesContent":["import findUp from \"find-up\";\nimport { existsSync } from \"node:fs\";\nimport { dirname, join } from \"node:path\";\nimport type { Join } from \"type-fest\";\n\nconst packageDirectorySync = (cwd?: string) => {\n const filePath = findUp.sync(\"package.json\", { cwd });\n\n return filePath && dirname(filePath);\n};\n\nconst getNearestPackageRootPath = (cwd?: string): AbsolutePath => {\n const packageDirectoryPath = packageDirectorySync(cwd ?? process.cwd());\n\n if (packageDirectoryPath?.startsWith(\"/\")) {\n return packageDirectoryPath as AbsolutePath;\n }\n\n throw new Error(`Cannot determine the nearest root of the package for the file: ${cwd}!`);\n};\n\nconst joinPaths = <T extends ReadonlyArray<string>>(paths: T): Join<T, \"/\"> => {\n const joined = join(...paths);\n\n if (joined.startsWith(\"/\")) {\n return joined as Join<T, \"/\">;\n }\n\n throw new TypeError(`Joined path did not return an absolute path.`);\n};\n\nconst getNearestConfigPath = <N extends ConfigFileName, A extends AbsolutePath = AbsolutePath>(fileName: N, cwd?: A): ConfigPath<A, N> => {\n const packageRootPath = getNearestPackageRootPath(cwd);\n const configPath = joinPaths<[A, N]>([packageRootPath as A, fileName]);\n\n // eslint-disable-next-line security/detect-non-literal-fs-filename\n if (existsSync(configPath)) {\n return configPath;\n }\n\n throw new Error(`Cannot locate nearest \"${fileName}\" file!`);\n};\n\nexport type AbsolutePath = `/${string}`;\nexport type ConfigFileName = string;\nexport type ConfigPath<A extends AbsolutePath, N extends ConfigFileName> = Join<[A, N], \"/\">;\n\nexport default getNearestConfigPath;\n"]}
@@ -1,8 +0,0 @@
1
- import { a } from './chunk-WAVKF2WX.mjs';
2
- import { env } from 'process';
3
-
4
- var i={[`**/*.{${["ts","mts","cts"].join(",")}}`]:n=>{let o=new Set;return n.forEach(s=>{try{let t=a("tsconfig.json",s);o.add(`tsc --noEmit --project ${t}`);}catch(t){env.DEBUG&&console.error(t);}}),[...o]}},f=i;
5
-
6
- export { f as a };
7
- //# sourceMappingURL=out.js.map
8
- //# sourceMappingURL=chunk-EMISBJRA.mjs.map
@@ -1,10 +0,0 @@
1
- 'use strict';
2
-
3
- var chunkB7BKRXC3_js = require('./chunk-B7BKRXC3.js');
4
- var process = require('process');
5
-
6
- var i={[`**/*.{${["ts","mts","cts"].join(",")}}`]:n=>{let o=new Set;return n.forEach(s=>{try{let t=chunkB7BKRXC3_js.a("tsconfig.json",s);o.add(`tsc --noEmit --project ${t}`);}catch(t){process.env.DEBUG&&console.error(t);}}),[...o]}},f=i;
7
-
8
- exports.a = f;
9
- //# sourceMappingURL=out.js.map
10
- //# sourceMappingURL=chunk-NQXBNZPO.js.map
@@ -1,12 +0,0 @@
1
- import { a } from './chunk-WAVKF2WX.mjs';
2
- import { b, a as a$1 } from './chunk-32WCNCA6.mjs';
3
- import { pkg, hasDependency, hasDevDependency } from '@anolilab/package-json-utils';
4
- import { dirname } from 'path';
5
- import { ESLint } from 'eslint';
6
- import { quote } from 'shell-quote';
7
-
8
- !global.anolilabLintStagedPackageJsonConfig&&pkg&&(global.anolilabLintStagedPackageJsonConfig=pkg.anolilab?.["lint-staged-config"]);var $=global.anolilabLintStagedPackageJsonConfig??{},u=$;var k=n=>{let t={};return n.forEach(s=>{let i=dirname(s);t[i]||(t[i]=[]),t[i].push(s);}),t},p=k;var F=async n=>{let t=new ESLint,s=await Promise.all(n.map(async o=>await t.isPathIgnored(o)));return n.filter((o,a)=>!s[a]).map(o=>`"${a$1?o:quote([o])}"`)},h=F;var e=u.settings.eslint??{},y=["react-hooks/exhaustive-deps: off"],r=".eslintrc",A=()=>{let n=[];e?.["max-warnings"]!==void 0&&Number.isNaN(e["max-warnings"])?n.push(`--max-warnings=${e["max-warnings"]}`):e?.["max-warnings"]!==!1&&n.push("--max-warnings=0");let t=[];e?.rules!==void 0&&Array.isArray(e.rules)?t.push([...e.rules,...y].filter(i=>i.trim().length>0).map(i=>`"${i.trim()}"`)):t.push(y.map(i=>`"${i.trim()}"`)),t.length>0&&n.push(`--rule ${t.join(" --rule ")}`);let s=[...e?.["fix-type"]??["layout"]].filter(i=>i.trim().length>0);return s.length>0&&n.push(`--fix-type ${s.join(",")}`,"--fix"),e?.cache&&n.push("--cache"),n},E=async n=>{let t=await h(n),s=A();if(e?.config)return s.push(`--config ${e.config}`),[`cross-env NO_LOGS=true eslint ${s.join(" ")} ${t.join(" ")}`];let i=p(t),o=[];return Object.values(i).forEach(a$1=>{let l;[r,`${r}.js`,`${r}.cjs`,`${r}.json`,`${r}.yaml`,`${r}.yml`].forEach(S=>{if(!l)try{l=a(S,a$1[0]);}catch{}}),l&&o.push(`cross-env NO_LOGS=true eslint ${s.join(" ")} --config ${l} ${a$1.join(" ")}`);}),o},g=E;var x=["cjs","js","mjs","cts","ts","mts","yml","yaml","jsx","tsx","mdx","toml"];global.hasAnolilabLintStagedMarkdownCli||(global.hasAnolilabLintStagedMarkdownCli=hasDependency("markdownlint-cli")||hasDevDependency("markdownlint-cli"));global.hasAnolilabLintStagedMarkdownCli2||(global.hasAnolilabLintStagedMarkdownCli2=hasDependency("markdownlint-cli2")||hasDevDependency("markdownlint-cli2"));!global.hasAnolilabLintStagedMarkdownCli&&!global.hasAnolilabLintStagedMarkdownCli2&&x.push("md");var N={[`**/*.{${["json","json5","jsonc"].join(",")}}`]:async n=>[...await g(n)],[`**/*.{${[x].join(",")}}`]:async n=>[`prettier --write ${b(n)}`,...await g(n)]},K=N;
9
-
10
- export { u as a, K as b };
11
- //# sourceMappingURL=out.js.map
12
- //# sourceMappingURL=chunk-ORP5CV3J.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/groups/eslint/index.ts","../src/utils/lint-staged-config.ts","../src/groups/eslint/group-file-paths-by-directory-name.ts","../src/groups/eslint/remove-ignored-files.ts","../src/groups/eslint/create-eslint-commands.ts"],"names":["hasDependency","hasDevDependency","pkg","config","lint_staged_config_default","dirname","groupFilePathsByDirectoryName","filePaths","groups","filePath","directoryName","group_file_paths_by_directory_name_default","ESLint","quote","removeIgnoredFiles","filenames","eslint","ignoredFiles","filename","_","index","is_windows_default","remove_ignored_files_default","eslintSettings","eslintGlobalRulesForFix","configFile","createEslintArguments","eslintArguments","rules","rule","r","fixType","type","createEslintCommands","filteredFiles","groupedFilesNames","eslintCommands","configName","get_nearest_config_path_default","create_eslint_commands_default","extensions","group","concat_files_default","eslint_default"],"mappings":"yFAAA,OAAS,iBAAAA,EAAe,oBAAAC,MAAwB,+BCAhD,OAAS,OAAAC,MAAW,+BAEhB,CAAC,OAAO,qCAAuCA,IAE/C,OAAO,oCAAsCA,EAAI,WAAc,oBAAoB,GAGvF,IAAMC,EAAiD,OAAO,qCAAuC,CAAC,EAE/FC,EAAQD,ECTf,OAAS,WAAAE,MAAe,OAExB,IAAMC,EAAiCC,GAAqD,CACxF,IAAMC,EAAsC,CAAC,EAE7C,OAAAD,EAAU,QAASE,GAAa,CAC5B,IAAMC,EAAgBL,EAAQI,CAAQ,EAGjCD,EAAOE,CAAa,IAErBF,EAAOE,CAAa,EAAI,CAAC,GAG5BF,EAAOE,CAAa,EAAe,KAAKD,CAAQ,CACrD,CAAC,EAEMD,CACX,EAEOG,EAAQL,ECnBf,OAAS,UAAAM,MAAc,SACvB,OAAS,SAAAC,MAAa,cAItB,IAAMC,EAAqB,MAAOC,GAA2C,CACzE,IAAMC,EAAS,IAAIJ,EAEbK,EAAe,MAAM,QAAQ,IAAIF,EAAU,IAAI,MAAOG,GAAa,MAAMF,EAAO,cAAcE,CAAQ,CAAC,CAAC,EAI9G,OAFsBH,EAAU,OAAO,CAACI,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,GAAwB,CACjE,oBAAoB2B,EAAY3B,CAAS,CAAC,GAC1C,GAAI,MAAMwB,EAAqBxB,CAAS,CAC5C,CACJ,EAEO4B,EAAQF","sourcesContent":["import { hasDependency, hasDevDependency } from \"@anolilab/package-json-utils\";\nimport type { Config } from \"lint-staged\";\n\nimport concatFiles from \"../../utils/concat-files\";\nimport createEslintCommands from \"./create-eslint-commands\";\n\nconst extensions = [\"cjs\", \"js\", \"mjs\", \"cts\", \"ts\", \"mts\", \"yml\", \"yaml\", \"jsx\", \"tsx\", \"mdx\", \"toml\"];\n\nif (!global.hasAnolilabLintStagedMarkdownCli) {\n global.hasAnolilabLintStagedMarkdownCli = hasDependency(\"markdownlint-cli\") || hasDevDependency(\"markdownlint-cli\");\n}\n\nif (!global.hasAnolilabLintStagedMarkdownCli2) {\n global.hasAnolilabLintStagedMarkdownCli2 = hasDependency(\"markdownlint-cli2\") || hasDevDependency(\"markdownlint-cli2\");\n}\n\nif (!global.hasAnolilabLintStagedMarkdownCli && !global.hasAnolilabLintStagedMarkdownCli2) {\n extensions.push(\"md\");\n}\n\nconst group: Config = {\n [`**/*.{${[\"json\", \"json5\", \"jsonc\"].join(\",\")}}`]: async (filenames: string[]) => [...(await createEslintCommands(filenames))],\n [`**/*.{${[extensions].join(\",\")}}`]: async (filenames: string[]) => [\n `prettier --write ${concatFiles(filenames)}`,\n ...(await createEslintCommands(filenames)),\n ],\n};\n\nexport default group;\n","import { pkg } from \"@anolilab/package-json-utils\";\n\nif (!global.anolilabLintStagedPackageJsonConfig && pkg) {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment,@typescript-eslint/no-unsafe-member-access\n global.anolilabLintStagedPackageJsonConfig = pkg[\"anolilab\"]?.[\"lint-staged-config\"];\n}\n\nconst config: { [key: string]: boolean | undefined } = global.anolilabLintStagedPackageJsonConfig ?? {};\n\nexport default config;\n","import { dirname } from \"node:path\";\n\nconst groupFilePathsByDirectoryName = (filePaths: string[]): { [key: string]: string[] } => {\n const groups: { [key: string]: string[] } = {};\n\n filePaths.forEach((filePath) => {\n const directoryName = dirname(filePath);\n\n // eslint-disable-next-line security/detect-object-injection\n if (!groups[directoryName]) {\n // eslint-disable-next-line security/detect-object-injection\n groups[directoryName] = [];\n }\n // eslint-disable-next-line security/detect-object-injection\n (groups[directoryName] as string[]).push(filePath);\n });\n\n return groups;\n};\n\nexport default groupFilePathsByDirectoryName;\n","// eslint-disable-next-line import/no-extraneous-dependencies\nimport { ESLint } from \"eslint\";\nimport { quote } from \"shell-quote\";\n\nimport isWindows from \"../../utils/is-windows\";\n\nconst removeIgnoredFiles = async (filenames: string[]): Promise<string[]> => {\n const eslint = new ESLint();\n // eslint-disable-next-line compat/compat\n const ignoredFiles = await Promise.all(filenames.map(async (filename) => await eslint.isPathIgnored(filename)));\n // eslint-disable-next-line security/detect-object-injection\n const filteredFiles = filenames.filter((_, index) => !ignoredFiles[index]);\n\n return filteredFiles.map((filename) => `\"${isWindows ? filename : quote([filename])}\"`);\n};\n\nexport default removeIgnoredFiles;\n","import getNearestConfigPath from \"../../utils/get-nearest-config-path\";\nimport anolilabLintStagedConfig from \"../../utils/lint-staged-config\";\nimport groupFilePathsByDirectoryName from \"./group-file-paths-by-directory-name\";\nimport removeIgnoredFiles from \"./remove-ignored-files\";\n\ntype ESLintSettings = {\n settings: {\n eslint?: {\n cache?: boolean;\n config?: string;\n \"fix-type\": string[];\n \"max-warnings\"?: number | string | false;\n rules?: string[];\n };\n };\n};\n\nconst eslintSettings: ESLintSettings[\"settings\"][\"eslint\"] =\n (anolilabLintStagedConfig as unknown as ESLintSettings).settings.eslint ?? ({} as ESLintSettings[\"settings\"][\"eslint\"]);\n\nconst eslintGlobalRulesForFix = [\n // react-hooks/eslint and react in general is very strict about exhaustively\n // declaring the dependencies when using the useEffect, useCallback... hooks.\n //\n // In some specific scenarios declaring the deps seems 'less' wanted or 'less' applicable\n // by the developer, leading to some exceptions in the code. That said it should be avoided.\n //\n // While the 'react-hooks/exhaustive-deps' rule is a good rule of thumb, it's not recommended to\n // automatically fix it from lint-staged as it can potentially break a legit intent.\n //\n // Reminder that a good practice is to always declare the dependencies when using the hooks,\n // and if not applicable, add an eslint disable comment to the useEffect, useCallback... such as:\n //\n // // eslint-disable-next-line react-hooks/exhaustive-deps\n //\n // Another approach can be to use hooks such as https://github.com/kentcdodds/use-deep-compare-effect to quickly bypass\n // shallow rendering limitations.\n //\n // @see https://reactjs.org/docs/hooks-rules.html\n // @see https://eslint.org/docs/2.13.1/user-guide/configuring#disabling-rules-with-inline-comments\n \"react-hooks/exhaustive-deps: off\",\n];\n\nconst configFile = \".eslintrc\";\n\nconst createEslintArguments = (): string[] => {\n const eslintArguments: string[] = [];\n\n if (eslintSettings?.[\"max-warnings\"] !== undefined && Number.isNaN(eslintSettings[\"max-warnings\"])) {\n eslintArguments.push(`--max-warnings=${eslintSettings[\"max-warnings\"]}`);\n } else if (eslintSettings?.[\"max-warnings\"] !== false) {\n eslintArguments.push(\"--max-warnings=0\");\n }\n\n const rules = [];\n\n if (eslintSettings?.rules !== undefined && Array.isArray(eslintSettings.rules)) {\n rules.push([...eslintSettings.rules, ...eslintGlobalRulesForFix].filter((rule) => rule.trim().length > 0).map((r) => `\"${r.trim()}\"`));\n } else {\n rules.push(eslintGlobalRulesForFix.map((r) => `\"${r.trim()}\"`));\n }\n\n if (rules.length > 0) {\n eslintArguments.push(`--rule ${rules.join(\" --rule \")}`);\n }\n\n // For lint-staged it's safer to not apply the fix command if it changes the AST\n // @see https://eslint.org/docs/user-guide/command-line-interface#--fix-type\n const fixType = [...(eslintSettings?.[\"fix-type\"] ?? [\"layout\"])].filter((type) => type.trim().length > 0);\n\n if (fixType.length > 0) {\n eslintArguments.push(`--fix-type ${fixType.join(\",\")}`, \"--fix\");\n }\n\n if (eslintSettings?.cache) {\n eslintArguments.push(\"--cache\");\n }\n\n return eslintArguments;\n};\n\nconst createEslintCommands = async (filenames: string[]): Promise<string[]> => {\n const filteredFiles = await removeIgnoredFiles(filenames);\n\n const eslintArguments = createEslintArguments();\n\n if (eslintSettings?.config) {\n eslintArguments.push(`--config ${eslintSettings.config}`);\n\n return [`cross-env NO_LOGS=true eslint ${eslintArguments.join(\" \")} ${filteredFiles.join(\" \")}`];\n }\n\n const groupedFilesNames = groupFilePathsByDirectoryName(filteredFiles);\n const eslintCommands: string[] = [];\n\n Object.values(groupedFilesNames).forEach((filePaths) => {\n let config: string | undefined;\n\n [configFile, `${configFile}.js`, `${configFile}.cjs`, `${configFile}.json`, `${configFile}.yaml`, `${configFile}.yml`].forEach((configName) => {\n if (config) {\n return;\n }\n\n try {\n // eslint-disable-next-line no-template-curly-in-string\n config = getNearestConfigPath(configName, filePaths[0] as \"/${string}\");\n } catch {\n // Ignore\n }\n });\n\n if (config) {\n eslintCommands.push(`cross-env NO_LOGS=true eslint ${eslintArguments.join(\" \")} --config ${config} ${filePaths.join(\" \")}`);\n }\n });\n\n return eslintCommands;\n};\n\nexport default createEslintCommands;\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/utils/get-nearest-config-path.ts"],"names":["findUp","existsSync","dirname","join","packageDirectorySync","cwd","filePath","getNearestPackageRootPath","packageDirectoryPath","joinPaths","paths","joined","getNearestConfigPath","fileName","packageRootPath","configPath","get_nearest_config_path_default"],"mappings":"AAAA,OAAOA,MAAY,UACnB,OAAS,cAAAC,MAAkB,KAC3B,OAAS,WAAAC,EAAS,QAAAC,MAAY,OAG9B,IAAMC,EAAwBC,GAAiB,CAC3C,IAAMC,EAAWN,EAAO,KAAK,eAAgB,CAAE,IAAAK,CAAI,CAAC,EAEpD,OAAOC,GAAYJ,EAAQI,CAAQ,CACvC,EAEMC,EAA6BF,GAA+B,CAC9D,IAAMG,EAAuBJ,EAAqBC,GAAO,QAAQ,IAAI,CAAC,EAEtE,GAAIG,GAAsB,WAAW,GAAG,EACpC,OAAOA,EAGX,MAAM,IAAI,MAAM,kEAAkEH,CAAG,GAAG,CAC5F,EAEMI,EAA8CC,GAA2B,CAC3E,IAAMC,EAASR,EAAK,GAAGO,CAAK,EAE5B,GAAIC,EAAO,WAAW,GAAG,EACrB,OAAOA,EAGX,MAAM,IAAI,UAAU,8CAA8C,CACtE,EAEMC,EAAuB,CAAkEC,EAAaR,IAA8B,CACtI,IAAMS,EAAkBP,EAA0BF,CAAG,EAC/CU,EAAaN,EAAkB,CAACK,EAAsBD,CAAQ,CAAC,EAGrE,GAAIZ,EAAWc,CAAU,EACrB,OAAOA,EAGX,MAAM,IAAI,MAAM,0BAA0BF,CAAQ,SAAS,CAC/D,EAMOG,EAAQJ","sourcesContent":["import findUp from \"find-up\";\nimport { existsSync } from \"node:fs\";\nimport { dirname, join } from \"node:path\";\nimport type { Join } from \"type-fest\";\n\nconst packageDirectorySync = (cwd?: string) => {\n const filePath = findUp.sync(\"package.json\", { cwd });\n\n return filePath && dirname(filePath);\n};\n\nconst getNearestPackageRootPath = (cwd?: string): AbsolutePath => {\n const packageDirectoryPath = packageDirectorySync(cwd ?? process.cwd());\n\n if (packageDirectoryPath?.startsWith(\"/\")) {\n return packageDirectoryPath as AbsolutePath;\n }\n\n throw new Error(`Cannot determine the nearest root of the package for the file: ${cwd}!`);\n};\n\nconst joinPaths = <T extends ReadonlyArray<string>>(paths: T): Join<T, \"/\"> => {\n const joined = join(...paths);\n\n if (joined.startsWith(\"/\")) {\n return joined as Join<T, \"/\">;\n }\n\n throw new TypeError(`Joined path did not return an absolute path.`);\n};\n\nconst getNearestConfigPath = <N extends ConfigFileName, A extends AbsolutePath = AbsolutePath>(fileName: N, cwd?: A): ConfigPath<A, N> => {\n const packageRootPath = getNearestPackageRootPath(cwd);\n const configPath = joinPaths<[A, N]>([packageRootPath as A, fileName]);\n\n // eslint-disable-next-line security/detect-non-literal-fs-filename\n if (existsSync(configPath)) {\n return configPath;\n }\n\n throw new Error(`Cannot locate nearest \"${fileName}\" file!`);\n};\n\nexport type AbsolutePath = `/${string}`;\nexport type ConfigFileName = string;\nexport type ConfigPath<A extends AbsolutePath, N extends ConfigFileName> = Join<[A, N], \"/\">;\n\nexport default getNearestConfigPath;\n"]}
@@ -1,15 +0,0 @@
1
- 'use strict';
2
-
3
- var chunkB7BKRXC3_js = require('./chunk-B7BKRXC3.js');
4
- var chunk26UFUGBI_js = require('./chunk-26UFUGBI.js');
5
- var packageJsonUtils = require('@anolilab/package-json-utils');
6
- var path = require('path');
7
- var eslint = require('eslint');
8
- var shellQuote = require('shell-quote');
9
-
10
- !global.anolilabLintStagedPackageJsonConfig&&packageJsonUtils.pkg&&(global.anolilabLintStagedPackageJsonConfig=packageJsonUtils.pkg.anolilab?.["lint-staged-config"]);var $=global.anolilabLintStagedPackageJsonConfig??{},u=$;var k=n=>{let t={};return n.forEach(s=>{let i=path.dirname(s);t[i]||(t[i]=[]),t[i].push(s);}),t},p=k;var F=async n=>{let t=new eslint.ESLint,s=await Promise.all(n.map(async o=>await t.isPathIgnored(o)));return n.filter((o,a)=>!s[a]).map(o=>`"${chunk26UFUGBI_js.a?o:shellQuote.quote([o])}"`)},h=F;var e=u.settings.eslint??{},y=["react-hooks/exhaustive-deps: off"],r=".eslintrc",A=()=>{let n=[];e?.["max-warnings"]!==void 0&&Number.isNaN(e["max-warnings"])?n.push(`--max-warnings=${e["max-warnings"]}`):e?.["max-warnings"]!==!1&&n.push("--max-warnings=0");let t=[];e?.rules!==void 0&&Array.isArray(e.rules)?t.push([...e.rules,...y].filter(i=>i.trim().length>0).map(i=>`"${i.trim()}"`)):t.push(y.map(i=>`"${i.trim()}"`)),t.length>0&&n.push(`--rule ${t.join(" --rule ")}`);let s=[...e?.["fix-type"]??["layout"]].filter(i=>i.trim().length>0);return s.length>0&&n.push(`--fix-type ${s.join(",")}`,"--fix"),e?.cache&&n.push("--cache"),n},E=async n=>{let t=await h(n),s=A();if(e?.config)return s.push(`--config ${e.config}`),[`cross-env NO_LOGS=true eslint ${s.join(" ")} ${t.join(" ")}`];let i=p(t),o=[];return Object.values(i).forEach(a=>{let l;[r,`${r}.js`,`${r}.cjs`,`${r}.json`,`${r}.yaml`,`${r}.yml`].forEach(S=>{if(!l)try{l=chunkB7BKRXC3_js.a(S,a[0]);}catch{}}),l&&o.push(`cross-env NO_LOGS=true eslint ${s.join(" ")} --config ${l} ${a.join(" ")}`);}),o},g=E;var x=["cjs","js","mjs","cts","ts","mts","yml","yaml","jsx","tsx","mdx","toml"];global.hasAnolilabLintStagedMarkdownCli||(global.hasAnolilabLintStagedMarkdownCli=packageJsonUtils.hasDependency("markdownlint-cli")||packageJsonUtils.hasDevDependency("markdownlint-cli"));global.hasAnolilabLintStagedMarkdownCli2||(global.hasAnolilabLintStagedMarkdownCli2=packageJsonUtils.hasDependency("markdownlint-cli2")||packageJsonUtils.hasDevDependency("markdownlint-cli2"));!global.hasAnolilabLintStagedMarkdownCli&&!global.hasAnolilabLintStagedMarkdownCli2&&x.push("md");var N={[`**/*.{${["json","json5","jsonc"].join(",")}}`]:async n=>[...await g(n)],[`**/*.{${[x].join(",")}}`]:async n=>[`prettier --write ${chunk26UFUGBI_js.b(n)}`,...await g(n)]},K=N;
11
-
12
- exports.a = u;
13
- exports.b = K;
14
- //# sourceMappingURL=out.js.map
15
- //# sourceMappingURL=chunk-WJEJ2JPI.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/groups/eslint/index.ts","../src/utils/lint-staged-config.ts","../src/groups/eslint/group-file-paths-by-directory-name.ts","../src/groups/eslint/remove-ignored-files.ts","../src/groups/eslint/create-eslint-commands.ts"],"names":["hasDependency","hasDevDependency","pkg","config","lint_staged_config_default","dirname","groupFilePathsByDirectoryName","filePaths","groups","filePath","directoryName","group_file_paths_by_directory_name_default","ESLint","quote","removeIgnoredFiles","filenames","eslint","ignoredFiles","filename","_","index","is_windows_default","remove_ignored_files_default","eslintSettings","eslintGlobalRulesForFix","configFile","createEslintArguments","eslintArguments","rules","rule","r","fixType","type","createEslintCommands","filteredFiles","groupedFilesNames","eslintCommands","configName","get_nearest_config_path_default","create_eslint_commands_default","extensions","group","concat_files_default","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AAU,CAAC,CAAiB,CAC1E,MAAE,CAEF,CACJ,CAAC,EAEGJ,GACAiC,EAAe,KAAK,iCAAiCT,EAAgB,KAAK,GAAG,CAAC,aAAaxB,CAAM,IAAII,EAAU,KAAK,GAAG,CAAC,EAAE,CAElI,CAAC,EAEM6B,CACX,EAEOG,EAAQN,EJjHf,IAAMO,EAAa,CAAC,MAAO,KAAM,MAAO,MAAO,KAAM,MAAO,MAAO,OAAQ,MAAO,MAAO,MAAO,MAAM,EAEjG,OAAO,mCACR,OAAO,iCAAmCxC,EAAc,kBAAkB,GAAKC,EAAiB,kBAAkB,GAGjH,OAAO,oCACR,OAAO,kCAAoCD,EAAc,mBAAmB,GAAKC,EAAiB,mBAAmB,GAGrH,CAAC,OAAO,kCAAoC,CAAC,OAAO,mCACpDuC,EAAW,KAAK,IAAI,EAGxB,IAAMC,EAAgB,CAClB,CAAC,SAAS,CAAC,OAAQ,QAAS,OAAO,EAAE,KAAK,GAAG,CAAC,GAAG,EAAG,MAAO1B,GAAwB,CAAC,GAAI,MAAMwB,EAAqBxB,CAAS,CAAE,EAC9H,CAAC,SAAS,CAACyB,CAAU,EAAE,KAAK,GAAG,CAAC,GAAG,EAAG,MAAOzB,GAAwB,CACjE,oBAAoB2B,EAAY3B,CAAS,CAAC,GAC1C,GAAI,MAAMwB,EAAqBxB,CAAS,CAC5C,CACJ,EAEO4B,EAAQF","sourcesContent":["import { hasDependency, hasDevDependency } from \"@anolilab/package-json-utils\";\nimport type { Config } from \"lint-staged\";\n\nimport concatFiles from \"../../utils/concat-files\";\nimport createEslintCommands from \"./create-eslint-commands\";\n\nconst extensions = [\"cjs\", \"js\", \"mjs\", \"cts\", \"ts\", \"mts\", \"yml\", \"yaml\", \"jsx\", \"tsx\", \"mdx\", \"toml\"];\n\nif (!global.hasAnolilabLintStagedMarkdownCli) {\n global.hasAnolilabLintStagedMarkdownCli = hasDependency(\"markdownlint-cli\") || hasDevDependency(\"markdownlint-cli\");\n}\n\nif (!global.hasAnolilabLintStagedMarkdownCli2) {\n global.hasAnolilabLintStagedMarkdownCli2 = hasDependency(\"markdownlint-cli2\") || hasDevDependency(\"markdownlint-cli2\");\n}\n\nif (!global.hasAnolilabLintStagedMarkdownCli && !global.hasAnolilabLintStagedMarkdownCli2) {\n extensions.push(\"md\");\n}\n\nconst group: Config = {\n [`**/*.{${[\"json\", \"json5\", \"jsonc\"].join(\",\")}}`]: async (filenames: string[]) => [...(await createEslintCommands(filenames))],\n [`**/*.{${[extensions].join(\",\")}}`]: async (filenames: string[]) => [\n `prettier --write ${concatFiles(filenames)}`,\n ...(await createEslintCommands(filenames)),\n ],\n};\n\nexport default group;\n","import { pkg } from \"@anolilab/package-json-utils\";\n\nif (!global.anolilabLintStagedPackageJsonConfig && pkg) {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment,@typescript-eslint/no-unsafe-member-access\n global.anolilabLintStagedPackageJsonConfig = pkg[\"anolilab\"]?.[\"lint-staged-config\"];\n}\n\nconst config: { [key: string]: boolean | undefined } = global.anolilabLintStagedPackageJsonConfig ?? {};\n\nexport default config;\n","import { dirname } from \"node:path\";\n\nconst groupFilePathsByDirectoryName = (filePaths: string[]): { [key: string]: string[] } => {\n const groups: { [key: string]: string[] } = {};\n\n filePaths.forEach((filePath) => {\n const directoryName = dirname(filePath);\n\n // eslint-disable-next-line security/detect-object-injection\n if (!groups[directoryName]) {\n // eslint-disable-next-line security/detect-object-injection\n groups[directoryName] = [];\n }\n // eslint-disable-next-line security/detect-object-injection\n (groups[directoryName] as string[]).push(filePath);\n });\n\n return groups;\n};\n\nexport default groupFilePathsByDirectoryName;\n","// eslint-disable-next-line import/no-extraneous-dependencies\nimport { ESLint } from \"eslint\";\nimport { quote } from \"shell-quote\";\n\nimport isWindows from \"../../utils/is-windows\";\n\nconst removeIgnoredFiles = async (filenames: string[]): Promise<string[]> => {\n const eslint = new ESLint();\n // eslint-disable-next-line compat/compat\n const ignoredFiles = await Promise.all(filenames.map(async (filename) => await eslint.isPathIgnored(filename)));\n // eslint-disable-next-line security/detect-object-injection\n const filteredFiles = filenames.filter((_, index) => !ignoredFiles[index]);\n\n return filteredFiles.map((filename) => `\"${isWindows ? filename : quote([filename])}\"`);\n};\n\nexport default removeIgnoredFiles;\n","import getNearestConfigPath from \"../../utils/get-nearest-config-path\";\nimport anolilabLintStagedConfig from \"../../utils/lint-staged-config\";\nimport groupFilePathsByDirectoryName from \"./group-file-paths-by-directory-name\";\nimport removeIgnoredFiles from \"./remove-ignored-files\";\n\ntype ESLintSettings = {\n settings: {\n eslint?: {\n cache?: boolean;\n config?: string;\n \"fix-type\": string[];\n \"max-warnings\"?: number | string | false;\n rules?: string[];\n };\n };\n};\n\nconst eslintSettings: ESLintSettings[\"settings\"][\"eslint\"] =\n (anolilabLintStagedConfig as unknown as ESLintSettings).settings.eslint ?? ({} as ESLintSettings[\"settings\"][\"eslint\"]);\n\nconst eslintGlobalRulesForFix = [\n // react-hooks/eslint and react in general is very strict about exhaustively\n // declaring the dependencies when using the useEffect, useCallback... hooks.\n //\n // In some specific scenarios declaring the deps seems 'less' wanted or 'less' applicable\n // by the developer, leading to some exceptions in the code. That said it should be avoided.\n //\n // While the 'react-hooks/exhaustive-deps' rule is a good rule of thumb, it's not recommended to\n // automatically fix it from lint-staged as it can potentially break a legit intent.\n //\n // Reminder that a good practice is to always declare the dependencies when using the hooks,\n // and if not applicable, add an eslint disable comment to the useEffect, useCallback... such as:\n //\n // // eslint-disable-next-line react-hooks/exhaustive-deps\n //\n // Another approach can be to use hooks such as https://github.com/kentcdodds/use-deep-compare-effect to quickly bypass\n // shallow rendering limitations.\n //\n // @see https://reactjs.org/docs/hooks-rules.html\n // @see https://eslint.org/docs/2.13.1/user-guide/configuring#disabling-rules-with-inline-comments\n \"react-hooks/exhaustive-deps: off\",\n];\n\nconst configFile = \".eslintrc\";\n\nconst createEslintArguments = (): string[] => {\n const eslintArguments: string[] = [];\n\n if (eslintSettings?.[\"max-warnings\"] !== undefined && Number.isNaN(eslintSettings[\"max-warnings\"])) {\n eslintArguments.push(`--max-warnings=${eslintSettings[\"max-warnings\"]}`);\n } else if (eslintSettings?.[\"max-warnings\"] !== false) {\n eslintArguments.push(\"--max-warnings=0\");\n }\n\n const rules = [];\n\n if (eslintSettings?.rules !== undefined && Array.isArray(eslintSettings.rules)) {\n rules.push([...eslintSettings.rules, ...eslintGlobalRulesForFix].filter((rule) => rule.trim().length > 0).map((r) => `\"${r.trim()}\"`));\n } else {\n rules.push(eslintGlobalRulesForFix.map((r) => `\"${r.trim()}\"`));\n }\n\n if (rules.length > 0) {\n eslintArguments.push(`--rule ${rules.join(\" --rule \")}`);\n }\n\n // For lint-staged it's safer to not apply the fix command if it changes the AST\n // @see https://eslint.org/docs/user-guide/command-line-interface#--fix-type\n const fixType = [...(eslintSettings?.[\"fix-type\"] ?? [\"layout\"])].filter((type) => type.trim().length > 0);\n\n if (fixType.length > 0) {\n eslintArguments.push(`--fix-type ${fixType.join(\",\")}`, \"--fix\");\n }\n\n if (eslintSettings?.cache) {\n eslintArguments.push(\"--cache\");\n }\n\n return eslintArguments;\n};\n\nconst createEslintCommands = async (filenames: string[]): Promise<string[]> => {\n const filteredFiles = await removeIgnoredFiles(filenames);\n\n const eslintArguments = createEslintArguments();\n\n if (eslintSettings?.config) {\n eslintArguments.push(`--config ${eslintSettings.config}`);\n\n return [`cross-env NO_LOGS=true eslint ${eslintArguments.join(\" \")} ${filteredFiles.join(\" \")}`];\n }\n\n const groupedFilesNames = groupFilePathsByDirectoryName(filteredFiles);\n const eslintCommands: string[] = [];\n\n Object.values(groupedFilesNames).forEach((filePaths) => {\n let config: string | undefined;\n\n [configFile, `${configFile}.js`, `${configFile}.cjs`, `${configFile}.json`, `${configFile}.yaml`, `${configFile}.yml`].forEach((configName) => {\n if (config) {\n return;\n }\n\n try {\n // eslint-disable-next-line no-template-curly-in-string\n config = getNearestConfigPath(configName, filePaths[0] as \"/${string}\");\n } catch {\n // Ignore\n }\n });\n\n if (config) {\n eslintCommands.push(`cross-env NO_LOGS=true eslint ${eslintArguments.join(\" \")} --config ${config} ${filePaths.join(\" \")}`);\n }\n });\n\n return eslintCommands;\n};\n\nexport default createEslintCommands;\n"]}