@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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xylabs/ts-scripts-yarn3",
3
- "version": "5.1.7",
3
+ "version": "5.1.8",
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.7",
97
- "@xylabs/tsconfig-dom": "^5.1.7",
96
+ "@xylabs/tsconfig": "^5.1.8",
97
+ "@xylabs/tsconfig-dom": "^5.1.8",
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
- "@xylabs/tsconfig": "^5.1.7",
138
+ "@types/picomatch": "^3.0.2",
139
+ "@xylabs/tsconfig": "^5.1.8",
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,33 +38,38 @@ async function getRootESLintConfig() {
37
38
  return pathToFileURL(configPath)
38
39
  }
39
40
 
40
- export const packageLint = async (fix = false) => {
41
- const configPath = await getRootESLintConfig()
42
- const { default: eslintConfig } = await import(configPath.href)
41
+ function getFiles(dir: string, ignoreFolders: string[]): string[] {
42
+ const currentDirectory = cwd()
43
+ return readdirSync(dir, { withFileTypes: true })
44
+ .flatMap((dirent) => {
45
+ const res = path.resolve(dir, dirent.name)
46
+ const subDirectory = dir.split(currentDirectory)[1]
47
+ const relativePath = subDirectory ? `${subDirectory}/${dirent.name}` : dirent.name
43
48
 
44
- // List of folders to ignore
45
- const ignoreFolders = new Set(['node_modules', 'dist', 'packages'])
49
+ const ignoreMatchers = ignoreFolders.map(pattern => picomatch(pattern))
46
50
 
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)
51
+ // Exclude ignored paths
52
+ if (ignoreMatchers.some(isMatch => isMatch(relativePath))) return []
51
53
 
52
- // Exclude ignored paths
53
- if (ignorePatterns.some(pattern => dir.includes(pattern))) return []
54
+ return dirent.isDirectory()
55
+ ? getFiles(res, ignoreFolders)
56
+ : [res]
57
+ })
58
+ }
54
59
 
55
- return dirent.isDirectory()
56
- ? getFiles(res, ignorePatterns)
57
- : (res.endsWith('.ts') || res.endsWith('.tsx') || res.endsWith('.js') || res.endsWith('.jsx')) ? [res] : []
58
- })
59
- }
60
+ export const packageLint = async (fix = false) => {
61
+ const configPath = await getRootESLintConfig()
62
+ const { default: eslintConfig } = await import(configPath.href)
60
63
 
61
- const engine = new ESLint({ baseConfig: [...eslintConfig], fix })
64
+ // List of folders to ignore
65
+ const ignoreFolders = ['node_modules', 'dist', 'packages', '.git', 'build']
62
66
 
63
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
64
- const ignorePatterns = [...eslintConfig.find((cfg: any) => cfg.ignores)?.ignores ?? [], ...ignoreFolders]
67
+ const engine = new ESLint({
68
+ baseConfig: [...eslintConfig], fix, warnIgnored: false,
69
+ })
65
70
 
66
- const lintResults = await engine.lintFiles(getFiles(cwd(), ignorePatterns))
71
+ const files = getFiles(cwd(), ignoreFolders)
72
+ const lintResults = await engine.lintFiles(files)
67
73
 
68
74
  dumpMessages(lintResults)
69
75