@xylabs/ts-scripts-yarn3 5.1.7 → 5.1.8

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.
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/bin/package/fix.ts","../../../src/actions/package/lint.ts"],"sourcesContent":["#!/usr/bin/env node\n\nimport chalk from 'chalk'\n\nimport { packageLint } from '../../actions/index.ts'\n\npackageLint(true)\n .then((value) => {\n if (value) {\n process.exit(value)\n }\n })\n .catch((reason) => {\n console.error(chalk.red(reason))\n process.exit(-1)\n })\n","import { readdirSync } from 'node:fs'\nimport path from 'node:path'\nimport { cwd } from 'node:process'\nimport { pathToFileURL } from 'node:url'\n\nimport chalk from 'chalk'\nimport { ESLint } from 'eslint'\nimport { findUp } from 'find-up'\n\nconst dumpMessages = (lintResults: ESLint.LintResult[]) => {\n const colors: ('white' | 'red' | 'yellow')[] = ['white', 'yellow', 'red']\n const severity: string[] = ['none', 'warning', 'error']\n\n for (const lintResult of lintResults) {\n if (lintResult.messages.length > 0) {\n console.log(chalk.gray(`\\n${lintResult.filePath}`))\n for (const message of lintResult.messages) {\n console.log(\n chalk.gray(`\\t${message.line}:${message.column}`),\n chalk[colors[message.severity]](`\\t${severity[message.severity]}`),\n chalk.white(`\\t${message.message}`),\n chalk.gray(`\\t${message.ruleId}`),\n )\n }\n }\n }\n}\n\nasync function getRootESLintConfig() {\n // Locate the root eslint.config.mjs\n const configPath = await findUp('eslint.config.mjs')\n\n if (!configPath) {\n throw new Error('eslint.config.mjs not found in the monorepo')\n }\n\n return pathToFileURL(configPath)\n}\n\nexport const packageLint = async (fix = false) => {\n const configPath = await getRootESLintConfig()\n const { default: eslintConfig } = await import(configPath.href)\n\n // List of folders to ignore\n const ignoreFolders = new Set(['node_modules', 'dist', 'packages'])\n\n function getFiles(dir: string, ignorePatterns: string[]): string[] {\n return readdirSync(dir, { withFileTypes: true })\n .flatMap((dirent) => {\n const res = path.resolve(dir, dirent.name)\n\n // Exclude ignored paths\n if (ignorePatterns.some(pattern => dir.includes(pattern))) return []\n\n return dirent.isDirectory()\n ? getFiles(res, ignorePatterns)\n : (res.endsWith('.ts') || res.endsWith('.tsx') || res.endsWith('.js') || res.endsWith('.jsx')) ? [res] : []\n })\n }\n\n const engine = new ESLint({ baseConfig: [...eslintConfig], fix })\n\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const ignorePatterns = [...eslintConfig.find((cfg: any) => cfg.ignores)?.ignores ?? [], ...ignoreFolders]\n\n const lintResults = await engine.lintFiles(getFiles(cwd(), ignorePatterns))\n\n dumpMessages(lintResults)\n\n return lintResults.reduce((prev, lintResult) => prev + lintResult.errorCount, 0)\n}\n"],"mappings":";;;;;AAEA,OAAOA,YAAW;;;ACFlB,SAASC,mBAAmB;AAC5B,OAAOC,UAAU;AACjB,SAASC,WAAW;AACpB,SAASC,qBAAqB;AAE9B,OAAOC,WAAW;AAClB,SAASC,cAAc;AACvB,SAASC,cAAc;AAEvB,IAAMC,eAAe,wBAACC,gBAAAA;AACpB,QAAMC,SAAyC;IAAC;IAAS;IAAU;;AACnE,QAAMC,WAAqB;IAAC;IAAQ;IAAW;;AAE/C,aAAWC,cAAcH,aAAa;AACpC,QAAIG,WAAWC,SAASC,SAAS,GAAG;AAClCC,cAAQC,IAAIC,MAAMC,KAAK;EAAKN,WAAWO,QAAQ,EAAE,CAAA;AACjD,iBAAWC,WAAWR,WAAWC,UAAU;AACzCE,gBAAQC,IACNC,MAAMC,KAAK,IAAKE,QAAQC,IAAI,IAAID,QAAQE,MAAM,EAAE,GAChDL,MAAMP,OAAOU,QAAQT,QAAQ,CAAC,EAAE,IAAKA,SAASS,QAAQT,QAAQ,CAAC,EAAE,GACjEM,MAAMM,MAAM,IAAKH,QAAQA,OAAO,EAAE,GAClCH,MAAMC,KAAK,IAAKE,QAAQI,MAAM,EAAE,CAAA;MAEpC;IACF;EACF;AACF,GAjBqB;AAmBrB,eAAeC,sBAAAA;AAEb,QAAM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AIA,OAAO;AACTC,YAAQC,KAAKF,KAAAA;EACf;AACF,CAAA,EACCG,MAAM,CAACC,WAAAA;AACNC,UAAQC,MAAMC,OAAMC,IAAIJ,MAAAA,CAAAA;AACxBH,UAAQC,KAAK,EAAC;AAChB,CAAA;","names":["chalk","readdirSync","path","cwd","pathToFileURL","chalk","ESLint","findUp","dumpMessages","lintResults","colors","severity","lintResult","messages","length","console","log","chalk","gray","filePath","message","line","column","white","ruleId","getRootESLintConfig","configPath","findUp","Error","pathToFileURL","packageLint","fix","default","eslintConfig","href","ignoreFolders","Set","getFiles","dir","ignorePatterns","readdirSync","withFileTypes","flatMap","dirent","res","path","resolve","name","some","pattern","includes","isDirectory","endsWith","engine","ESLint","baseConfig","find","cfg","ignores","lintFiles","cwd","reduce","prev","errorCount","packageLint","then","value","process","exit","catch","reason","console","error","chalk","red"]}
1
+ {"version":3,"sources":["../../../src/bin/package/fix.ts","../../../src/actions/package/lint.ts"],"sourcesContent":["#!/usr/bin/env node\n\nimport chalk from 'chalk'\n\nimport { packageLint } from '../../actions/index.ts'\n\npackageLint(true)\n .then((value) => {\n if (value) {\n process.exit(value)\n }\n })\n .catch((reason) => {\n console.error(chalk.red(reason))\n process.exit(-1)\n })\n","import { readdirSync } from 'node:fs'\nimport path from 'node:path'\nimport { cwd } from 'node:process'\nimport { pathToFileURL } from 'node:url'\n\nimport chalk from 'chalk'\nimport { ESLint } from 'eslint'\nimport { findUp } from 'find-up'\nimport picomatch from 'picomatch'\n\nconst dumpMessages = (lintResults: ESLint.LintResult[]) => {\n const colors: ('white' | 'red' | 'yellow')[] = ['white', 'yellow', 'red']\n const severity: string[] = ['none', 'warning', 'error']\n\n for (const lintResult of lintResults) {\n if (lintResult.messages.length > 0) {\n console.log(chalk.gray(`\\n${lintResult.filePath}`))\n for (const message of lintResult.messages) {\n console.log(\n chalk.gray(`\\t${message.line}:${message.column}`),\n chalk[colors[message.severity]](`\\t${severity[message.severity]}`),\n chalk.white(`\\t${message.message}`),\n chalk.gray(`\\t${message.ruleId}`),\n )\n }\n }\n }\n}\n\nasync function getRootESLintConfig() {\n // Locate the root eslint.config.mjs\n const configPath = await findUp('eslint.config.mjs')\n\n if (!configPath) {\n throw new Error('eslint.config.mjs not found in the monorepo')\n }\n\n return pathToFileURL(configPath)\n}\n\nfunction getFiles(dir: string, ignoreFolders: string[]): string[] {\n const currentDirectory = cwd()\n return readdirSync(dir, { withFileTypes: true })\n .flatMap((dirent) => {\n const res = path.resolve(dir, dirent.name)\n const subDirectory = dir.split(currentDirectory)[1]\n const relativePath = subDirectory ? `${subDirectory}/${dirent.name}` : dirent.name\n\n const ignoreMatchers = ignoreFolders.map(pattern => picomatch(pattern))\n\n // Exclude ignored paths\n if (ignoreMatchers.some(isMatch => isMatch(relativePath))) return []\n\n return dirent.isDirectory()\n ? getFiles(res, ignoreFolders)\n : [res]\n })\n}\n\nexport const packageLint = async (fix = false) => {\n const configPath = await getRootESLintConfig()\n const { default: eslintConfig } = await import(configPath.href)\n\n // List of folders to ignore\n const ignoreFolders = ['node_modules', 'dist', 'packages', '.git', 'build']\n\n const engine = new ESLint({\n baseConfig: [...eslintConfig], fix, warnIgnored: false,\n })\n\n const files = getFiles(cwd(), ignoreFolders)\n const lintResults = await engine.lintFiles(files)\n\n dumpMessages(lintResults)\n\n return lintResults.reduce((prev, lintResult) => prev + lintResult.errorCount, 0)\n}\n"],"mappings":";;;;;AAEA,OAAOA,YAAW;;;ACFlB,SAASC,mBAAmB;AAC5B,OAAOC,UAAU;AACjB,SAASC,WAAW;AACpB,SAASC,qBAAqB;AAE9B,OAAOC,WAAW;AAClB,SAASC,cAAc;AACvB,SAASC,cAAc;AACvB,OAAOC,eAAe;AAEtB,IAAMC,eAAe,wBAACC,gBAAAA;AACpB,QAAMC,SAAyC;IAAC;IAAS;IAAU;;AACnE,QAAMC,WAAqB;IAAC;IAAQ;IAAW;;AAE/C,aAAWC,cAAcH,aAAa;AACpC,QAAIG,WAAWC,SAASC,SAAS,GAAG;A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zB,QAAM,EAAE8B,SAASC,aAAY,IAAK,MAAM,OAAO9B,WAAW+B;AAG1D,QAAMzB,gBAAgB;IAAC;IAAgB;IAAQ;IAAY;IAAQ;;AAEnE,QAAM0B,SAAS,IAAIC,OAAO;IACxBC,YAAY;SAAIJ;;IAAeF;IAAKO,aAAa;EACnD,CAAA;AAEA,QAAMC,QAAQhC,SAASI,IAAAA,GAAOF,aAAAA;AAC9B,QAAMvB,cAAc,MAAMiD,OAAOK,UAAUD,KAAAA;AAE3CtD,eAAaC,WAAAA;AAEb,SAAOA,YAAYuD,OAAO,CAACC,MAAMrD,eAAeqD,OAAOrD,WAAWsD,YAAY,CAAA;AAChF,GAjB2B;;;ADrD3BC,YAAY,IAAA,EACTC,KAAK,CAACC,UAAAA;AACL,MAAIA,OAAO;AACTC,YAAQC,KAAKF,KAAAA;EACf;AACF,CAAA,EACCG,MAAM,CAACC,WAAAA;AACNC,UAAQC,MAAMC,OAAMC,IAAIJ,MAAAA,CAAAA;AACxBH,UAAQC,KAAK,EAAC;AAChB,CAAA;","names":["chalk","readdirSync","path","cwd","pathToFileURL","chalk","ESLint","findUp","picomatch","dumpMessages","lintResults","colors","severity","lintResult","messages","length","console","log","chalk","gray","filePath","message","line","column","white","ruleId","getRootESLintConfig","configPath","findUp","Error","pathToFileURL","getFiles","dir","ignoreFolders","currentDirectory","cwd","readdirSync","withFileTypes","flatMap","dirent","res","path","resolve","name","subDirectory","split","relativePath","ignoreMatchers","map","pattern","picomatch","some","isMatch","isDirectory","packageLint","fix","default","eslintConfig","href","engine","ESLint","baseConfig","warnIgnored","files","lintFiles","reduce","prev","errorCount","packageLint","then","value","process","exit","catch","reason","console","error","chalk","red"]}
@@ -13,6 +13,7 @@ import { pathToFileURL } from "node:url";
13
13
  import chalk from "chalk";
14
14
  import { ESLint } from "eslint";
15
15
  import { findUp } from "find-up";
16
+ import picomatch from "picomatch";
16
17
  var dumpMessages = /* @__PURE__ */ __name((lintResults) => {
17
18
  const colors = [
18
19
  "white",
@@ -42,37 +43,41 @@ async function getRootESLintConfig() {
42
43
  return pathToFileURL(configPath);
43
44
  }
44
45
  __name(getRootESLintConfig, "getRootESLintConfig");
46
+ function getFiles(dir, ignoreFolders) {
47
+ const currentDirectory = cwd();
48
+ return readdirSync(dir, {
49
+ withFileTypes: true
50
+ }).flatMap((dirent) => {
51
+ const res = path.resolve(dir, dirent.name);
52
+ const subDirectory = dir.split(currentDirectory)[1];
53
+ const relativePath = subDirectory ? `${subDirectory}/${dirent.name}` : dirent.name;
54
+ const ignoreMatchers = ignoreFolders.map((pattern) => picomatch(pattern));
55
+ if (ignoreMatchers.some((isMatch) => isMatch(relativePath))) return [];
56
+ return dirent.isDirectory() ? getFiles(res, ignoreFolders) : [
57
+ res
58
+ ];
59
+ });
60
+ }
61
+ __name(getFiles, "getFiles");
45
62
  var packageLint = /* @__PURE__ */ __name(async (fix = false) => {
46
63
  const configPath = await getRootESLintConfig();
47
64
  const { default: eslintConfig } = await import(configPath.href);
48
- const ignoreFolders = /* @__PURE__ */ new Set([
65
+ const ignoreFolders = [
49
66
  "node_modules",
50
67
  "dist",
51
- "packages"
52
- ]);
53
- function getFiles(dir, ignorePatterns2) {
54
- return readdirSync(dir, {
55
- withFileTypes: true
56
- }).flatMap((dirent) => {
57
- const res = path.resolve(dir, dirent.name);
58
- if (ignorePatterns2.some((pattern) => dir.includes(pattern))) return [];
59
- return dirent.isDirectory() ? getFiles(res, ignorePatterns2) : res.endsWith(".ts") || res.endsWith(".tsx") || res.endsWith(".js") || res.endsWith(".jsx") ? [
60
- res
61
- ] : [];
62
- });
63
- }
64
- __name(getFiles, "getFiles");
68
+ "packages",
69
+ ".git",
70
+ "build"
71
+ ];
65
72
  const engine = new ESLint({
66
73
  baseConfig: [
67
74
  ...eslintConfig
68
75
  ],
69
- fix
76
+ fix,
77
+ warnIgnored: false
70
78
  });
71
- const ignorePatterns = [
72
- ...eslintConfig.find((cfg) => cfg.ignores)?.ignores ?? [],
73
- ...ignoreFolders
74
- ];
75
- const lintResults = await engine.lintFiles(getFiles(cwd(), ignorePatterns));
79
+ const files = getFiles(cwd(), ignoreFolders);
80
+ const lintResults = await engine.lintFiles(files);
76
81
  dumpMessages(lintResults);
77
82
  return lintResults.reduce((prev, lintResult) => prev + lintResult.errorCount, 0);
78
83
  }, "packageLint");
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/bin/package/lint.ts","../../../src/actions/package/lint.ts"],"sourcesContent":["#!/usr/bin/env node\n\nimport chalk from 'chalk'\n\nimport { packageLint } from '../../actions/index.ts'\n\npackageLint()\n .then((value) => {\n if (value) {\n process.exit(value)\n }\n })\n .catch((reason) => {\n console.error(chalk.red(reason))\n process.exit(-1)\n })\n","import { readdirSync } from 'node:fs'\nimport path from 'node:path'\nimport { cwd } from 'node:process'\nimport { pathToFileURL } from 'node:url'\n\nimport chalk from 'chalk'\nimport { ESLint } from 'eslint'\nimport { findUp } from 'find-up'\n\nconst dumpMessages = (lintResults: ESLint.LintResult[]) => {\n const colors: ('white' | 'red' | 'yellow')[] = ['white', 'yellow', 'red']\n const severity: string[] = ['none', 'warning', 'error']\n\n for (const lintResult of lintResults) {\n if (lintResult.messages.length > 0) {\n console.log(chalk.gray(`\\n${lintResult.filePath}`))\n for (const message of lintResult.messages) {\n console.log(\n chalk.gray(`\\t${message.line}:${message.column}`),\n chalk[colors[message.severity]](`\\t${severity[message.severity]}`),\n chalk.white(`\\t${message.message}`),\n chalk.gray(`\\t${message.ruleId}`),\n )\n }\n }\n }\n}\n\nasync function getRootESLintConfig() {\n // Locate the root eslint.config.mjs\n const configPath = await findUp('eslint.config.mjs')\n\n if (!configPath) {\n throw new Error('eslint.config.mjs not found in the monorepo')\n }\n\n return pathToFileURL(configPath)\n}\n\nexport const packageLint = async (fix = false) => {\n const configPath = await getRootESLintConfig()\n const { default: eslintConfig } = await import(configPath.href)\n\n // List of folders to ignore\n const ignoreFolders = new Set(['node_modules', 'dist', 'packages'])\n\n function getFiles(dir: string, ignorePatterns: string[]): string[] {\n return readdirSync(dir, { withFileTypes: true })\n .flatMap((dirent) => {\n const res = path.resolve(dir, dirent.name)\n\n // Exclude ignored paths\n if (ignorePatterns.some(pattern => dir.includes(pattern))) return []\n\n return dirent.isDirectory()\n ? getFiles(res, ignorePatterns)\n : (res.endsWith('.ts') || res.endsWith('.tsx') || res.endsWith('.js') || res.endsWith('.jsx')) ? [res] : []\n })\n }\n\n const engine = new ESLint({ baseConfig: [...eslintConfig], fix })\n\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const ignorePatterns = [...eslintConfig.find((cfg: any) => cfg.ignores)?.ignores ?? [], ...ignoreFolders]\n\n const lintResults = await engine.lintFiles(getFiles(cwd(), ignorePatterns))\n\n dumpMessages(lintResults)\n\n return lintResults.reduce((prev, lintResult) => prev + lintResult.errorCount, 0)\n}\n"],"mappings":";;;;;AAEA,OAAOA,YAAW;;;ACFlB,SAASC,mBAAmB;AAC5B,OAAOC,UAAU;AACjB,SAASC,WAAW;AACpB,SAASC,qBAAqB;AAE9B,OAAOC,WAAW;AAClB,SAASC,cAAc;AACvB,SAASC,cAAc;AAEvB,IAAMC,eAAe,wBAACC,gBAAAA;AACpB,QAAMC,SAAyC;IAAC;IAAS;IAAU;;AACnE,QAAMC,WAAqB;IAAC;IAAQ;IAAW;;AAE/C,aAAWC,cAAcH,aAAa;AACpC,QAAIG,WAAWC,SAASC,SAAS,GAAG;AAClCC,cAAQC,IAAIC,MAAMC,KAAK;EAAKN,WAAWO,QAAQ,EAAE,CAAA;AACjD,iBAAWC,WAAWR,WAAWC,UAAU;AACzCE,gBAAQC,IACNC,MAAMC,KAAK,IAAKE,QAAQC,IAAI,IAAID,QAAQE,MAAM,EAAE,GAChDL,MAAMP,OAAOU,QAAQT,QAAQ,CAAC,EAAE,IAAKA,SAASS,QAAQT,QAAQ,CAAC,EAAE,GACjEM,MAAMM,MAAM,IAAKH,QAAQA,OAAO,EAAE,GAClCH,MAAMC,KAAK,IAAKE,QAAQI,MAAM,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CAAA;AAChF,GA/B2B;;;ADjC3BC,YAAAA,EACGC,KAAK,CAACC,UAAAA;AACL,MAAIA,OAAO;AACTC,YAAQC,KAAKF,KAAAA;EACf;AACF,CAAA,EACCG,MAAM,CAACC,WAAAA;AACNC,UAAQC,MAAMC,OAAMC,IAAIJ,MAAAA,CAAAA;AACxBH,UAAQC,KAAK,EAAC;AAChB,CAAA;","names":["chalk","readdirSync","path","cwd","pathToFileURL","chalk","ESLint","findUp","dumpMessages","lintResults","colors","severity","lintResult","messages","length","console","log","chalk","gray","filePath","message","line","column","white","ruleId","getRootESLintConfig","configPath","findUp","Error","pathToFileURL","packageLint","fix","default","eslintConfig","href","ignoreFolders","Set","getFiles","dir","ignorePatterns","readdirSync","withFileTypes","flatMap","dirent","res","path","resolve","name","some","pattern","includes","isDirectory","endsWith","engine","ESLint","baseConfig","find","cfg","ignores","lintFiles","cwd","reduce","prev","errorCount","packageLint","then","value","process","exit","catch","reason","console","error","chalk","red"]}
1
+ {"version":3,"sources":["../../../src/bin/package/lint.ts","../../../src/actions/package/lint.ts"],"sourcesContent":["#!/usr/bin/env node\n\nimport chalk from 'chalk'\n\nimport { packageLint } from '../../actions/index.ts'\n\npackageLint()\n .then((value) => {\n if (value) {\n process.exit(value)\n }\n })\n .catch((reason) => {\n console.error(chalk.red(reason))\n process.exit(-1)\n })\n","import { readdirSync } from 'node:fs'\nimport path from 'node:path'\nimport { cwd } from 'node:process'\nimport { pathToFileURL } from 'node:url'\n\nimport chalk from 'chalk'\nimport { ESLint } from 'eslint'\nimport { findUp } from 'find-up'\nimport picomatch from 'picomatch'\n\nconst dumpMessages = (lintResults: ESLint.LintResult[]) => {\n const colors: ('white' | 'red' | 'yellow')[] = ['white', 'yellow', 'red']\n const severity: string[] = ['none', 'warning', 'error']\n\n for (const lintResult of lintResults) {\n if (lintResult.messages.length > 0) {\n console.log(chalk.gray(`\\n${lintResult.filePath}`))\n for (const message of lintResult.messages) {\n console.log(\n chalk.gray(`\\t${message.line}:${message.column}`),\n chalk[colors[message.severity]](`\\t${severity[message.severity]}`),\n chalk.white(`\\t${message.message}`),\n chalk.gray(`\\t${message.ruleId}`),\n )\n }\n }\n }\n}\n\nasync function getRootESLintConfig() {\n // Locate the root eslint.config.mjs\n const configPath = await findUp('eslint.config.mjs')\n\n if (!configPath) {\n throw new Error('eslint.config.mjs not found in the monorepo')\n }\n\n return pathToFileURL(configPath)\n}\n\nfunction getFiles(dir: string, ignoreFolders: string[]): string[] {\n const currentDirectory = cwd()\n return readdirSync(dir, { withFileTypes: true })\n .flatMap((dirent) => {\n const res = path.resolve(dir, dirent.name)\n const subDirectory = dir.split(currentDirectory)[1]\n const relativePath = subDirectory ? `${subDirectory}/${dirent.name}` : dirent.name\n\n const ignoreMatchers = ignoreFolders.map(pattern => picomatch(pattern))\n\n // Exclude ignored paths\n if (ignoreMatchers.some(isMatch => isMatch(relativePath))) return []\n\n return dirent.isDirectory()\n ? getFiles(res, ignoreFolders)\n : [res]\n })\n}\n\nexport const packageLint = async (fix = false) => {\n const configPath = await getRootESLintConfig()\n const { default: eslintConfig } = await import(configPath.href)\n\n // List of folders to ignore\n const ignoreFolders = ['node_modules', 'dist', 'packages', '.git', 'build']\n\n const engine = new ESLint({\n baseConfig: [...eslintConfig], fix, warnIgnored: false,\n })\n\n const files = getFiles(cwd(), ignoreFolders)\n const lintResults = await engine.lintFiles(files)\n\n dumpMessages(lintResults)\n\n return lintResults.reduce((prev, lintResult) => prev + lintResult.errorCount, 0)\n}\n"],"mappings":";;;;;AAEA,OAAOA,YAAW;;;ACFlB,SAASC,mBAAmB;AAC5B,OAAOC,UAAU;AACjB,SAASC,WAAW;AACpB,SAASC,qBAAqB;AAE9B,OAAOC,WAAW;AAClB,SAASC,cAAc;AACvB,SAASC,cAAc;AACvB,OAAOC,eAAe;AAEtB,IAAMC,eAAe,wBAACC,gBAAAA;AACpB,QAAMC,SAAyC;IAAC;IAAS;IAAU;;AACnE,QAAMC,WAAqB;IAAC;IAAQ;IAAW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uB,cAAc,8BAAOC,MAAM,UAAK;AAC3C,QAAM5B,aAAa,MAAMD,oBAAAA;AACzB,QAAM,EAAE8B,SAASC,aAAY,IAAK,MAAM,OAAO9B,WAAW+B;AAG1D,QAAMzB,gBAAgB;IAAC;IAAgB;IAAQ;IAAY;IAAQ;;AAEnE,QAAM0B,SAAS,IAAIC,OAAO;IACxBC,YAAY;SAAIJ;;IAAeF;IAAKO,aAAa;EACnD,CAAA;AAEA,QAAMC,QAAQhC,SAASI,IAAAA,GAAOF,aAAAA;AAC9B,QAAMvB,cAAc,MAAMiD,OAAOK,UAAUD,KAAAA;AAE3CtD,eAAaC,WAAAA;AAEb,SAAOA,YAAYuD,OAAO,CAACC,MAAMrD,eAAeqD,OAAOrD,WAAWsD,YAAY,CAAA;AAChF,GAjB2B;;;ADrD3BC,YAAAA,EACGC,KAAK,CAACC,UAAAA;AACL,MAAIA,OAAO;AACTC,YAAQC,KAAKF,KAAAA;EACf;AACF,CAAA,EACCG,MAAM,CAACC,WAAAA;AACNC,UAAQC,MAAMC,OAAMC,IAAIJ,MAAAA,CAAAA;AACxBH,UAAQC,KAAK,EAAC;AAChB,CAAA;","names":["chalk","readdirSync","path","cwd","pathToFileURL","chalk","ESLint","findUp","picomatch","dumpMessages","lintResults","colors","severity","lintResult","messages","length","console","log","chalk","gray","filePath","message","line","column","white","ruleId","getRootESLintConfig","configPath","findUp","Error","pathToFileURL","getFiles","dir","ignoreFolders","currentDirectory","cwd","readdirSync","withFileTypes","flatMap","dirent","res","path","resolve","name","subDirectory","split","relativePath","ignoreMatchers","map","pattern","picomatch","some","isMatch","isDirectory","packageLint","fix","default","eslintConfig","href","engine","ESLint","baseConfig","warnIgnored","files","lintFiles","reduce","prev","errorCount","packageLint","then","value","process","exit","catch","reason","console","error","chalk","red"]}
package/dist/index.mjs CHANGED
@@ -2101,6 +2101,7 @@ import { pathToFileURL } from "node:url";
2101
2101
  import chalk28 from "chalk";
2102
2102
  import { ESLint as ESLint3 } from "eslint";
2103
2103
  import { findUp } from "find-up";
2104
+ import picomatch from "picomatch";
2104
2105
  var dumpMessages2 = /* @__PURE__ */ __name((lintResults) => {
2105
2106
  const colors = [
2106
2107
  "white",
@@ -2130,37 +2131,41 @@ async function getRootESLintConfig() {
2130
2131
  return pathToFileURL(configPath);
2131
2132
  }
2132
2133
  __name(getRootESLintConfig, "getRootESLintConfig");
2134
+ function getFiles(dir, ignoreFolders) {
2135
+ const currentDirectory = cwd4();
2136
+ return readdirSync(dir, {
2137
+ withFileTypes: true
2138
+ }).flatMap((dirent) => {
2139
+ const res = path7.resolve(dir, dirent.name);
2140
+ const subDirectory = dir.split(currentDirectory)[1];
2141
+ const relativePath = subDirectory ? `${subDirectory}/${dirent.name}` : dirent.name;
2142
+ const ignoreMatchers = ignoreFolders.map((pattern) => picomatch(pattern));
2143
+ if (ignoreMatchers.some((isMatch) => isMatch(relativePath))) return [];
2144
+ return dirent.isDirectory() ? getFiles(res, ignoreFolders) : [
2145
+ res
2146
+ ];
2147
+ });
2148
+ }
2149
+ __name(getFiles, "getFiles");
2133
2150
  var packageLint = /* @__PURE__ */ __name(async (fix2 = false) => {
2134
2151
  const configPath = await getRootESLintConfig();
2135
2152
  const { default: eslintConfig } = await import(configPath.href);
2136
- const ignoreFolders = /* @__PURE__ */ new Set([
2153
+ const ignoreFolders = [
2137
2154
  "node_modules",
2138
2155
  "dist",
2139
- "packages"
2140
- ]);
2141
- function getFiles(dir, ignorePatterns2) {
2142
- return readdirSync(dir, {
2143
- withFileTypes: true
2144
- }).flatMap((dirent) => {
2145
- const res = path7.resolve(dir, dirent.name);
2146
- if (ignorePatterns2.some((pattern) => dir.includes(pattern))) return [];
2147
- return dirent.isDirectory() ? getFiles(res, ignorePatterns2) : res.endsWith(".ts") || res.endsWith(".tsx") || res.endsWith(".js") || res.endsWith(".jsx") ? [
2148
- res
2149
- ] : [];
2150
- });
2151
- }
2152
- __name(getFiles, "getFiles");
2156
+ "packages",
2157
+ ".git",
2158
+ "build"
2159
+ ];
2153
2160
  const engine = new ESLint3({
2154
2161
  baseConfig: [
2155
2162
  ...eslintConfig
2156
2163
  ],
2157
- fix: fix2
2164
+ fix: fix2,
2165
+ warnIgnored: false
2158
2166
  });
2159
- const ignorePatterns = [
2160
- ...eslintConfig.find((cfg) => cfg.ignores)?.ignores ?? [],
2161
- ...ignoreFolders
2162
- ];
2163
- const lintResults = await engine.lintFiles(getFiles(cwd4(), ignorePatterns));
2167
+ const files = getFiles(cwd4(), ignoreFolders);
2168
+ const lintResults = await engine.lintFiles(files);
2164
2169
  dumpMessages2(lintResults);
2165
2170
  return lintResults.reduce((prev, lintResult) => prev + lintResult.errorCount, 0);
2166
2171
  }, "packageLint");