@anolilab/lint-staged-config 3.0.12 → 3.0.14

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,22 @@
1
+ ## @anolilab/lint-staged-config [3.0.14](https://github.com/anolilab/javascript-style-guide/compare/@anolilab/lint-staged-config@3.0.13...@anolilab/lint-staged-config@3.0.14) (2025-06-02)
2
+
3
+
4
+ ### Dependencies
5
+
6
+ * **@anolilab/eslint-config:** upgraded to 16.2.10
7
+
8
+ ## @anolilab/lint-staged-config [3.0.13](https://github.com/anolilab/javascript-style-guide/compare/@anolilab/lint-staged-config@3.0.12...@anolilab/lint-staged-config@3.0.13) (2025-06-01)
9
+
10
+ ### Bug Fixes
11
+
12
+ * enhance packem configuration with isolated declaration transformer and cjsInterop ([fb759fc](https://github.com/anolilab/javascript-style-guide/commit/fb759fc1246adb01d2f5d7a1b254eb036a86ec13))
13
+ * **lint-staged-config:** update dependencies in lint-staged-config ([4ae9f4b](https://github.com/anolilab/javascript-style-guide/commit/4ae9f4bf6867a0ea90960b65a60e2a78d1fe186e))
14
+
15
+
16
+ ### Dependencies
17
+
18
+ * **@anolilab/eslint-config:** upgraded to 16.2.9
19
+
1
20
  ## @anolilab/lint-staged-config [3.0.12](https://github.com/anolilab/javascript-style-guide/compare/@anolilab/lint-staged-config@3.0.11...@anolilab/lint-staged-config@3.0.12) (2025-06-01)
2
21
 
3
22
 
package/dist/bin.d.mts ADDED
@@ -0,0 +1 @@
1
+ export {};
package/dist/bin.mjs CHANGED
@@ -1,5 +1,7 @@
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{readFile as p,writeFileSync as r,ensureDirSync as $,isAccessibleSync as _}from"@visulima/fs";import{parsePackageJson as y,hasPackageJsonAnyDependency as d}from"@visulima/package";var w=Object.defineProperty,l=h((n,o)=>w(n,"name",{value:o,configurable:!0}),"c");const c=l(n=>_(n)?(console.warn(`⚠️ ${n} already exists;`),!0):!1,"checkIfFileExists"),I=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(c(s(n,i))){console.warn(`⚠️ ${i} already exists;`);return}const t=s(n,".lintstagedrc.js");r(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{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
+ const require = __cjs_mod__.createRequire(import.meta.url);
4
+ var w=Object.defineProperty,l=h((n,o)=>w(n,"name",{value:o,configurable:!0}),"c");const c=l(n=>_(n)?(console.warn(`⚠️ ${n} already exists;`),!0):!1,"checkIfFileExists"),I=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(c(s(n,i))){console.warn(`⚠️ ${i} already exists;`);return}const t=s(n,".lintstagedrc.js");r(t,`${o?'import { defineConfig } from "@anolilab/lint-staged-config"':'const { defineConfig } = require("@anolilab/lint-staged-config")'};
3
5
 
4
6
  ${o?"export default":"module.exports ="} defineConfig();
5
7
  `)},"writeLintStagedRc"),x=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(c(s(n,i))){console.warn(`⚠️ ${i} already exists;`);return}const t=s(n,".nano-staged.js");r(t,`${o?'import { defineConfig } from "@anolilab/lint-staged-config"':'const { defineConfig } = require("@anolilab/lint-staged-config")'};
@@ -0,0 +1,4 @@
1
+ import type { NormalizedPackageJson, PackageManager } from "@visulima/package";
2
+ import type { EslintConfig } from "../types.d.cts";
3
+ declare const createEslintCommands: (packageManager: PackageManager, packageJson: NormalizedPackageJson, eslintConfig: EslintConfig, filenames: string[]) => Promise<string[]>;
4
+ export = createEslintCommands;
@@ -0,0 +1,4 @@
1
+ import type { NormalizedPackageJson, PackageManager } from "@visulima/package";
2
+ import type { EslintConfig } from "../types.d.mts";
3
+ declare const createEslintCommands: (packageManager: PackageManager, packageJson: NormalizedPackageJson, eslintConfig: EslintConfig, filenames: string[]) => Promise<string[]>;
4
+ export default createEslintCommands;
@@ -0,0 +1,4 @@
1
+ import type { NormalizedPackageJson, PackageManager } from "@visulima/package";
2
+ import type { EslintConfig } from "../types.d.ts";
3
+ declare const createEslintCommands: (packageManager: PackageManager, packageJson: NormalizedPackageJson, eslintConfig: EslintConfig, filenames: string[]) => Promise<string[]>;
4
+ export = createEslintCommands;
@@ -0,0 +1,2 @@
1
+ declare const groupFilePathsByDirectoryName: (filePaths: string[]) => Record<string, string[]>;
2
+ export = groupFilePathsByDirectoryName;
@@ -0,0 +1,2 @@
1
+ declare const groupFilePathsByDirectoryName: (filePaths: string[]) => Record<string, string[]>;
2
+ export default groupFilePathsByDirectoryName;
@@ -0,0 +1,2 @@
1
+ declare const groupFilePathsByDirectoryName: (filePaths: string[]) => Record<string, string[]>;
2
+ export = groupFilePathsByDirectoryName;
@@ -0,0 +1,3 @@
1
+ import { ESLint } from "eslint";
2
+ declare const removeIgnoredFiles: (filenames: string[], eslint?: ESLint) => Promise<string[]>;
3
+ export = removeIgnoredFiles;
@@ -0,0 +1,3 @@
1
+ import { ESLint } from "eslint";
2
+ declare const removeIgnoredFiles: (filenames: string[], eslint?: ESLint) => Promise<string[]>;
3
+ export default removeIgnoredFiles;
@@ -0,0 +1,3 @@
1
+ import { ESLint } from "eslint";
2
+ declare const removeIgnoredFiles: (filenames: string[], eslint?: ESLint) => Promise<string[]>;
3
+ export = removeIgnoredFiles;
package/dist/index.d.cts CHANGED
@@ -1,32 +1,16 @@
1
- import { Configuration } from 'lint-staged';
2
-
3
- declare global {
4
- // eslint-disable-next-line @typescript-eslint/consistent-type-definitions -- It has to be an `interface` so that it can be merged.
5
- interface SymbolConstructor {
6
- readonly observable: symbol;
7
- }
8
- }
9
-
10
- interface EslintConfig {
11
- cache?: boolean;
12
- config?: string;
13
- extensions?: string[];
14
- "fix-type"?: string[];
15
- "max-warnings"?: number | string | false;
16
- rules?: string[];
17
- }
18
-
1
+ import type { Configuration } from "lint-staged";
2
+ import type { EslintConfig } from "./types.d.cts";
19
3
  interface StylesheetsConfig {
20
- extensions?: string[];
4
+ extensions?: (typeof stylesheetsExtensions)[number][];
21
5
  }
22
6
  interface TypescriptConfig {
23
7
  exclude?: string[];
24
- extensions?: string[];
8
+ extensions?: (typeof typescriptExtensions)[number][];
25
9
  }
26
- declare const eslintExtensions: string[];
27
- declare const typescriptExtensions: string[];
28
- declare const stylesheetsExtensions: string[];
29
- declare const defineConfig: (options?: {
10
+ export declare const eslintExtensions: readonly ["cjs", "js", "mjs", "cts", "ts", "mts", "yml", "yaml", "jsx", "tsx", "mdx", "toml", "json", "json5", "jsonc"];
11
+ export declare const typescriptExtensions: readonly ["cts", "ts", "mts", "tsx", "ctsx"];
12
+ export declare const stylesheetsExtensions: readonly ["css", "scss", "sass", "less", "styl", "stylus", "pcss", "postcss", "sss"];
13
+ export declare const defineConfig: (options?: {
30
14
  cwd?: string;
31
15
  debug?: boolean;
32
16
  eslint?: EslintConfig | false;
@@ -37,5 +21,4 @@ declare const defineConfig: (options?: {
37
21
  tests?: false;
38
22
  typescript?: TypescriptConfig | false;
39
23
  }) => Configuration;
40
-
41
- export { defineConfig, eslintExtensions, stylesheetsExtensions, typescriptExtensions };
24
+ export {};
package/dist/index.d.mts CHANGED
@@ -1,32 +1,16 @@
1
- import { Configuration } from 'lint-staged';
2
-
3
- declare global {
4
- // eslint-disable-next-line @typescript-eslint/consistent-type-definitions -- It has to be an `interface` so that it can be merged.
5
- interface SymbolConstructor {
6
- readonly observable: symbol;
7
- }
8
- }
9
-
10
- interface EslintConfig {
11
- cache?: boolean;
12
- config?: string;
13
- extensions?: string[];
14
- "fix-type"?: string[];
15
- "max-warnings"?: number | string | false;
16
- rules?: string[];
17
- }
18
-
1
+ import type { Configuration } from "lint-staged";
2
+ import type { EslintConfig } from "./types.d.mts";
19
3
  interface StylesheetsConfig {
20
- extensions?: string[];
4
+ extensions?: (typeof stylesheetsExtensions)[number][];
21
5
  }
22
6
  interface TypescriptConfig {
23
7
  exclude?: string[];
24
- extensions?: string[];
8
+ extensions?: (typeof typescriptExtensions)[number][];
25
9
  }
26
- declare const eslintExtensions: string[];
27
- declare const typescriptExtensions: string[];
28
- declare const stylesheetsExtensions: string[];
29
- declare const defineConfig: (options?: {
10
+ export declare const eslintExtensions: readonly ["cjs", "js", "mjs", "cts", "ts", "mts", "yml", "yaml", "jsx", "tsx", "mdx", "toml", "json", "json5", "jsonc"];
11
+ export declare const typescriptExtensions: readonly ["cts", "ts", "mts", "tsx", "ctsx"];
12
+ export declare const stylesheetsExtensions: readonly ["css", "scss", "sass", "less", "styl", "stylus", "pcss", "postcss", "sss"];
13
+ export declare const defineConfig: (options?: {
30
14
  cwd?: string;
31
15
  debug?: boolean;
32
16
  eslint?: EslintConfig | false;
@@ -37,5 +21,4 @@ declare const defineConfig: (options?: {
37
21
  tests?: false;
38
22
  typescript?: TypescriptConfig | false;
39
23
  }) => Configuration;
40
-
41
- export { defineConfig, eslintExtensions, stylesheetsExtensions, typescriptExtensions };
24
+ export {};
package/dist/index.d.ts CHANGED
@@ -1,32 +1,16 @@
1
- import { Configuration } from 'lint-staged';
2
-
3
- declare global {
4
- // eslint-disable-next-line @typescript-eslint/consistent-type-definitions -- It has to be an `interface` so that it can be merged.
5
- interface SymbolConstructor {
6
- readonly observable: symbol;
7
- }
8
- }
9
-
10
- interface EslintConfig {
11
- cache?: boolean;
12
- config?: string;
13
- extensions?: string[];
14
- "fix-type"?: string[];
15
- "max-warnings"?: number | string | false;
16
- rules?: string[];
17
- }
18
-
1
+ import type { Configuration } from "lint-staged";
2
+ import type { EslintConfig } from "./types.d.ts";
19
3
  interface StylesheetsConfig {
20
- extensions?: string[];
4
+ extensions?: (typeof stylesheetsExtensions)[number][];
21
5
  }
22
6
  interface TypescriptConfig {
23
7
  exclude?: string[];
24
- extensions?: string[];
8
+ extensions?: (typeof typescriptExtensions)[number][];
25
9
  }
26
- declare const eslintExtensions: string[];
27
- declare const typescriptExtensions: string[];
28
- declare const stylesheetsExtensions: string[];
29
- declare const defineConfig: (options?: {
10
+ export declare const eslintExtensions: readonly ["cjs", "js", "mjs", "cts", "ts", "mts", "yml", "yaml", "jsx", "tsx", "mdx", "toml", "json", "json5", "jsonc"];
11
+ export declare const typescriptExtensions: readonly ["cts", "ts", "mts", "tsx", "ctsx"];
12
+ export declare const stylesheetsExtensions: readonly ["css", "scss", "sass", "less", "styl", "stylus", "pcss", "postcss", "sss"];
13
+ export declare const defineConfig: (options?: {
30
14
  cwd?: string;
31
15
  debug?: boolean;
32
16
  eslint?: EslintConfig | false;
@@ -37,5 +21,4 @@ declare const defineConfig: (options?: {
37
21
  tests?: false;
38
22
  typescript?: TypescriptConfig | false;
39
23
  }) => Configuration;
40
-
41
- export { defineConfig, eslintExtensions, stylesheetsExtensions, typescriptExtensions };
24
+ export {};
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,parsePackageJson as T,findPackageManagerSync as O}from"@visulima/package";import{dirname as y,join as N}from"node:path";import{ESLint as C}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&&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=N(...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=y(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 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(`
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,parsePackageJson as T,findPackageManagerSync as O}from"@visulima/package";import{dirname as y,join as N}from"node:path";import{ESLint as C}from"eslint";import{quote as j}from"shell-quote";import{platform as R,env as q}from"node:process";var F=Object.defineProperty,g=d((t,e)=>F(t,"name",{value:e,configurable:!0}),"o$1");const G=g(t=>{const e=P("package.json",{cwd:t});return e&&y(e)},"packageDirectorySync"),L=g(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=g(t=>{const e=N(...t);if(e.startsWith("/"))return e;throw new TypeError("Joined path did not return an absolute path.")},"joinPaths"),w=g((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=y(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 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
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,h=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=h((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`)),{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":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{le as defineConfig,X as eslintExtensions,ee as stylesheetsExtensions,Z as typescriptExtensions};
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,h=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=h((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`)),{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":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($=>{if(typeof e.typescript?.exclude=="object"&&Array.isArray(e.typescript.exclude)){let u=!1;if(e.typescript.exclude.forEach(b=>{!u&&$.includes(b)&&(u=!0)}),u){e.debug&&console.info(`Skipping ${$} as it's excluded in the settings.`);return}}try{const u=w("tsconfig.json",$);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};
@@ -0,0 +1,11 @@
1
+ import type { Join } from "type-fest";
2
+ export type AbsolutePath = `/${string}`;
3
+ export type ConfigPath<A extends AbsolutePath, N extends string> = Join<[A, N], "/">;
4
+ export interface EslintConfig {
5
+ cache?: boolean;
6
+ config?: string;
7
+ extensions?: string[];
8
+ "fix-type"?: string[];
9
+ "max-warnings"?: number | string | false;
10
+ rules?: string[];
11
+ }
@@ -0,0 +1,11 @@
1
+ import type { Join } from "type-fest";
2
+ export type AbsolutePath = `/${string}`;
3
+ export type ConfigPath<A extends AbsolutePath, N extends string> = Join<[A, N], "/">;
4
+ export interface EslintConfig {
5
+ cache?: boolean;
6
+ config?: string;
7
+ extensions?: string[];
8
+ "fix-type"?: string[];
9
+ "max-warnings"?: number | string | false;
10
+ rules?: string[];
11
+ }
@@ -0,0 +1,11 @@
1
+ import type { Join } from "type-fest";
2
+ export type AbsolutePath = `/${string}`;
3
+ export type ConfigPath<A extends AbsolutePath, N extends string> = Join<[A, N], "/">;
4
+ export interface EslintConfig {
5
+ cache?: boolean;
6
+ config?: string;
7
+ extensions?: string[];
8
+ "fix-type"?: string[];
9
+ "max-warnings"?: number | string | false;
10
+ rules?: string[];
11
+ }
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Concatenate and escape a list of filenames that can be passed as args to prettier cli.
3
+ *
4
+ * Prettier and Stylelint have an issue with special characters in filenames,
5
+ * such as the ones uses for Next.js dynamic routes (ie: [id].tsx...)
6
+ * @link https://github.com/okonet/lint-staged/issues/676
7
+ *
8
+ * The @ type shouldn't be quoted, but it is.
9
+ * If a folder name contains a @, it will be escaped as \@ (example test/@types), which is wrong.
10
+ * @param filenames
11
+ * @returns Return concatenated and escaped filenames
12
+ */
13
+ declare const concatFiles: (filenames: string[]) => string;
14
+ export = concatFiles;
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Concatenate and escape a list of filenames that can be passed as args to prettier cli.
3
+ *
4
+ * Prettier and Stylelint have an issue with special characters in filenames,
5
+ * such as the ones uses for Next.js dynamic routes (ie: [id].tsx...)
6
+ * @link https://github.com/okonet/lint-staged/issues/676
7
+ *
8
+ * The @ type shouldn't be quoted, but it is.
9
+ * If a folder name contains a @, it will be escaped as \@ (example test/@types), which is wrong.
10
+ * @param filenames
11
+ * @returns Return concatenated and escaped filenames
12
+ */
13
+ declare const concatFiles: (filenames: string[]) => string;
14
+ export default concatFiles;
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Concatenate and escape a list of filenames that can be passed as args to prettier cli.
3
+ *
4
+ * Prettier and Stylelint have an issue with special characters in filenames,
5
+ * such as the ones uses for Next.js dynamic routes (ie: [id].tsx...)
6
+ * @link https://github.com/okonet/lint-staged/issues/676
7
+ *
8
+ * The @ type shouldn't be quoted, but it is.
9
+ * If a folder name contains a @, it will be escaped as \@ (example test/@types), which is wrong.
10
+ * @param filenames
11
+ * @returns Return concatenated and escaped filenames
12
+ */
13
+ declare const concatFiles: (filenames: string[]) => string;
14
+ export = concatFiles;
@@ -0,0 +1,3 @@
1
+ import type { AbsolutePath, ConfigPath } from "../types.d.cts";
2
+ declare const getNearestConfigPath: <N extends string = string, A extends AbsolutePath = AbsolutePath>(fileName: N, cwd?: A) => ConfigPath<A, N>;
3
+ export = getNearestConfigPath;
@@ -0,0 +1,3 @@
1
+ import type { AbsolutePath, ConfigPath } from "../types.d.mts";
2
+ declare const getNearestConfigPath: <N extends string = string, A extends AbsolutePath = AbsolutePath>(fileName: N, cwd?: A) => ConfigPath<A, N>;
3
+ export default getNearestConfigPath;
@@ -0,0 +1,3 @@
1
+ import type { AbsolutePath, ConfigPath } from "../types.d.ts";
2
+ declare const getNearestConfigPath: <N extends string = string, A extends AbsolutePath = AbsolutePath>(fileName: N, cwd?: A) => ConfigPath<A, N>;
3
+ export = getNearestConfigPath;
@@ -0,0 +1,2 @@
1
+ declare const isWindows: boolean;
2
+ export = isWindows;
@@ -0,0 +1,2 @@
1
+ declare const isWindows: boolean;
2
+ export default isWindows;
@@ -0,0 +1,2 @@
1
+ declare const isWindows: boolean;
2
+ export = isWindows;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@anolilab/lint-staged-config",
3
- "version": "3.0.12",
3
+ "version": "3.0.14",
4
4
  "description": "Shareable Lint-Staged Config for any project.",
5
5
  "keywords": [
6
6
  "anolilab",
@@ -74,8 +74,8 @@
74
74
  "dist"
75
75
  ],
76
76
  "dependencies": {
77
- "@visulima/fs": "3.1.2",
78
- "@visulima/package": "^3.5.4",
77
+ "@visulima/fs": "3.1.3",
78
+ "@visulima/package": "^3.5.6",
79
79
  "shell-quote": "^1.8.2"
80
80
  },
81
81
  "peerDependencies": {