@xylabs/ts-scripts-yarn3 5.1.7 → 5.1.9
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/dist/actions/index.mjs +34 -21
- package/dist/actions/index.mjs.map +1 -1
- package/dist/actions/package/index.mjs +34 -21
- package/dist/actions/package/index.mjs.map +1 -1
- package/dist/actions/package/lint.mjs +34 -21
- package/dist/actions/package/lint.mjs.map +1 -1
- package/dist/bin/package/fix.mjs +34 -21
- package/dist/bin/package/fix.mjs.map +1 -1
- package/dist/bin/package/lint.mjs +34 -21
- package/dist/bin/package/lint.mjs.map +1 -1
- package/dist/index.mjs +34 -21
- package/dist/index.mjs.map +1 -1
- package/package.json +6 -4
- package/src/actions/package/lint.ts +32 -20
|
@@ -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\
|
|
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 const subDirectory = dir.split(currentDirectory)[1]\n if (ignoreFolders.includes(subDirectory)) return []\n console.log('subDirectory:', subDirectory)\n return readdirSync(dir, { withFileTypes: true })\n .flatMap((dirent) => {\n const res = path.resolve(dir, dirent.name)\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', '.yarn', '.vscode', '.github']\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 if (fix) {\n await ESLint.outputFixes(lintResults)\n }\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;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,EAA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xBC,YAAY;SAAIJ;;IAAeF;IAAKO,aAAa;EACnD,CAAA;AAEA,QAAMC,QAAQjC,SAASI,IAAAA,GAAOF,aAAAA;AAC9B,QAAMvB,cAAc,MAAMkD,OAAOK,UAAUD,KAAAA;AAE3CvD,eAAaC,WAAAA;AAEb,MAAI8C,KAAK;AACP,UAAMK,OAAOK,YAAYxD,WAAAA;EAC3B;AAEA,SAAOA,YAAYyD,OAAO,CAACC,MAAMvD,eAAeuD,OAAOvD,WAAWwD,YAAY,CAAA;AAChF,GArB2B;;;ADvD3BC,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","subDirectory","split","includes","readdirSync","withFileTypes","flatMap","dirent","res","path","resolve","name","relativePath","ignoreMatchers","map","pattern","picomatch","some","isMatch","isDirectory","packageLint","fix","default","eslintConfig","href","engine","ESLint","baseConfig","warnIgnored","files","lintFiles","outputFixes","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,38 +43,50 @@ 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
|
+
const subDirectory = dir.split(currentDirectory)[1];
|
|
49
|
+
if (ignoreFolders.includes(subDirectory)) return [];
|
|
50
|
+
console.log("subDirectory:", subDirectory);
|
|
51
|
+
return readdirSync(dir, {
|
|
52
|
+
withFileTypes: true
|
|
53
|
+
}).flatMap((dirent) => {
|
|
54
|
+
const res = path.resolve(dir, dirent.name);
|
|
55
|
+
const relativePath = subDirectory ? `${subDirectory}/${dirent.name}` : dirent.name;
|
|
56
|
+
const ignoreMatchers = ignoreFolders.map((pattern) => picomatch(pattern));
|
|
57
|
+
if (ignoreMatchers.some((isMatch) => isMatch(relativePath))) return [];
|
|
58
|
+
return dirent.isDirectory() ? getFiles(res, ignoreFolders) : [
|
|
59
|
+
res
|
|
60
|
+
];
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
__name(getFiles, "getFiles");
|
|
45
64
|
var packageLint = /* @__PURE__ */ __name(async (fix = false) => {
|
|
46
65
|
const configPath = await getRootESLintConfig();
|
|
47
66
|
const { default: eslintConfig } = await import(configPath.href);
|
|
48
|
-
const ignoreFolders =
|
|
67
|
+
const ignoreFolders = [
|
|
49
68
|
"node_modules",
|
|
50
69
|
"dist",
|
|
51
|
-
"packages"
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
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");
|
|
70
|
+
"packages",
|
|
71
|
+
".git",
|
|
72
|
+
"build",
|
|
73
|
+
".yarn",
|
|
74
|
+
".vscode",
|
|
75
|
+
".github"
|
|
76
|
+
];
|
|
65
77
|
const engine = new ESLint({
|
|
66
78
|
baseConfig: [
|
|
67
79
|
...eslintConfig
|
|
68
80
|
],
|
|
69
|
-
fix
|
|
81
|
+
fix,
|
|
82
|
+
warnIgnored: false
|
|
70
83
|
});
|
|
71
|
-
const
|
|
72
|
-
|
|
73
|
-
...ignoreFolders
|
|
74
|
-
];
|
|
75
|
-
const lintResults = await engine.lintFiles(getFiles(cwd(), ignorePatterns));
|
|
84
|
+
const files = getFiles(cwd(), ignoreFolders);
|
|
85
|
+
const lintResults = await engine.lintFiles(files);
|
|
76
86
|
dumpMessages(lintResults);
|
|
87
|
+
if (fix) {
|
|
88
|
+
await ESLint.outputFixes(lintResults);
|
|
89
|
+
}
|
|
77
90
|
return lintResults.reduce((prev, lintResult) => prev + lintResult.errorCount, 0);
|
|
78
91
|
}, "packageLint");
|
|
79
92
|
|
|
@@ -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\
|
|
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 const subDirectory = dir.split(currentDirectory)[1]\n if (ignoreFolders.includes(subDirectory)) return []\n console.log('subDirectory:', subDirectory)\n return readdirSync(dir, { withFileTypes: true })\n .flatMap((dirent) => {\n const res = path.resolve(dir, dirent.name)\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', '.yarn', '.vscode', '.github']\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 if (fix) {\n await ESLint.outputFixes(lintResults)\n }\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;AAClCC,cAAQC,IAAIC,MAAMC,KAAK;EAAKN,WAAWO,QAAQ,EAAE,CAAA;AACjD,iBAAWC,WAAWR,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AA;AACzB,QAAM,EAAE+B,SAASC,aAAY,IAAK,MAAM,OAAO/B,WAAWgC;AAG1D,QAAM1B,gBAAgB;IAAC;IAAgB;IAAQ;IAAY;IAAQ;IAAS;IAAS;IAAW;;AAEhG,QAAM2B,SAAS,IAAIC,OAAO;IACxBC,YAAY;SAAIJ;;IAAeF;IAAKO,aAAa;EACnD,CAAA;AAEA,QAAMC,QAAQjC,SAASI,IAAAA,GAAOF,aAAAA;AAC9B,QAAMvB,cAAc,MAAMkD,OAAOK,UAAUD,KAAAA;AAE3CvD,eAAaC,WAAAA;AAEb,MAAI8C,KAAK;AACP,UAAMK,OAAOK,YAAYxD,WAAAA;EAC3B;AAEA,SAAOA,YAAYyD,OAAO,CAACC,MAAMvD,eAAeuD,OAAOvD,WAAWwD,YAAY,CAAA;AAChF,GArB2B;;;ADvD3BC,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","subDirectory","split","includes","readdirSync","withFileTypes","flatMap","dirent","res","path","resolve","name","relativePath","ignoreMatchers","map","pattern","picomatch","some","isMatch","isDirectory","packageLint","fix","default","eslintConfig","href","engine","ESLint","baseConfig","warnIgnored","files","lintFiles","outputFixes","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,38 +2131,50 @@ 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
|
+
const subDirectory = dir.split(currentDirectory)[1];
|
|
2137
|
+
if (ignoreFolders.includes(subDirectory)) return [];
|
|
2138
|
+
console.log("subDirectory:", subDirectory);
|
|
2139
|
+
return readdirSync(dir, {
|
|
2140
|
+
withFileTypes: true
|
|
2141
|
+
}).flatMap((dirent) => {
|
|
2142
|
+
const res = path7.resolve(dir, dirent.name);
|
|
2143
|
+
const relativePath = subDirectory ? `${subDirectory}/${dirent.name}` : dirent.name;
|
|
2144
|
+
const ignoreMatchers = ignoreFolders.map((pattern) => picomatch(pattern));
|
|
2145
|
+
if (ignoreMatchers.some((isMatch) => isMatch(relativePath))) return [];
|
|
2146
|
+
return dirent.isDirectory() ? getFiles(res, ignoreFolders) : [
|
|
2147
|
+
res
|
|
2148
|
+
];
|
|
2149
|
+
});
|
|
2150
|
+
}
|
|
2151
|
+
__name(getFiles, "getFiles");
|
|
2133
2152
|
var packageLint = /* @__PURE__ */ __name(async (fix2 = false) => {
|
|
2134
2153
|
const configPath = await getRootESLintConfig();
|
|
2135
2154
|
const { default: eslintConfig } = await import(configPath.href);
|
|
2136
|
-
const ignoreFolders =
|
|
2155
|
+
const ignoreFolders = [
|
|
2137
2156
|
"node_modules",
|
|
2138
2157
|
"dist",
|
|
2139
|
-
"packages"
|
|
2140
|
-
|
|
2141
|
-
|
|
2142
|
-
|
|
2143
|
-
|
|
2144
|
-
|
|
2145
|
-
|
|
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");
|
|
2158
|
+
"packages",
|
|
2159
|
+
".git",
|
|
2160
|
+
"build",
|
|
2161
|
+
".yarn",
|
|
2162
|
+
".vscode",
|
|
2163
|
+
".github"
|
|
2164
|
+
];
|
|
2153
2165
|
const engine = new ESLint3({
|
|
2154
2166
|
baseConfig: [
|
|
2155
2167
|
...eslintConfig
|
|
2156
2168
|
],
|
|
2157
|
-
fix: fix2
|
|
2169
|
+
fix: fix2,
|
|
2170
|
+
warnIgnored: false
|
|
2158
2171
|
});
|
|
2159
|
-
const
|
|
2160
|
-
|
|
2161
|
-
...ignoreFolders
|
|
2162
|
-
];
|
|
2163
|
-
const lintResults = await engine.lintFiles(getFiles(cwd4(), ignorePatterns));
|
|
2172
|
+
const files = getFiles(cwd4(), ignoreFolders);
|
|
2173
|
+
const lintResults = await engine.lintFiles(files);
|
|
2164
2174
|
dumpMessages2(lintResults);
|
|
2175
|
+
if (fix2) {
|
|
2176
|
+
await ESLint3.outputFixes(lintResults);
|
|
2177
|
+
}
|
|
2165
2178
|
return lintResults.reduce((prev, lintResult) => prev + lintResult.errorCount, 0);
|
|
2166
2179
|
}, "packageLint");
|
|
2167
2180
|
|