@anolilab/lint-staged-config 3.0.31 → 3.0.32
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 +11 -0
- package/dist/bin.js +10 -10
- package/dist/index.cjs +1 -1
- package/dist/index.mjs +2 -2
- package/package.json +5 -5
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,14 @@
|
|
|
1
|
+
## @anolilab/lint-staged-config [3.0.32](https://github.com/anolilab/javascript-style-guide/compare/@anolilab/lint-staged-config@3.0.31...@anolilab/lint-staged-config@3.0.32) (2025-10-02)
|
|
2
|
+
|
|
3
|
+
### Bug Fixes
|
|
4
|
+
|
|
5
|
+
* enhance lint-staged-config with Prettier and ESLint updates ([0018245](https://github.com/anolilab/javascript-style-guide/commit/00182452abe9fb80a1be54ac889f4ab9ee9b24b6))
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
### Dependencies
|
|
9
|
+
|
|
10
|
+
* **@anolilab/eslint-config:** upgraded to 16.3.1
|
|
11
|
+
|
|
1
12
|
## @anolilab/lint-staged-config [3.0.31](https://github.com/anolilab/javascript-style-guide/compare/@anolilab/lint-staged-config@3.0.30...@anolilab/lint-staged-config@3.0.31) (2025-09-11)
|
|
2
13
|
|
|
3
14
|
### Bug Fixes
|
package/dist/bin.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
var g=Object.defineProperty;var h=(n
|
|
2
|
+
var g=Object.defineProperty;var h=(t,n)=>g(t,"name",{value:n,configurable:!0});import{existsSync as u}from"node:fs";import{join as s}from"node:path";import{exit as f}from"node:process";import{readFile as p,writeFileSync as r,ensureDirSync as $,isAccessibleSync as _}from"@visulima/fs";import{parsePackageJson as y,hasPackageJsonAnyDependency as d}from"@visulima/package";import __cjs_mod__ from "node:module"; // -- packem CommonJS require shim --
|
|
3
3
|
const require = __cjs_mod__.createRequire(import.meta.url);
|
|
4
|
-
var w=Object.defineProperty,l=h((n
|
|
4
|
+
var w=Object.defineProperty,l=h((t,n)=>w(t,"name",{value:n,configurable:!0}),"c");const c=l(t=>_(t)?(console.warn(`⚠️ ${t} already exists;`),!0):!1,"checkIfFileExists"),I=l(async(t,n)=>{const e=".lintstagedrc";for(const i of[e,`${e}.js`,`${e}.cjs`,`${e}.mjs`,`${e}.json`,`${e}.yaml`,`${e}.yml`,"lint-staged.config.js","lint-staged.config.mjs","lint-staged.config.cjs"])if(c(s(t,i))){console.warn(`⚠️ ${i} already exists;`);return}const o=s(t,".lintstagedrc.js");r(o,`${n?'import { defineConfig } from "@anolilab/lint-staged-config"':'const { defineConfig } = require("@anolilab/lint-staged-config")'};
|
|
5
5
|
|
|
6
|
-
${
|
|
7
|
-
`)},"writeLintStagedRc"),x=l(async(n
|
|
6
|
+
${n?"export default":"module.exports ="} defineConfig();
|
|
7
|
+
`)},"writeLintStagedRc"),x=l(async(t,n)=>{const e=".nano-staged";for(const i of[e,`${e}.js`,`${e}.cjs`,`${e}.mjs`,`${e}.json`,`${e.replace(".","")}.js`,`${e.replace(".","")}.cjs`,`${e.replace(".","")}.mjs`,`${e.replace(".","")}.json`,".nanostagedrc"])if(c(s(t,i))){console.warn(`⚠️ ${i} already exists;`);return}const o=s(t,".nano-staged.js");r(o,`${n?'import { defineConfig } from "@anolilab/lint-staged-config"':'const { defineConfig } = require("@anolilab/lint-staged-config")'};
|
|
8
8
|
|
|
9
|
-
${
|
|
10
|
-
`)},"writeNanoStagedRc"),S=l(async(n,
|
|
9
|
+
${n?"export default":"module.exports ="} defineConfig();
|
|
10
|
+
`)},"writeNanoStagedRc"),S=l(async(t,n,e)=>{if(!d(n,["husky"])){console.warn("⚠️ husky is not installed;");return}const o=s(t,".husky");$(o);const i=s(o,"common.sh");c(i)||r(i,`#!/bin/sh
|
|
11
11
|
|
|
12
12
|
command_exists () {
|
|
13
13
|
command -v "$1" >/dev/null 2>&1
|
|
@@ -29,7 +29,7 @@ if [ "$IS_WINDOWS" = "true" ]; then
|
|
|
29
29
|
exec < /dev/tty
|
|
30
30
|
fi
|
|
31
31
|
fi
|
|
32
|
-
`);const a=s(
|
|
32
|
+
`);const a=s(o,"pre-commit");c(a)||r(a,`#!/bin/sh
|
|
33
33
|
|
|
34
34
|
. "$(dirname "$0")/_/husky.sh"
|
|
35
35
|
. "$(dirname "$0")/common.sh"
|
|
@@ -44,7 +44,7 @@ ${e?"./node_modules/.bin/nano-staged":"./node_modules/.bin/lint-staged --verbose
|
|
|
44
44
|
|
|
45
45
|
echo Finished Git hook: pre-commit
|
|
46
46
|
echo --------------------------------------------
|
|
47
|
-
`);const m=s(
|
|
47
|
+
`);const m=s(o,"prepare-commit-msg");d(n,["commitizen"])&&!c(m)&&r(m,`#!/bin/sh
|
|
48
48
|
|
|
49
49
|
. "$(dirname "$0")/_/husky.sh"
|
|
50
50
|
. "$(dirname "$0")/common.sh"
|
|
@@ -86,5 +86,5 @@ fi
|
|
|
86
86
|
|
|
87
87
|
echo Finished Git hook: prepare-commit-msg
|
|
88
88
|
echo --------------------------------------------
|
|
89
|
-
`)},"writeHuskyFiles");(async()=>{const
|
|
90
|
-
`);const
|
|
89
|
+
`)},"writeHuskyFiles");(async()=>{const t=process.cwd();console.log("Configuring @anolilab/lint-staged-config",t,`
|
|
90
|
+
`);const n=s(t,"package.json");u(n)||(console.error("No package.json found in the current directory. You need to run this command in a directory with a package.json file."),f(1));const e=await y(await p(n)),o=e.type==="module",i=d(e,["lint-staged"]),a=d(e,["nano-staged"]);try{i?await I(t,o):a&&await x(t,o),await S(t,e,a),console.log("Everything went well, have fun!"),f(0)}catch(m){console.error("Something went wrong:",m),f(1)}})();
|
package/dist/index.cjs
CHANGED
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
Unable to determine if file is ignored.
|
|
3
3
|
|
|
4
4
|
|
|
5
|
-
${t.reason}`),new Error("Stopping lint-staged because of an error.")});return s.filter((t,n)=>!i[n]).map(t=>`"${P?t:k.quote([t])}"`)},"removeIgnoredFiles");var I=Object.defineProperty,_=f((s,e)=>I(s,"name",{value:e,configurable:!0}),"m");const y=".eslintrc",U=_((s,e)=>{const i=[];s["max-warnings"]!==void 0&&Number.isNaN(s["max-warnings"])?i.push(`--max-warnings=${s["max-warnings"]}`):s["max-warnings"]!==!1&&i.push("--max-warnings=0");const t=[];o.hasPackageJsonAnyDependency(e,["eslint-plugin-react-hooks"])&&t.push("react-hooks/exhaustive-deps:off"),o.hasPackageJsonAnyDependency(e,["eslint-plugin-eslint-comments"])&&t.push("eslint-comments/no-unused-disable:off");const n=[...s.rules??[],...t].filter(p=>p.trim().length>0);n.length>0&&i.push(n.map(p=>`--rule "${p}"`).join(" "));const l=[...s["fix-type"]??["layout"]].filter(p=>p.trim().length>0);return l.length>0&&i.push(`--fix-type ${l.join(",")}`,"--fix"),s.cache&&i.push("--cache"),i},"createEslintArguments"),W=_(async(s,e,i,t)=>{const n=await H(t),l=U(i,e);if(i.config)return l.push(`--config ${i.config}`),[`${s} exec eslint ${l.join(" ")} ${n.join(" ")}`];const p=G(n),d=[];return Object.values(p).forEach(a=>{let r;[y,`${y}.js`,`${y}.cjs`,`${y}.json`,`${y}.yaml`,`${y}.yml`].forEach(g=>{if(!r)try{r=v(g,a[0])}catch{}}),r&&d.push(`${s} exec eslint ${l.join(" ")} --config ${r} ${a.join(" ")}`)}),d},"createEslintCommands");var B=Object.defineProperty,Q=f((s,e)=>B(s,"name",{value:e,configurable:!0}),"r");const c=Q(s=>s.map(e=>`"${P?e:k.quote([e])}"`).join(" ").replaceAll("/@","/@"),"concatFiles");var Y=Object.defineProperty,$=f((s,e)=>Y(s,"name",{value:e,configurable:!0}),"f");const b=["cjs","js","mjs","cts","ts","mts","yml","yaml","jsx","tsx","mdx","toml","json","json5","jsonc"],E=["cts","ts","mts","tsx","ctsx"],A=["css","scss","sass","less","styl","stylus","pcss","postcss","sss"],z=$((s={})=>{const e={debug:!1,eslint:{extensions:b},stylesheets:{extensions:A},typescript:{exclude:[],extensions:E},...s},i=e.cwd||process.cwd();if(!J.existsSync(`${i}/package.json`))throw new Error(`No package.json found in the current working directory: ${i}; Please adjust the "cwd" option.`);const t=o.
|
|
5
|
+
${t.reason}`),new Error("Stopping lint-staged because of an error.")});return s.filter((t,n)=>!i[n]).map(t=>`"${P?t:k.quote([t])}"`)},"removeIgnoredFiles");var I=Object.defineProperty,_=f((s,e)=>I(s,"name",{value:e,configurable:!0}),"m");const y=".eslintrc",U=_((s,e)=>{const i=[];s["max-warnings"]!==void 0&&Number.isNaN(s["max-warnings"])?i.push(`--max-warnings=${s["max-warnings"]}`):s["max-warnings"]!==!1&&i.push("--max-warnings=0");const t=[];o.hasPackageJsonAnyDependency(e,["eslint-plugin-react-hooks"])&&t.push("react-hooks/exhaustive-deps:off"),o.hasPackageJsonAnyDependency(e,["eslint-plugin-eslint-comments"])&&t.push("eslint-comments/no-unused-disable:off");const n=[...s.rules??[],...t].filter(p=>p.trim().length>0);n.length>0&&i.push(n.map(p=>`--rule "${p}"`).join(" "));const l=[...s["fix-type"]??["layout"]].filter(p=>p.trim().length>0);return l.length>0&&i.push(`--fix-type ${l.join(",")}`,"--fix"),s.cache&&i.push("--cache"),i},"createEslintArguments"),W=_(async(s,e,i,t)=>{const n=await H(t),l=U(i,e);if(i.config)return l.push(`--config ${i.config}`),[`${s} exec eslint ${l.join(" ")} ${n.join(" ")}`];const p=G(n),d=[];return Object.values(p).forEach(a=>{let r;[y,`${y}.js`,`${y}.cjs`,`${y}.json`,`${y}.yaml`,`${y}.yml`].forEach(g=>{if(!r)try{r=v(g,a[0])}catch{}}),r&&d.push(`${s} exec eslint ${l.join(" ")} --config ${r} ${a.join(" ")}`)}),d},"createEslintCommands");var B=Object.defineProperty,Q=f((s,e)=>B(s,"name",{value:e,configurable:!0}),"r");const c=Q(s=>s.map(e=>`"${P?e:k.quote([e])}"`).join(" ").replaceAll("/@","/@"),"concatFiles");var Y=Object.defineProperty,$=f((s,e)=>Y(s,"name",{value:e,configurable:!0}),"f");const b=["cjs","js","mjs","cts","ts","mts","yml","yaml","jsx","tsx","mdx","toml","json","json5","jsonc"],E=["cts","ts","mts","tsx","ctsx"],A=["css","scss","sass","less","styl","stylus","pcss","postcss","sss"],z=$((s={})=>{const e={debug:!1,eslint:{extensions:b},stylesheets:{extensions:A},typescript:{exclude:[],extensions:E},...s},i=e.cwd||process.cwd();if(!J.existsSync(`${i}/package.json`))throw new Error(`No package.json found in the current working directory: ${i}; Please adjust the "cwd" option.`);const t=o.parsePackageJsonSync(m.readFileSync(`${i}/package.json`),{resolveCatalogs:!0}),{packageManager:n}=o.findPackageManagerSync(i);e.debug&&console.debug("Package manager found:",n);const l=o.hasPackageJsonAnyDependency(t,["markdownlint-cli"]),p=o.hasPackageJsonAnyDependency(t,["markdownlint-cli2"]),d=o.hasPackageJsonAnyDependency(t,["prettier"]);let a={};if(e.eslint!==!1&&o.hasPackageJsonAnyDependency(t,["eslint"])){if(!Array.isArray(e.eslint.extensions)||e.eslint.extensions.length===0)throw new Error("The `extensions` option is required for the ESLint configuration.");!l&&!p&&e.eslint.extensions.push("md"),a[`**/*.{${e.eslint.extensions.join(",")}}`]=async r=>[...d?[`${n} exec prettier --write ${c(r)}`]:[],...await W(n,t,e.eslint,r)]}if(e.json!==!1&&o.hasPackageJsonAnyDependency(t,["sort-package-json"])&&(a["**/package.json"]=r=>[`${n} exec sort-package-json ${c(r)}`]),e.markdown!==!1&&l&&(a={...a,"**/*.md":$(r=>[...d?[`${n} exec prettier --write ${c(r)}`]:[],...l?[`${n} exec markdownlint --fix --ignore '**/node_modules/**' --ignore '**/CHANGELOG.md' ${c(r)}`]:[],...p?[`${n} exec markdownlint-cli2 --fix '!**/node_modules/**' '!**/CHANGELOG.md' ${c(r)}`]:[]],"**/*.md"),"**/*.mdx":$(r=>[...d?[`${n} exec prettier --write ${c(r)}`]:[]],"**/*.mdx")}),e.secretlint!==!1&&o.hasPackageJsonAnyDependency(t,["secretlint"])&&(a["**/*"]=r=>[`${n} exec secretlint ${c(r)}`]),e.stylesheets!==!1&&o.hasPackageJsonAnyDependency(t,["stylelint"])){if(!Array.isArray(e.stylesheets.extensions)||e.stylesheets.extensions.length===0)throw new Error("The `extensions` option is required for the Stylesheets configuration.");a[`**/*.{${e.stylesheets.extensions.join(",")}}`]=r=>[...d?[`${n} exec prettier --ignore-unknown --write ${c(r)}`]:[],`${n} exec stylelint --fix`]}if(e.typescript!==!1&&o.hasPackageJsonAnyDependency(t,["typescript"])){if(!Array.isArray(e.typescript.extensions)||e.typescript.extensions.length===0)throw new Error("The `extensions` option is required for the TypeScript configuration.");a[`**/*.{${e.typescript.extensions.join(",")}}`]=r=>{const g=new Set;return r.forEach(x=>{if(typeof e.typescript?.exclude=="object"&&Array.isArray(e.typescript.exclude)){let u=!1;if(e.typescript.exclude.forEach(S=>{!u&&x.includes(S)&&(u=!0)}),u){e.debug&&console.info(`Skipping ${x} as it's excluded in the settings.`);return}}try{const u=v("tsconfig.json",x);g.add(`${n} exec tsc --noEmit --project ${u}`)}catch(u){e.debug&&console.error(u)}}),[...g]}}return o.hasPackageJsonAnyDependency(t,["vitest"])&&(a["**/?(*.){test,spec}.?(c|m)[jt]s?(x)"]=["vitest related --run"],a["**/__tests__/**/*.?(c|m)[jt]s?(x)"]=[`${n} exec vitest related --run`]),o.hasPackageJsonAnyDependency(t,["jest"])&&(a["**/*.spec.{js,ts,tsx}"]=[`${n} exec jest --findRelatedTests`],a["**/*.test.{js,ts,tsx}"]=[`${n} exec jest --findRelatedTests`],a["**/?(*.){test,spec}.?(c|m)[jt]s?(x)"]=[`${n} exec jest --findRelatedTests`],a["**/__mocks__/*.{js,ts,tsx}"]=[`${n} exec jest --findRelatedTests`],a["**/__tests__/**/*.?(c|m)[jt]s?(x)"]=[`${n} exec jest --findRelatedTests`],a["**/__tests__/*.{js,ts,tsx}"]=[`${n} exec jest --findRelatedTests`],a["**/test/*.{js,ts,tsx}"]=[`${n} exec jest --findRelatedTests`]),o.hasPackageJsonAnyDependency(t,["ava"])&&(a["**/(test|tests|__tests__)/**/*.js"]=r=>[`${n} exec ava ${c(r)}`],a["**/*.(spec|test).js"]=r=>[`${n} exec ava ${c(r)}`],a["**/test.js"]=r=>[`${n} exec ava ${c(r)}`],a["**/test-*.js"]=r=>[`${n} exec ava ${c(r)}`]),a},"defineConfig");exports.defineConfig=z;exports.eslintExtensions=b;exports.stylesheetsExtensions=A;exports.typescriptExtensions=E;
|
package/dist/index.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
var E=Object.defineProperty;var d=(t,e)=>E(t,"name",{value:e,configurable:!0});import{existsSync as _}from"node:fs";import{findUpSync as P,isAccessibleSync as S,readFileSync as A}from"@visulima/fs";import{hasPackageJsonAnyDependency as a,
|
|
1
|
+
var E=Object.defineProperty;var d=(t,e)=>E(t,"name",{value:e,configurable:!0});import{existsSync as _}from"node:fs";import{findUpSync as P,isAccessibleSync as S,readFileSync as A}from"@visulima/fs";import{hasPackageJsonAnyDependency as a,parsePackageJsonSync as T,findPackageManagerSync as O}from"@visulima/package";import{dirname as h,join as C}from"node:path";import{ESLint as N}from"eslint";import{quote as j}from"shell-quote";import{platform as R,env as q}from"node:process";var F=Object.defineProperty,$=d((t,e)=>F(t,"name",{value:e,configurable:!0}),"o$1");const G=$(t=>{const e=P("package.json",{cwd:t});return e&&h(e)},"packageDirectorySync"),L=$(t=>{const e=G(t??process.cwd());if(e?.startsWith("/"))return e;throw new Error(`Cannot determine the nearest root of the package for the file: ${t}!`)},"getNearestPackageRootPath"),D=$(t=>{const e=C(...t);if(e.startsWith("/"))return e;throw new TypeError("Joined path did not return an absolute path.")},"joinPaths"),w=$((t,e)=>{const o=L(e),s=D([o,t]);if(S(s))return s;throw new Error(`Cannot locate nearest "${t}" file!`)},"getNearestConfigPath");var J=Object.defineProperty,H=d((t,e)=>J(t,"name",{value:e,configurable:!0}),"i$1");const I=H(t=>{const e={};return t.forEach(o=>{const s=h(o);e[s]||(e[s]=[]),e[s].push(o)}),e},"groupFilePathsByDirectoryName"),v=R==="win32"||/^(msys|cygwin)$/u.test(q.OSTYPE??"");var M=Object.defineProperty,U=d((t,e)=>M(t,"name",{value:e,configurable:!0}),"o");const W=U(async(t,e=new N)=>{const o=(await Promise.allSettled(t.map(async s=>await e.isPathIgnored(s)))).map(s=>{if(s.status==="fulfilled")return s.value;throw console.error(`
|
|
2
2
|
Unable to determine if file is ignored.
|
|
3
3
|
|
|
4
4
|
|
|
5
|
-
${s.reason}`),new Error("Stopping lint-staged because of an error.")});return t.filter((s,n)=>!o[n]).map(s=>`"${v?s:j([s])}"`)},"removeIgnoredFiles");var B=Object.defineProperty,k=d((t,e)=>B(t,"name",{value:e,configurable:!0}),"m");const m=".eslintrc",Y=k((t,e)=>{const o=[];t["max-warnings"]!==void 0&&Number.isNaN(t["max-warnings"])?o.push(`--max-warnings=${t["max-warnings"]}`):t["max-warnings"]!==!1&&o.push("--max-warnings=0");const s=[];a(e,["eslint-plugin-react-hooks"])&&s.push("react-hooks/exhaustive-deps:off"),a(e,["eslint-plugin-eslint-comments"])&&s.push("eslint-comments/no-unused-disable:off");const n=[...t.rules??[],...s].filter(f=>f.trim().length>0);n.length>0&&o.push(n.map(f=>`--rule "${f}"`).join(" "));const l=[...t["fix-type"]??["layout"]].filter(f=>f.trim().length>0);return l.length>0&&o.push(`--fix-type ${l.join(",")}`,"--fix"),t.cache&&o.push("--cache"),o},"createEslintArguments"),z=k(async(t,e,o,s)=>{const n=await W(s),l=Y(o,e);if(o.config)return l.push(`--config ${o.config}`),[`${t} exec eslint ${l.join(" ")} ${n.join(" ")}`];const f=I(n),p=[];return Object.values(f).forEach(i=>{let r;[m,`${m}.js`,`${m}.cjs`,`${m}.json`,`${m}.yaml`,`${m}.yml`].forEach(x=>{if(!r)try{r=w(x,i[0])}catch{}}),r&&p.push(`${t} exec eslint ${l.join(" ")} --config ${r} ${i.join(" ")}`)}),p},"createEslintCommands");var K=Object.defineProperty,Q=d((t,e)=>K(t,"name",{value:e,configurable:!0}),"r");const c=Q(t=>t.map(e=>`"${v?e:j([e])}"`).join(" ").replaceAll("/@","/@"),"concatFiles");var V=Object.defineProperty,
|
|
5
|
+
${s.reason}`),new Error("Stopping lint-staged because of an error.")});return t.filter((s,n)=>!o[n]).map(s=>`"${v?s:j([s])}"`)},"removeIgnoredFiles");var B=Object.defineProperty,k=d((t,e)=>B(t,"name",{value:e,configurable:!0}),"m");const m=".eslintrc",Y=k((t,e)=>{const o=[];t["max-warnings"]!==void 0&&Number.isNaN(t["max-warnings"])?o.push(`--max-warnings=${t["max-warnings"]}`):t["max-warnings"]!==!1&&o.push("--max-warnings=0");const s=[];a(e,["eslint-plugin-react-hooks"])&&s.push("react-hooks/exhaustive-deps:off"),a(e,["eslint-plugin-eslint-comments"])&&s.push("eslint-comments/no-unused-disable:off");const n=[...t.rules??[],...s].filter(f=>f.trim().length>0);n.length>0&&o.push(n.map(f=>`--rule "${f}"`).join(" "));const l=[...t["fix-type"]??["layout"]].filter(f=>f.trim().length>0);return l.length>0&&o.push(`--fix-type ${l.join(",")}`,"--fix"),t.cache&&o.push("--cache"),o},"createEslintArguments"),z=k(async(t,e,o,s)=>{const n=await W(s),l=Y(o,e);if(o.config)return l.push(`--config ${o.config}`),[`${t} exec eslint ${l.join(" ")} ${n.join(" ")}`];const f=I(n),p=[];return Object.values(f).forEach(i=>{let r;[m,`${m}.js`,`${m}.cjs`,`${m}.json`,`${m}.yaml`,`${m}.yml`].forEach(x=>{if(!r)try{r=w(x,i[0])}catch{}}),r&&p.push(`${t} exec eslint ${l.join(" ")} --config ${r} ${i.join(" ")}`)}),p},"createEslintCommands");var K=Object.defineProperty,Q=d((t,e)=>K(t,"name",{value:e,configurable:!0}),"r");const c=Q(t=>t.map(e=>`"${v?e:j([e])}"`).join(" ").replaceAll("/@","/@"),"concatFiles");var V=Object.defineProperty,y=d((t,e)=>V(t,"name",{value:e,configurable:!0}),"f");const X=["cjs","js","mjs","cts","ts","mts","yml","yaml","jsx","tsx","mdx","toml","json","json5","jsonc"],Z=["cts","ts","mts","tsx","ctsx"],ee=["css","scss","sass","less","styl","stylus","pcss","postcss","sss"],le=y((t={})=>{const e={debug:!1,eslint:{extensions:X},stylesheets:{extensions:ee},typescript:{exclude:[],extensions:Z},...t},o=e.cwd||process.cwd();if(!_(`${o}/package.json`))throw new Error(`No package.json found in the current working directory: ${o}; Please adjust the "cwd" option.`);const s=T(A(`${o}/package.json`),{resolveCatalogs:!0}),{packageManager:n}=O(o);e.debug&&console.debug("Package manager found:",n);const l=a(s,["markdownlint-cli"]),f=a(s,["markdownlint-cli2"]),p=a(s,["prettier"]);let i={};if(e.eslint!==!1&&a(s,["eslint"])){if(!Array.isArray(e.eslint.extensions)||e.eslint.extensions.length===0)throw new Error("The `extensions` option is required for the ESLint configuration.");!l&&!f&&e.eslint.extensions.push("md"),i[`**/*.{${e.eslint.extensions.join(",")}}`]=async r=>[...p?[`${n} exec prettier --write ${c(r)}`]:[],...await z(n,s,e.eslint,r)]}if(e.json!==!1&&a(s,["sort-package-json"])&&(i["**/package.json"]=r=>[`${n} exec sort-package-json ${c(r)}`]),e.markdown!==!1&&l&&(i={...i,"**/*.md":y(r=>[...p?[`${n} exec prettier --write ${c(r)}`]:[],...l?[`${n} exec markdownlint --fix --ignore '**/node_modules/**' --ignore '**/CHANGELOG.md' ${c(r)}`]:[],...f?[`${n} exec markdownlint-cli2 --fix '!**/node_modules/**' '!**/CHANGELOG.md' ${c(r)}`]:[]],"**/*.md"),"**/*.mdx":y(r=>[...p?[`${n} exec prettier --write ${c(r)}`]:[]],"**/*.mdx")}),e.secretlint!==!1&&a(s,["secretlint"])&&(i["**/*"]=r=>[`${n} exec secretlint ${c(r)}`]),e.stylesheets!==!1&&a(s,["stylelint"])){if(!Array.isArray(e.stylesheets.extensions)||e.stylesheets.extensions.length===0)throw new Error("The `extensions` option is required for the Stylesheets configuration.");i[`**/*.{${e.stylesheets.extensions.join(",")}}`]=r=>[...p?[`${n} exec prettier --ignore-unknown --write ${c(r)}`]:[],`${n} exec stylelint --fix`]}if(e.typescript!==!1&&a(s,["typescript"])){if(!Array.isArray(e.typescript.extensions)||e.typescript.extensions.length===0)throw new Error("The `extensions` option is required for the TypeScript configuration.");i[`**/*.{${e.typescript.extensions.join(",")}}`]=r=>{const x=new Set;return r.forEach(g=>{if(typeof e.typescript?.exclude=="object"&&Array.isArray(e.typescript.exclude)){let u=!1;if(e.typescript.exclude.forEach(b=>{!u&&g.includes(b)&&(u=!0)}),u){e.debug&&console.info(`Skipping ${g} as it's excluded in the settings.`);return}}try{const u=w("tsconfig.json",g);x.add(`${n} exec tsc --noEmit --project ${u}`)}catch(u){e.debug&&console.error(u)}}),[...x]}}return a(s,["vitest"])&&(i["**/?(*.){test,spec}.?(c|m)[jt]s?(x)"]=["vitest related --run"],i["**/__tests__/**/*.?(c|m)[jt]s?(x)"]=[`${n} exec vitest related --run`]),a(s,["jest"])&&(i["**/*.spec.{js,ts,tsx}"]=[`${n} exec jest --findRelatedTests`],i["**/*.test.{js,ts,tsx}"]=[`${n} exec jest --findRelatedTests`],i["**/?(*.){test,spec}.?(c|m)[jt]s?(x)"]=[`${n} exec jest --findRelatedTests`],i["**/__mocks__/*.{js,ts,tsx}"]=[`${n} exec jest --findRelatedTests`],i["**/__tests__/**/*.?(c|m)[jt]s?(x)"]=[`${n} exec jest --findRelatedTests`],i["**/__tests__/*.{js,ts,tsx}"]=[`${n} exec jest --findRelatedTests`],i["**/test/*.{js,ts,tsx}"]=[`${n} exec jest --findRelatedTests`]),a(s,["ava"])&&(i["**/(test|tests|__tests__)/**/*.js"]=r=>[`${n} exec ava ${c(r)}`],i["**/*.(spec|test).js"]=r=>[`${n} exec ava ${c(r)}`],i["**/test.js"]=r=>[`${n} exec ava ${c(r)}`],i["**/test-*.js"]=r=>[`${n} exec ava ${c(r)}`]),i},"defineConfig");export{le as defineConfig,X as eslintExtensions,ee as stylesheetsExtensions,Z as typescriptExtensions};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@anolilab/lint-staged-config",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.32",
|
|
4
4
|
"description": "Shareable Lint-Staged Config for any project.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"anolilab",
|
|
@@ -74,13 +74,13 @@
|
|
|
74
74
|
"dist"
|
|
75
75
|
],
|
|
76
76
|
"dependencies": {
|
|
77
|
-
"@visulima/fs": "3.1.
|
|
78
|
-
"@visulima/package": "^
|
|
77
|
+
"@visulima/fs": "3.1.9",
|
|
78
|
+
"@visulima/package": "^4.0.1",
|
|
79
79
|
"shell-quote": "^1.8.3",
|
|
80
|
-
"type-fest": "^
|
|
80
|
+
"type-fest": "^5.0.1"
|
|
81
81
|
},
|
|
82
82
|
"peerDependencies": {
|
|
83
|
-
"eslint": "^9.
|
|
83
|
+
"eslint": "^9.36.0",
|
|
84
84
|
"husky": "^8.x || ^9.x",
|
|
85
85
|
"jest": "^27.x || ^28.x",
|
|
86
86
|
"lint-staged": "^13.x || ^14.x|| ^15.x || ^16.x",
|