@anolilab/lint-staged-config 5.1.0 → 6.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,43 @@
1
+ ## @anolilab/lint-staged-config [6.0.1](https://github.com/anolilab/javascript-style-guide/compare/@anolilab/lint-staged-config@6.0.0...@anolilab/lint-staged-config@6.0.1) (2026-02-28)
2
+
3
+ ### Bug Fixes
4
+
5
+ * **eslint-config:** disable css/no-invalid-at-rules for Tailwind CSS … ([#1000](https://github.com/anolilab/javascript-style-guide/issues/1000)) ([aa8b26b](https://github.com/anolilab/javascript-style-guide/commit/aa8b26b4cb711ad956a8d6360e2cc9f45d50565e))
6
+
7
+
8
+ ### Dependencies
9
+
10
+ * **@anolilab/eslint-config:** upgraded to 22.0.2
11
+
12
+ ## @anolilab/lint-staged-config [6.0.0](https://github.com/anolilab/javascript-style-guide/compare/@anolilab/lint-staged-config@5.1.0...@anolilab/lint-staged-config@6.0.0) (2026-02-21)
13
+
14
+ ### ⚠ BREAKING CHANGES
15
+
16
+ * **lint-staged-config:** Package is now ESM-only. The require export condition
17
+ and dist/index.cjs have been removed. CommonJS consumers must migrate
18
+ to ESM or use dynamic import().
19
+
20
+ Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
21
+
22
+ ### Features
23
+
24
+ * **lint-staged-config:** migrate to ESM-only, drop CJS support ([38bbac9](https://github.com/anolilab/javascript-style-guide/commit/38bbac90d8e15d63527af239cb0666f077b9d99e))
25
+
26
+ ### Bug Fixes
27
+
28
+ * resolve pre-commit hook failures and lint errors across packages ([a4707c3](https://github.com/anolilab/javascript-style-guide/commit/a4707c38941c7adb55a7a606f9689caa9c8f7962))
29
+
30
+ ### Miscellaneous Chores
31
+
32
+ * **lint-staged-config:** add prettier-config to NX implicit dependencies ([02c267e](https://github.com/anolilab/javascript-style-guide/commit/02c267eb5b2b3adff6f9c31d994d4f7bef47c6f9))
33
+ * **lint-staged-config:** simplify .prettierignore ([68bc97a](https://github.com/anolilab/javascript-style-guide/commit/68bc97acd76642eab0604626eecb529f0c1c87e1))
34
+
35
+
36
+ ### Dependencies
37
+
38
+ * **@anolilab/eslint-config:** upgraded to 22.0.0
39
+ * **@anolilab/prettier-config:** upgraded to 9.1.1
40
+
1
41
  ## @anolilab/lint-staged-config [5.1.0](https://github.com/anolilab/javascript-style-guide/compare/@anolilab/lint-staged-config@5.0.0...@anolilab/lint-staged-config@5.1.0) (2026-01-29)
2
42
 
3
43
  ### Code Refactoring
package/README.md CHANGED
@@ -109,7 +109,7 @@ The default configuration, automatically adds the following linting and formatti
109
109
  - [ESLint](https://eslint.org)
110
110
  - [Prettier](https://prettier.io)
111
111
  - [StyleLint](https://stylelint.io)
112
- - [SecretLint]()
112
+ - [SecretLint](https://github.com/secretlint/secretlint)
113
113
  - [CommitLint](https://commitlint.js.org)
114
114
  - [Vitest](https://vitest.dev) or [Jest](https://jestjs.io) or [AVA](https://github.com/avajs/ava)
115
115
  - [TypeScript](https://www.typescriptlang.org)
@@ -1,7 +1,5 @@
1
1
  #!/usr/bin/env node
2
- var g=Object.defineProperty;var h=(n,o)=>g(n,"name",{value:o,configurable:!0});import{existsSync as u}from"node:fs";import{join as s}from"node:path";import{exit as f}from"node:process";import{writeFileSync as c,ensureDirSync as p,isAccessibleSync as $}from"@visulima/fs";import{parsePackageJson as _,hasPackageJsonAnyDependency as d}from"@visulima/package";import __cjs_mod__ from "node:module"; // -- packem CommonJS require shim --
3
- const require = __cjs_mod__.createRequire(import.meta.url);
4
- var y=Object.defineProperty,l=h((n,o)=>y(n,"name",{value:o,configurable:!0}),"c");const r=l(n=>$(n)?(console.warn(`⚠️ ${n} already exists;`),!0):!1,"checkIfFileExists"),w=l(async(n,o)=>{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(r(s(n,i))){console.warn(`⚠️ ${i} already exists;`);return}const t=s(n,".lintstagedrc.js");c(t,`${o?'import { defineConfig } from "@anolilab/lint-staged-config"':'const { defineConfig } = require("@anolilab/lint-staged-config")'};
2
+ var g=Object.defineProperty;var h=(n,o)=>g(n,"name",{value:o,configurable:!0});import{existsSync as u}from"node:fs";import{join as s}from"node:path";import{exit as f}from"node:process";import{writeFileSync as c,ensureDirSync as p,isAccessibleSync as $}from"@visulima/fs";import{parsePackageJson as _,hasPackageJsonAnyDependency as d}from"@visulima/package";var y=Object.defineProperty,l=h((n,o)=>y(n,"name",{value:o,configurable:!0}),"c");const r=l(n=>$(n)?(console.warn(`⚠️ ${n} already exists;`),!0):!1,"checkIfFileExists"),w=l(async(n,o)=>{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(r(s(n,i))){console.warn(`⚠️ ${i} already exists;`);return}const t=s(n,".lintstagedrc.js");c(t,`${o?'import { defineConfig } from "@anolilab/lint-staged-config"':'const { defineConfig } = require("@anolilab/lint-staged-config")'};
5
3
 
6
4
  ${o?"export default":"module.exports ="} defineConfig();
7
5
  `)},"writeLintStagedRc"),I=l(async(n,o)=>{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(r(s(n,i))){console.warn(`⚠️ ${i} already exists;`);return}const t=s(n,".nano-staged.js");c(t,`${o?'import { defineConfig } from "@anolilab/lint-staged-config"':'const { defineConfig } = require("@anolilab/lint-staged-config")'};
package/dist/index.js ADDED
@@ -0,0 +1 @@
1
+ import"node:fs";import"@visulima/package";import{d as n,e as o,s as p,t as r}from"./packem_shared/index-eCPAX7na.js";export{n as defineConfig,o as eslintExtensions,p as stylesheetsExtensions,r as typescriptExtensions};
@@ -0,0 +1,5 @@
1
+ var g=Object.defineProperty;var l=(e,n)=>g(e,"name",{value:n,configurable:!0});import{hasPackageJsonAnyDependency as f}from"@visulima/package";import{n as $,P as d}from"../packem_shared/index-eCPAX7na.js";import{dirname as y}from"node:path";import{ESLint as v}from"eslint";import{quote as x}from"shell-quote";var j=Object.defineProperty,w=l((e,n)=>j(e,"name",{value:n,configurable:!0}),"i");const b=w(e=>{const n={};return e.forEach(t=>{const r=y(t);n[r]||(n[r]=[]),n[r].push(t)}),n},"groupFilePathsByDirectoryName");var P=Object.defineProperty,E=l((e,n)=>P(e,"name",{value:n,configurable:!0}),"o");const N=E(async(e,n=new v)=>{const t=(await Promise.allSettled(e.map(async r=>await n.isPathIgnored(r)))).map(r=>{if(r.status==="fulfilled")return r.value;throw console.error(`
2
+ Unable to determine if file is ignored.
3
+
4
+
5
+ ${r.reason}`),new Error("Stopping lint-staged because of an error.")});return e.filter((r,a)=>!t[a]).map(r=>`"${$?r:x([r])}"`)},"removeIgnoredFiles");var O=Object.defineProperty,p=l((e,n)=>O(e,"name",{value:n,configurable:!0}),"m");const s=".eslintrc",k=p((e,n)=>{const t=[];e["max-warnings"]!==void 0&&Number.isNaN(e["max-warnings"])?t.push(`--max-warnings=${e["max-warnings"]}`):e["max-warnings"]!==!1&&t.push("--max-warnings=0");const r=[];f(n,["eslint-plugin-react-hooks"])&&r.push("react-hooks/exhaustive-deps:off"),f(n,["eslint-plugin-eslint-comments"])&&r.push("eslint-comments/no-unused-disable:off");const a=[...e.rules??[],...r].filter(o=>o.trim().length>0);a.length>0&&t.push(a.map(o=>`--rule "${o}"`).join(" "));const i=[...e["fix-type"]??["layout"]].filter(o=>o.trim().length>0);return i.length>0&&t.push(`--fix-type ${i.join(",")}`,"--fix"),e.cache&&t.push("--cache"),t},"createEslintArguments"),B=p(async(e,n,t,r)=>{const a=await N(r),i=k(t,n);if(t.config)return a.length===0?[]:(i.push(`--config ${t.config}`),[`${e} exec eslint ${i.join(" ")} ${a.join(" ")}`]);const o=b(a),u=[];return Object.values(o).forEach(m=>{let c;[s,`${s}.js`,`${s}.cjs`,`${s}.json`,`${s}.yaml`,`${s}.yml`].forEach(h=>{if(!c)try{c=d(h,m[0])}catch{}}),c&&u.push(`${e} exec eslint ${i.join(" ")} --config ${c} ${m.join(" ")}`)}),u},"createEslintCommands");export{B as default};
@@ -0,0 +1 @@
1
+ var $=Object.defineProperty;var f=(n,e)=>$(n,"name",{value:e,configurable:!0});import{existsSync as h}from"node:fs";import{parsePackageJsonSync as w,findPackageManagerSync as k,hasPackageJsonAnyDependency as a}from"@visulima/package";import{quote as _}from"shell-quote";import{platform as v,env as E}from"node:process";import{dirname as b,join as P}from"node:path";import{findUpSync as A,isAccessibleSync as T}from"@visulima/fs";const S=v==="win32"||/^(msys|cygwin)$/u.test(E.OSTYPE??"");var C=Object.defineProperty,R=f((n,e)=>C(n,"name",{value:e,configurable:!0}),"t");const o=R(n=>n.map(e=>`"${S?e:_([e])}"`).join(" ").replaceAll("/@","/@"),"concatFiles");var O=Object.defineProperty,x=f((n,e)=>O(n,"name",{value:e,configurable:!0}),"o");const N=x(n=>{const e=A("package.json",{cwd:n});return e&&b(e)},"packageDirectorySync"),q=x(n=>{const e=N(n??process.cwd());if(e?.startsWith("/"))return e;throw new Error(`Cannot determine the nearest root of the package for the file: ${n}!`)},"getNearestPackageRootPath"),G=x(n=>{const e=P(...n);if(e.startsWith("/"))return e;throw new TypeError("Joined path did not return an absolute path.")},"joinPaths"),J=x((n,e)=>{const l=q(e),i=G([l,n]);if(T(i))return i;throw new Error(`Cannot locate nearest "${n}" file!`)},"getNearestConfigPath");var L=Object.defineProperty,j=f((n,e)=>L(n,"name",{value:e,configurable:!0}),"g");const D=["cjs","js","mjs","cts","ts","mts","yml","yaml","jsx","tsx","mdx","toml","json","json5","jsonc"],H=["cts","ts","mts","tsx","ctsx"],M=["css","scss","sass","less","styl","stylus","pcss","postcss","sss"],K=j((n={})=>{const e={debug:!1,eslint:{extensions:D},stylesheets:{extensions:M},typescript:{exclude:[],extensions:H},...n},l=e.cwd||process.cwd();if(!h(`${l}/package.json`))throw new Error(`No package.json found in the current working directory: ${l}; Please adjust the "cwd" option.`);const i=w(`${l}/package.json`,{resolveCatalogs:!0}),{packageManager:t}=k(l);e.debug&&console.debug("Package manager found:",t);const u=a(i,["markdownlint-cli"]),m=a(i,["markdownlint-cli2"]),p=a(i,["prettier"]);let r={};if(e.eslint!==!1&&a(i,["eslint"])){if(!Array.isArray(e.eslint.extensions)||e.eslint.extensions.length===0)throw new Error("The `extensions` option is required for the ESLint configuration.");!u&&!m&&e.eslint.extensions.push("md"),r[`**/*.{${e.eslint.extensions.join(",")}}`]=async s=>{const{default:d}=await import("../packem_chunks/create-eslint-commands.js");return[...p?[`${t} exec prettier --write ${o(s)}`]:[],...await d(t,i,e.eslint,s)]}}if(e.json!==!1&&a(i,["sort-package-json"])&&(r["**/package.json"]=s=>[`${t} exec sort-package-json ${o(s)}`]),e.markdown!==!1&&u&&(r={...r,"**/*.md":j(s=>[...p?[`${t} exec prettier --write ${o(s)}`]:[],...u?[`${t} exec markdownlint --fix --ignore '**/node_modules/**' --ignore '**/CHANGELOG.md' ${o(s)}`]:[],...m?[`${t} exec markdownlint-cli2 --fix '!**/node_modules/**' '!**/CHANGELOG.md' ${o(s)}`]:[]],"**/*.md"),"**/*.mdx":j(s=>[...p?[`${t} exec prettier --write ${o(s)}`]:[]],"**/*.mdx")}),e.secretlint!==!1&&a(i,["secretlint"])&&(r["**/*"]=s=>[`${t} exec secretlint ${o(s)}`]),e.stylesheets!==!1&&a(i,["stylelint"])){if(!Array.isArray(e.stylesheets.extensions)||e.stylesheets.extensions.length===0)throw new Error("The `extensions` option is required for the Stylesheets configuration.");r[`**/*.{${e.stylesheets.extensions.join(",")}}`]=s=>[...p?[`${t} exec prettier --ignore-unknown --write ${o(s)}`]:[],`${t} exec stylelint --fix`]}if(e.typescript!==!1&&a(i,["typescript"])){if(!Array.isArray(e.typescript.extensions)||e.typescript.extensions.length===0)throw new Error("The `extensions` option is required for the TypeScript configuration.");r[`**/*.{${e.typescript.extensions.join(",")}}`]=s=>{const d=new Set;return s.forEach(y=>{if(typeof e.typescript?.exclude=="object"&&Array.isArray(e.typescript.exclude)){let c=!1;if(e.typescript.exclude.forEach(g=>{!c&&y.includes(g)&&(c=!0)}),c){e.debug&&console.info(`Skipping ${y} as it's excluded in the settings.`);return}}try{const c=J("tsconfig.json",y);d.add(`${t} exec tsc --noEmit --project ${c}`)}catch(c){e.debug&&console.error(c)}}),[...d]}}return a(i,["vitest"])&&(r["**/?(*.){test,spec}.?(c|m)[jt]s?(x)"]=["vitest related --run"],r["**/__tests__/**/*.?(c|m)[jt]s?(x)"]=[`${t} exec vitest related --run`]),a(i,["jest"])&&(r["**/*.spec.{js,ts,tsx}"]=[`${t} exec jest --findRelatedTests`],r["**/*.test.{js,ts,tsx}"]=[`${t} exec jest --findRelatedTests`],r["**/?(*.){test,spec}.?(c|m)[jt]s?(x)"]=[`${t} exec jest --findRelatedTests`],r["**/__mocks__/*.{js,ts,tsx}"]=[`${t} exec jest --findRelatedTests`],r["**/__tests__/**/*.?(c|m)[jt]s?(x)"]=[`${t} exec jest --findRelatedTests`],r["**/__tests__/*.{js,ts,tsx}"]=[`${t} exec jest --findRelatedTests`],r["**/test/*.{js,ts,tsx}"]=[`${t} exec jest --findRelatedTests`]),a(i,["ava"])&&(r["**/(test|tests|__tests__)/**/*.js"]=s=>[`${t} exec ava ${o(s)}`],r["**/*.(spec|test).js"]=s=>[`${t} exec ava ${o(s)}`],r["**/test.js"]=s=>[`${t} exec ava ${o(s)}`],r["**/test-*.js"]=s=>[`${t} exec ava ${o(s)}`]),r},"defineConfig");export{J as P,K as d,D as e,S as n,M as s,H as t};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@anolilab/lint-staged-config",
3
- "version": "5.1.0",
3
+ "version": "6.0.1",
4
4
  "description": "Shareable Lint-Staged Config for any project.",
5
5
  "keywords": [
6
6
  "anolilab",
@@ -43,29 +43,15 @@
43
43
  "type": "module",
44
44
  "exports": {
45
45
  ".": {
46
- "import": {
47
- "types": "./dist/index.d.mts",
48
- "default": "./dist/index.mjs"
49
- },
50
- "require": {
51
- "types": "./dist/index.d.cts",
52
- "default": "./dist/index.cjs"
53
- }
46
+ "types": "./dist/index.d.ts",
47
+ "default": "./dist/index.js"
54
48
  },
55
49
  "./package.json": "./package.json"
56
50
  },
57
- "main": "dist/index.cjs",
58
- "module": "dist/index.mjs",
51
+ "module": "dist/index.js",
59
52
  "types": "dist/index.d.ts",
60
- "typesVersions": {
61
- ">=5.0": {
62
- ".": [
63
- "./dist/index.d.ts"
64
- ]
65
- }
66
- },
67
53
  "bin": {
68
- "lint-stage-config:install": "./dist/bin.mjs"
54
+ "lint-stage-config:install": "./dist/bin.js"
69
55
  },
70
56
  "files": [
71
57
  "CHANGELOG.md",
@@ -77,18 +63,18 @@
77
63
  "@visulima/fs": "4.1.0",
78
64
  "@visulima/package": "^4.1.7",
79
65
  "shell-quote": "^1.8.3",
80
- "type-fest": "5.4.2"
66
+ "type-fest": "5.4.4"
81
67
  },
82
68
  "peerDependencies": {
83
- "eslint": "^9.39.2",
84
- "husky": "^8.x || ^9.x",
85
- "jest": "^27.x || ^28.x || ^29.0.0",
86
- "lint-staged": "^13.x || ^14.x|| ^15.x || ^16.x",
69
+ "eslint": "9.39.3",
70
+ "husky": "^9.x",
71
+ "jest": "^29.0.0",
72
+ "lint-staged": "^16.x",
87
73
  "nano-staged": "^0.9.0",
88
74
  "prettier": "3.8.1",
89
- "secretlint": "^7.x || ^8.x || ^10.0.0 || ^11.0.0",
90
- "stylelint": "^15.x || ^16.x",
91
- "vitest": "^1.x || ^2.x || ^3.x || ^4.0.0"
75
+ "secretlint": "^11.0.0",
76
+ "stylelint": "^16.x || ^17.x",
77
+ "vitest": "^3.x || ^4.x"
92
78
  },
93
79
  "peerDependenciesMeta": {
94
80
  "eslint": {
@@ -116,6 +102,7 @@
116
102
  "optional": true
117
103
  }
118
104
  },
105
+ "optionalDependencies": {},
119
106
  "engines": {
120
107
  "node": ">=20.18.* <=25.*"
121
108
  },
package/dist/index.cjs DELETED
@@ -1,5 +0,0 @@
1
- "use strict";var D=Object.defineProperty;var f=(s,e)=>D(s,"name",{value:e,configurable:!0});Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const J=require("node:fs"),o=require("@visulima/package"),m=require("node:path"),w=require("@visulima/fs"),T=require("eslint"),k=require("shell-quote"),j=require("node:process");var q=Object.defineProperty,h=f((s,e)=>q(s,"name",{value:e,configurable:!0}),"o$1");const O=h(s=>{const e=w.findUpSync("package.json",{cwd:s});return e&&m.dirname(e)},"packageDirectorySync"),C=h(s=>{const e=O(s??process.cwd());if(e?.startsWith("/"))return e;throw new Error(`Cannot determine the nearest root of the package for the file: ${s}!`)},"getNearestPackageRootPath"),N=h(s=>{const e=m.join(...s);if(e.startsWith("/"))return e;throw new TypeError("Joined path did not return an absolute path.")},"joinPaths"),v=h((s,e)=>{const i=C(e),t=N([i,s]);if(w.isAccessibleSync(t))return t;throw new Error(`Cannot locate nearest "${s}" file!`)},"getNearestConfigPath");var R=Object.defineProperty,G=f((s,e)=>R(s,"name",{value:e,configurable:!0}),"i$1");const L=G(s=>{const e={};return s.forEach(i=>{const t=m.dirname(i);e[t]||(e[t]=[]),e[t].push(i)}),e},"groupFilePathsByDirectoryName"),P=j.platform==="win32"||/^(msys|cygwin)$/u.test(j.env.OSTYPE??"");var M=Object.defineProperty,F=f((s,e)=>M(s,"name",{value:e,configurable:!0}),"o");const H=F(async(s,e=new T.ESLint)=>{const i=(await Promise.allSettled(s.map(async t=>await e.isPathIgnored(t)))).map(t=>{if(t.status==="fulfilled")return t.value;throw console.error(`
2
- Unable to determine if file is ignored.
3
-
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=L(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(`${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.d.cts DELETED
@@ -1,34 +0,0 @@
1
- import { Configuration } from 'lint-staged';
2
-
3
- interface EslintConfig {
4
- cache?: boolean;
5
- config?: string;
6
- extensions?: string[];
7
- "fix-type"?: string[];
8
- "max-warnings"?: number | string | false;
9
- rules?: string[];
10
- }
11
-
12
- interface StylesheetsConfig {
13
- extensions?: (typeof stylesheetsExtensions)[number][];
14
- }
15
- interface TypescriptConfig {
16
- exclude?: string[];
17
- extensions?: (typeof typescriptExtensions)[number][];
18
- }
19
- declare const eslintExtensions: readonly ["cjs", "js", "mjs", "cts", "ts", "mts", "yml", "yaml", "jsx", "tsx", "mdx", "toml", "json", "json5", "jsonc"];
20
- declare const typescriptExtensions: readonly ["cts", "ts", "mts", "tsx", "ctsx"];
21
- declare const stylesheetsExtensions: readonly ["css", "scss", "sass", "less", "styl", "stylus", "pcss", "postcss", "sss"];
22
- declare const defineConfig: (options?: {
23
- cwd?: string;
24
- debug?: boolean;
25
- eslint?: EslintConfig | false;
26
- json?: false;
27
- markdown?: false;
28
- secretlint?: false;
29
- stylesheets?: StylesheetsConfig | false;
30
- tests?: false;
31
- typescript?: TypescriptConfig | false;
32
- }) => Configuration;
33
-
34
- export { defineConfig, eslintExtensions, stylesheetsExtensions, typescriptExtensions };
package/dist/index.d.mts DELETED
@@ -1,34 +0,0 @@
1
- import { Configuration } from 'lint-staged';
2
-
3
- interface EslintConfig {
4
- cache?: boolean;
5
- config?: string;
6
- extensions?: string[];
7
- "fix-type"?: string[];
8
- "max-warnings"?: number | string | false;
9
- rules?: string[];
10
- }
11
-
12
- interface StylesheetsConfig {
13
- extensions?: (typeof stylesheetsExtensions)[number][];
14
- }
15
- interface TypescriptConfig {
16
- exclude?: string[];
17
- extensions?: (typeof typescriptExtensions)[number][];
18
- }
19
- declare const eslintExtensions: readonly ["cjs", "js", "mjs", "cts", "ts", "mts", "yml", "yaml", "jsx", "tsx", "mdx", "toml", "json", "json5", "jsonc"];
20
- declare const typescriptExtensions: readonly ["cts", "ts", "mts", "tsx", "ctsx"];
21
- declare const stylesheetsExtensions: readonly ["css", "scss", "sass", "less", "styl", "stylus", "pcss", "postcss", "sss"];
22
- declare const defineConfig: (options?: {
23
- cwd?: string;
24
- debug?: boolean;
25
- eslint?: EslintConfig | false;
26
- json?: false;
27
- markdown?: false;
28
- secretlint?: false;
29
- stylesheets?: StylesheetsConfig | false;
30
- tests?: false;
31
- typescript?: TypescriptConfig | false;
32
- }) => Configuration;
33
-
34
- export { defineConfig, eslintExtensions, stylesheetsExtensions, typescriptExtensions };
package/dist/index.mjs DELETED
@@ -1,5 +0,0 @@
1
- var E=Object.defineProperty;var d=(t,e)=>E(t,"name",{value:e,configurable:!0});import{existsSync as _}from"node:fs";import{hasPackageJsonAnyDependency as a,parsePackageJsonSync as P,findPackageManagerSync as S}from"@visulima/package";import{dirname as y,join as A}from"node:path";import{findUpSync as T,isAccessibleSync as O}from"@visulima/fs";import{ESLint as C}from"eslint";import{quote as j}from"shell-quote";import{platform as N,env as R}from"node:process";var q=Object.defineProperty,$=d((t,e)=>q(t,"name",{value:e,configurable:!0}),"o$1");const G=$(t=>{const e=T("package.json",{cwd:t});return e&&y(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=A(...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(O(s))return s;throw new Error(`Cannot locate nearest "${t}" file!`)},"getNearestConfigPath");var F=Object.defineProperty,J=d((t,e)=>F(t,"name",{value:e,configurable:!0}),"i$1");const H=J(t=>{const e={};return t.forEach(o=>{const s=y(o);e[s]||(e[s]=[]),e[s].push(o)}),e},"groupFilePathsByDirectoryName"),v=N==="win32"||/^(msys|cygwin)$/u.test(R.OSTYPE??"");var I=Object.defineProperty,M=d((t,e)=>I(t,"name",{value:e,configurable:!0}),"o");const U=M(async(t,e=new C)=>{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
- Unable to determine if file is ignored.
3
-
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 W=Object.defineProperty,k=d((t,e)=>W(t,"name",{value:e,configurable:!0}),"m");const m=".eslintrc",B=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"),Y=k(async(t,e,o,s)=>{const n=await U(s),l=B(o,e);if(o.config)return l.push(`--config ${o.config}`),[`${t} exec eslint ${l.join(" ")} ${n.join(" ")}`];const f=H(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 z=Object.defineProperty,K=d((t,e)=>z(t,"name",{value:e,configurable:!0}),"r");const c=K(t=>t.map(e=>`"${v?e:j([e])}"`).join(" ").replaceAll("/@","/@"),"concatFiles");var Q=Object.defineProperty,h=d((t,e)=>Q(t,"name",{value:e,configurable:!0}),"f");const V=["cjs","js","mjs","cts","ts","mts","yml","yaml","jsx","tsx","mdx","toml","json","json5","jsonc"],X=["cts","ts","mts","tsx","ctsx"],Z=["css","scss","sass","less","styl","stylus","pcss","postcss","sss"],ce=h((t={})=>{const e={debug:!1,eslint:{extensions:V},stylesheets:{extensions:Z},typescript:{exclude:[],extensions:X},...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=P(`${o}/package.json`,{resolveCatalogs:!0}),{packageManager:n}=S(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 Y(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":h(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":h(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{ce as defineConfig,V as eslintExtensions,Z as stylesheetsExtensions,X as typescriptExtensions};