@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
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xylabs/ts-scripts-yarn3",
|
|
3
|
-
"version": "5.1.
|
|
3
|
+
"version": "5.1.9",
|
|
4
4
|
"description": "TypeScript project scripts",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"xylabs",
|
|
@@ -93,8 +93,8 @@
|
|
|
93
93
|
"@swc/core": "^1.11.5",
|
|
94
94
|
"@types/node": "^22.13.5",
|
|
95
95
|
"@types/yargs": "^17.0.33",
|
|
96
|
-
"@xylabs/tsconfig": "^5.1.
|
|
97
|
-
"@xylabs/tsconfig-dom": "^5.1.
|
|
96
|
+
"@xylabs/tsconfig": "^5.1.9",
|
|
97
|
+
"@xylabs/tsconfig-dom": "^5.1.9",
|
|
98
98
|
"async-mutex": "^0.5.0",
|
|
99
99
|
"chalk": "^5.4.1",
|
|
100
100
|
"cosmiconfig": "^9.0.0",
|
|
@@ -113,6 +113,7 @@
|
|
|
113
113
|
"npm-package-json-lint": "^8.0.0",
|
|
114
114
|
"npm-package-json-lint-config-default": "^7.0.1",
|
|
115
115
|
"parse-git-config": "^3.0.0",
|
|
116
|
+
"picomatch": "^4.0.2",
|
|
116
117
|
"publint": "^0.3.7",
|
|
117
118
|
"reflect-metadata": "^0.2.2",
|
|
118
119
|
"rollup": "^4.34.8",
|
|
@@ -134,7 +135,8 @@
|
|
|
134
135
|
"@types/eslint": "^9.6.1",
|
|
135
136
|
"@types/license-checker": "^25.0.6",
|
|
136
137
|
"@types/parse-git-config": "^3.0.4",
|
|
137
|
-
"@
|
|
138
|
+
"@types/picomatch": "^3.0.2",
|
|
139
|
+
"@xylabs/tsconfig": "^5.1.9",
|
|
138
140
|
"publint": "^0.3.7",
|
|
139
141
|
"rimraf": "^6.0.1",
|
|
140
142
|
"typescript": "^5.7.3"
|
|
@@ -6,6 +6,7 @@ import { pathToFileURL } from 'node:url'
|
|
|
6
6
|
import chalk from 'chalk'
|
|
7
7
|
import { ESLint } from 'eslint'
|
|
8
8
|
import { findUp } from 'find-up'
|
|
9
|
+
import picomatch from 'picomatch'
|
|
9
10
|
|
|
10
11
|
const dumpMessages = (lintResults: ESLint.LintResult[]) => {
|
|
11
12
|
const colors: ('white' | 'red' | 'yellow')[] = ['white', 'yellow', 'red']
|
|
@@ -37,35 +38,46 @@ async function getRootESLintConfig() {
|
|
|
37
38
|
return pathToFileURL(configPath)
|
|
38
39
|
}
|
|
39
40
|
|
|
41
|
+
function getFiles(dir: string, ignoreFolders: string[]): string[] {
|
|
42
|
+
const currentDirectory = cwd()
|
|
43
|
+
const subDirectory = dir.split(currentDirectory)[1]
|
|
44
|
+
if (ignoreFolders.includes(subDirectory)) return []
|
|
45
|
+
console.log('subDirectory:', subDirectory)
|
|
46
|
+
return readdirSync(dir, { withFileTypes: true })
|
|
47
|
+
.flatMap((dirent) => {
|
|
48
|
+
const res = path.resolve(dir, dirent.name)
|
|
49
|
+
const relativePath = subDirectory ? `${subDirectory}/${dirent.name}` : dirent.name
|
|
50
|
+
|
|
51
|
+
const ignoreMatchers = ignoreFolders.map(pattern => picomatch(pattern))
|
|
52
|
+
|
|
53
|
+
// Exclude ignored paths
|
|
54
|
+
if (ignoreMatchers.some(isMatch => isMatch(relativePath))) return []
|
|
55
|
+
|
|
56
|
+
return dirent.isDirectory()
|
|
57
|
+
? getFiles(res, ignoreFolders)
|
|
58
|
+
: [res]
|
|
59
|
+
})
|
|
60
|
+
}
|
|
61
|
+
|
|
40
62
|
export const packageLint = async (fix = false) => {
|
|
41
63
|
const configPath = await getRootESLintConfig()
|
|
42
64
|
const { default: eslintConfig } = await import(configPath.href)
|
|
43
65
|
|
|
44
66
|
// List of folders to ignore
|
|
45
|
-
const ignoreFolders =
|
|
46
|
-
|
|
47
|
-
function getFiles(dir: string, ignorePatterns: string[]): string[] {
|
|
48
|
-
return readdirSync(dir, { withFileTypes: true })
|
|
49
|
-
.flatMap((dirent) => {
|
|
50
|
-
const res = path.resolve(dir, dirent.name)
|
|
67
|
+
const ignoreFolders = ['node_modules', 'dist', 'packages', '.git', 'build', '.yarn', '.vscode', '.github']
|
|
51
68
|
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
return dirent.isDirectory()
|
|
56
|
-
? getFiles(res, ignorePatterns)
|
|
57
|
-
: (res.endsWith('.ts') || res.endsWith('.tsx') || res.endsWith('.js') || res.endsWith('.jsx')) ? [res] : []
|
|
58
|
-
})
|
|
59
|
-
}
|
|
69
|
+
const engine = new ESLint({
|
|
70
|
+
baseConfig: [...eslintConfig], fix, warnIgnored: false,
|
|
71
|
+
})
|
|
60
72
|
|
|
61
|
-
const
|
|
62
|
-
|
|
63
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
64
|
-
const ignorePatterns = [...eslintConfig.find((cfg: any) => cfg.ignores)?.ignores ?? [], ...ignoreFolders]
|
|
65
|
-
|
|
66
|
-
const lintResults = await engine.lintFiles(getFiles(cwd(), ignorePatterns))
|
|
73
|
+
const files = getFiles(cwd(), ignoreFolders)
|
|
74
|
+
const lintResults = await engine.lintFiles(files)
|
|
67
75
|
|
|
68
76
|
dumpMessages(lintResults)
|
|
69
77
|
|
|
78
|
+
if (fix) {
|
|
79
|
+
await ESLint.outputFixes(lintResults)
|
|
80
|
+
}
|
|
81
|
+
|
|
70
82
|
return lintResults.reduce((prev, lintResult) => prev + lintResult.errorCount, 0)
|
|
71
83
|
}
|