From b89683aaf1e805ffabd9b0a8e4d4b3977fda8105 Mon Sep 17 00:00:00 2001 From: CDeltakai Date: Tue, 29 Apr 2025 13:56:23 +1000 Subject: [PATCH 1/8] feat: install commander package --- package-lock.json | 23 +++++++++++++++++------ package.json | 5 +++-- 2 files changed, 20 insertions(+), 8 deletions(-) diff --git a/package-lock.json b/package-lock.json index 802bd25..911d76c 100644 --- a/package-lock.json +++ b/package-lock.json @@ -14,7 +14,7 @@ "@typescript-eslint/eslint-plugin": "^8.27.0", "@typescript-eslint/parser": "^8.27.0", "@typescript-eslint/utils": "^8.26.1", - "eslint": "^9.18.0", + "eslint": ">=9.0.0", "eslint-config-prettier": "^9.1.0", "eslint-plugin-import": "^2.31.0", "eslint-plugin-jsx-a11y": "^6.10.2", @@ -31,6 +31,7 @@ "@swc/jest": "^0.2.29", "@types/jest": "^29.5.2", "@types/node": "^20.5.7", + "commander": "^13.1.0", "jest": "^29.6.2", "jest-extended": "^4.0.2", "jest-junit": "^16.0.0", @@ -3646,13 +3647,13 @@ "license": "MIT" }, "node_modules/commander": { - "version": "4.1.1", - "resolved": "https://registry.npmjs.org/commander/-/commander-4.1.1.tgz", - "integrity": "sha512-NOKm8xhkzAjzFx8B2v5OAHT+u5pRQc2UCa2Vq9jYL/31o2wi9mxBA7LIFs3sV5VSC49z6pEhfbMULvShKj26WA==", + "version": "13.1.0", + "resolved": "https://registry.npmjs.org/commander/-/commander-13.1.0.tgz", + "integrity": "sha512-/rFeCpNJQbhSZjGVwO9RFV3xPqbnERS8MmIQzCtD/zl6gpJuV/bMLuN92oG3F7d8oDEHHRrujSXNUr8fpjntKw==", + "dev": true, "license": "MIT", - "peer": true, "engines": { - "node": ">= 6" + "node": ">=18" } }, "node_modules/concat-map": { @@ -9536,6 +9537,16 @@ "node": ">=16 || 14 >=14.17" } }, + "node_modules/sucrase/node_modules/commander": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/commander/-/commander-4.1.1.tgz", + "integrity": "sha512-NOKm8xhkzAjzFx8B2v5OAHT+u5pRQc2UCa2Vq9jYL/31o2wi9mxBA7LIFs3sV5VSC49z6pEhfbMULvShKj26WA==", + "license": "MIT", + "peer": true, + "engines": { + "node": ">= 6" + } + }, "node_modules/sucrase/node_modules/glob": { "version": "10.4.5", "resolved": "https://registry.npmjs.org/glob/-/glob-10.4.5.tgz", diff --git a/package.json b/package.json index 61dbb27..17b5820 100644 --- a/package.json +++ b/package.json @@ -38,11 +38,11 @@ "@typescript-eslint/eslint-plugin": "^8.27.0", "@typescript-eslint/parser": "^8.27.0", "@typescript-eslint/utils": "^8.26.1", - "eslint": "^9.18.0", + "eslint": ">=9.0.0", "eslint-config-prettier": "^9.1.0", "eslint-plugin-import": "^2.31.0", - "eslint-plugin-prettier": "^5.2.1", "eslint-plugin-jsx-a11y": "^6.10.2", + "eslint-plugin-prettier": "^5.2.1", "eslint-plugin-react": "^7.37.4", "eslint-plugin-react-hooks": "^5.1.0", "eslint-plugin-tailwindcss": "^3.18.0" @@ -52,6 +52,7 @@ "@swc/jest": "^0.2.29", "@types/jest": "^29.5.2", "@types/node": "^20.5.7", + "commander": "^13.1.0", "jest": "^29.6.2", "jest-extended": "^4.0.2", "jest-junit": "^16.0.0", From d703fb8bf3b9dffa319222ad837abee776d122d2 Mon Sep 17 00:00:00 2001 From: CDeltakai Date: Tue, 29 Apr 2025 14:49:16 +1000 Subject: [PATCH 2/8] feat: added commnder to lint.ts and reimplemented cli options using it --- src/bin/lint.ts | 42 ++++++++++++++++++++---------------------- 1 file changed, 20 insertions(+), 22 deletions(-) diff --git a/src/bin/lint.ts b/src/bin/lint.ts index 033c3a6..51a48e6 100644 --- a/src/bin/lint.ts +++ b/src/bin/lint.ts @@ -4,36 +4,34 @@ import path from 'node:path'; import process from 'node:process'; import childProcess from 'node:child_process'; import fs from 'node:fs'; +import { Command } from 'commander'; import * as utils from '../utils.js'; const platform = os.platform(); +const program = new Command(); + +program + .name('matrixai-lint') + .description( + 'Lint source files, scripts, and markdown with configured rules.', + ) + .option('-f, --fix', 'Automatically fix problems') + .option( + '--user-config', + 'Use user-provided ESLint config instead of built-in one', + ) + .option('--config ', 'Path to explicit ESLint config file') + .allowUnknownOption(false); // Optional: force rejection of unknown flags /* eslint-disable no-console */ async function main(argv = process.argv) { - argv = argv.slice(2); + await program.parseAsync(argv); + const options = program.opts(); + const fix = Boolean(options.fix); + const useUserConfig = Boolean(options.userConfig); + const explicitConfigPath: string | undefined = options.config; let hadFailure = false; - let fix = false; - let useUserConfig = false; - let explicitConfigPath: string | undefined; - const restArgs: string[] = []; - - while (argv.length > 0) { - const option = argv.shift()!; - switch (option) { - case '--fix': - fix = true; - break; - case '--user-config': - useUserConfig = true; - break; - case '--config': - explicitConfigPath = argv.shift(); // Grab the next token - break; - default: - restArgs.push(option); - } - } // Resolve which config file to use let chosenConfig: string | undefined; From 18402c41cac4222a73405d5749eaa9e5d74ac080 Mon Sep 17 00:00:00 2001 From: CDeltakai Date: Tue, 29 Apr 2025 16:31:43 +1000 Subject: [PATCH 3/8] wip: implementing additional cli options for eslint and shellcheck. installed minimatch for glob matching --- package-lock.json | 57 +++++++++++++++++++++++++++++++++++++++++++---- package.json | 3 ++- src/bin/lint.ts | 13 ++++++++--- src/types.ts | 11 ++++++++- src/utils.ts | 31 ++++++++++++++++++++------ 5 files changed, 99 insertions(+), 16 deletions(-) diff --git a/package-lock.json b/package-lock.json index 911d76c..e5f350a 100644 --- a/package-lock.json +++ b/package-lock.json @@ -35,6 +35,7 @@ "jest": "^29.6.2", "jest-extended": "^4.0.2", "jest-junit": "^16.0.0", + "minimatch": "^10.0.1", "prettier": "^3.0.0", "shx": "^0.3.4", "tsconfig-paths": "^3.9.0", @@ -2901,6 +2902,21 @@ "typescript": ">=4.8.4 <5.9.0" } }, + "node_modules/@typescript-eslint/typescript-estree/node_modules/minimatch": { + "version": "9.0.5", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-9.0.5.tgz", + "integrity": "sha512-G6T0ZX48xgozx7587koeX9Ys2NYy6Gmv//P89sEte9V9whIapMNF4idKxnW2QtCcLiTWlb/wfCabAtAFWhhBow==", + "license": "ISC", + "dependencies": { + "brace-expansion": "^2.0.1" + }, + "engines": { + "node": ">=16 || 14 >=14.17" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, "node_modules/@typescript-eslint/utils": { "version": "8.27.0", "resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-8.27.0.tgz", @@ -7922,15 +7938,16 @@ } }, "node_modules/minimatch": { - "version": "9.0.5", - "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-9.0.5.tgz", - "integrity": "sha512-G6T0ZX48xgozx7587koeX9Ys2NYy6Gmv//P89sEte9V9whIapMNF4idKxnW2QtCcLiTWlb/wfCabAtAFWhhBow==", + "version": "10.0.1", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-10.0.1.tgz", + "integrity": "sha512-ethXTt3SGGR+95gudmqJ1eNhRO7eGEGIgYA9vnPatK4/etz2MEVDno5GMCibdMTuBMyElzIlgxMna3K94XDIDQ==", + "dev": true, "license": "ISC", "dependencies": { "brace-expansion": "^2.0.1" }, "engines": { - "node": ">=16 || 14 >=14.17" + "node": "20 || >=22" }, "funding": { "url": "https://github.com/sponsors/isaacs" @@ -9568,6 +9585,22 @@ "url": "https://github.com/sponsors/isaacs" } }, + "node_modules/sucrase/node_modules/minimatch": { + "version": "9.0.5", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-9.0.5.tgz", + "integrity": "sha512-G6T0ZX48xgozx7587koeX9Ys2NYy6Gmv//P89sEte9V9whIapMNF4idKxnW2QtCcLiTWlb/wfCabAtAFWhhBow==", + "license": "ISC", + "peer": true, + "dependencies": { + "brace-expansion": "^2.0.1" + }, + "engines": { + "node": ">=16 || 14 >=14.17" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, "node_modules/supports-color": { "version": "7.2.0", "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", @@ -9913,6 +9946,22 @@ "typescript": "4.6.x || 4.7.x || 4.8.x || 4.9.x || 5.0.x || 5.1.x" } }, + "node_modules/typedoc/node_modules/minimatch": { + "version": "9.0.5", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-9.0.5.tgz", + "integrity": "sha512-G6T0ZX48xgozx7587koeX9Ys2NYy6Gmv//P89sEte9V9whIapMNF4idKxnW2QtCcLiTWlb/wfCabAtAFWhhBow==", + "dev": true, + "license": "ISC", + "dependencies": { + "brace-expansion": "^2.0.1" + }, + "engines": { + "node": ">=16 || 14 >=14.17" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, "node_modules/typescript": { "version": "5.1.6", "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.1.6.tgz", diff --git a/package.json b/package.json index 17b5820..5440164 100644 --- a/package.json +++ b/package.json @@ -27,7 +27,7 @@ "postversion": "npm install --package-lock-only --ignore-scripts --silent", "tsx": "tsx", "lint": "test -f ./dist/bin/lint.js || npm run build && ./dist/bin/lint.js", - "lintfix": "sh -c 'test -f ./dist/bin/lint.js || npm run build && ./dist/bin/lint.js --fix'", + "lintfix": "sh -c 'test -f ./dist/bin/lint.js || npm run build && ./dist/bin/lint.js --fix --eslint='{src,scripts}/**/*.{js,mjs,ts,mts,jsx,tsx}''", "lint-shell": "find ./src ./tests ./scripts -type f -regextype posix-extended -regex '.*\\.(sh)' -exec shellcheck {} +", "docs": "shx rm -rf ./docs && typedoc --entryPointStrategy expand --gitRevision master --tsconfig ./tsconfig.build.json --out ./docs src", "test": "node ./scripts/test.mjs" @@ -56,6 +56,7 @@ "jest": "^29.6.2", "jest-extended": "^4.0.2", "jest-junit": "^16.0.0", + "minimatch": "^10.0.1", "prettier": "^3.0.0", "shx": "^0.3.4", "tsconfig-paths": "^3.9.0", diff --git a/src/bin/lint.ts b/src/bin/lint.ts index 51a48e6..4b15b35 100644 --- a/src/bin/lint.ts +++ b/src/bin/lint.ts @@ -6,6 +6,7 @@ import childProcess from 'node:child_process'; import fs from 'node:fs'; import { Command } from 'commander'; import * as utils from '../utils.js'; +import type { CLIOptions } from '../types.js'; const platform = os.platform(); const program = new Command(); @@ -21,16 +22,22 @@ program 'Use user-provided ESLint config instead of built-in one', ) .option('--config ', 'Path to explicit ESLint config file') - .allowUnknownOption(false); // Optional: force rejection of unknown flags + .option('--eslint ', 'Glob(s) to pass to ESLint') + .option('--shell ', 'Glob(s) to pass to shell-check') + .allowUnknownOption(true); // Optional: force rejection of unknown flags /* eslint-disable no-console */ async function main(argv = process.argv) { await program.parseAsync(argv); - const options = program.opts(); + const options = program.opts(); const fix = Boolean(options.fix); const useUserConfig = Boolean(options.userConfig); const explicitConfigPath: string | undefined = options.config; + + const eslintPatterns: string[] | undefined = options.eslint?.flatMap(utils.splitCommaOrSpace); + const shellPatterns: string[] | undefined = options.shell?.flatMap(utils.splitCommaOrSpace); + let hadFailure = false; // Resolve which config file to use @@ -57,7 +64,7 @@ async function main(argv = process.argv) { } try { - await utils.runESLint({ fix, configPath: chosenConfig }); + await utils.runESLint({ fix, configPath: chosenConfig, explicitGlobs: eslintPatterns }); } catch (err) { console.error(`ESLint failed: \n${err}`); hadFailure = true; diff --git a/src/types.ts b/src/types.ts index 6b25cc4..4709a2a 100644 --- a/src/types.ts +++ b/src/types.ts @@ -8,4 +8,13 @@ type RawMatrixCfg = Partial<{ forceInclude: unknown; }>; // “might have these two keys, values are unknown” -export type { MatrixAILintCfg, RawMatrixCfg }; +type CLIOptions = { + fix: boolean; + userConfig: boolean; + config?: string; + eslint?: string[]; + shell?: string[]; +} + + +export type { MatrixAILintCfg, RawMatrixCfg, CLIOptions }; diff --git a/src/utils.ts b/src/utils.ts index c110d78..cf3afcf 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -11,9 +11,11 @@ import { ESLint } from 'eslint'; async function runESLint({ fix, configPath, + explicitGlobs, }: { fix: boolean; configPath?: string; + explicitGlobs?: string[]; }) { const dirname = path.dirname(url.fileURLToPath(import.meta.url)); const defaultConfigPath = path.resolve(dirname, './configs/js.js'); @@ -29,23 +31,33 @@ async function runESLint({ console.log(`Found ${tsconfigPaths.length} tsconfig.json files:`); tsconfigPaths.forEach((tsconfigPath) => console.log(' ' + tsconfigPath)); - const { files: lintFiles, ignore } = buildPatterns( - tsconfigPaths[0], - forceInclude, - ); + let patterns: string[] = []; + let ignorePats: string[] = []; + + if (explicitGlobs?.length) { + patterns = explicitGlobs; + ignorePats = []; + } else { + const { files: lintFiles, ignore: ignorePatterns } = buildPatterns( + tsconfigPaths[0], + forceInclude, + ); + patterns = lintFiles; + ignorePats = ignorePatterns; + } console.log('Linting files:'); - lintFiles.forEach((file) => console.log(' ' + file)); + patterns.forEach((file) => console.log(' ' + file)); const eslint = new ESLint({ overrideConfigFile: configPath || defaultConfigPath, fix, errorOnUnmatchedPattern: false, warnIgnored: false, - ignorePatterns: ignore, + ignorePatterns: explicitGlobs?.length ? [] : ignorePats, }); - const results = await eslint.lintFiles(lintFiles); + const results = await eslint.lintFiles(patterns); if (fix) { await ESLint.outputFixes(results); @@ -232,6 +244,10 @@ function buildPatterns( return { files, ignore }; } +function splitCommaOrSpace(s: string): string[] { + return s.split(/[, ]+/).filter(Boolean); +} + export { runESLint, findUserESLintConfig, @@ -239,4 +255,5 @@ export { commandExists, resolveMatrixConfig, buildPatterns, + splitCommaOrSpace }; From d770cd7205acf1d8072fe4aaaf5761ef1780b32e Mon Sep 17 00:00:00 2001 From: CDeltakai Date: Tue, 29 Apr 2025 16:52:07 +1000 Subject: [PATCH 4/8] fix: removed broken function that was messing up cli options and made the lint script recognize --eslint flag properly --- package.json | 2 +- src/bin/lint.ts | 12 ++++++++---- src/types.ts | 3 +-- src/utils.ts | 5 ----- 4 files changed, 10 insertions(+), 12 deletions(-) diff --git a/package.json b/package.json index 5440164..7d36f87 100644 --- a/package.json +++ b/package.json @@ -27,7 +27,7 @@ "postversion": "npm install --package-lock-only --ignore-scripts --silent", "tsx": "tsx", "lint": "test -f ./dist/bin/lint.js || npm run build && ./dist/bin/lint.js", - "lintfix": "sh -c 'test -f ./dist/bin/lint.js || npm run build && ./dist/bin/lint.js --fix --eslint='{src,scripts}/**/*.{js,mjs,ts,mts,jsx,tsx}''", + "lintfix": "sh -c 'test -f ./dist/bin/lint.js || npm run build && ./dist/bin/lint.js --fix --eslint \"{src,scripts}/**/*.{js,mjs,ts,mts,jsx,tsx}\"'", "lint-shell": "find ./src ./tests ./scripts -type f -regextype posix-extended -regex '.*\\.(sh)' -exec shellcheck {} +", "docs": "shx rm -rf ./docs && typedoc --entryPointStrategy expand --gitRevision master --tsconfig ./tsconfig.build.json --out ./docs src", "test": "node ./scripts/test.mjs" diff --git a/src/bin/lint.ts b/src/bin/lint.ts index 4b15b35..a10d3b7 100644 --- a/src/bin/lint.ts +++ b/src/bin/lint.ts @@ -1,4 +1,5 @@ #!/usr/bin/env node +import type { CLIOptions } from '../types.js'; import os from 'node:os'; import path from 'node:path'; import process from 'node:process'; @@ -6,7 +7,6 @@ import childProcess from 'node:child_process'; import fs from 'node:fs'; import { Command } from 'commander'; import * as utils from '../utils.js'; -import type { CLIOptions } from '../types.js'; const platform = os.platform(); const program = new Command(); @@ -35,8 +35,8 @@ async function main(argv = process.argv) { const useUserConfig = Boolean(options.userConfig); const explicitConfigPath: string | undefined = options.config; - const eslintPatterns: string[] | undefined = options.eslint?.flatMap(utils.splitCommaOrSpace); - const shellPatterns: string[] | undefined = options.shell?.flatMap(utils.splitCommaOrSpace); + const eslintPatterns: string[] | undefined = options.eslint; + const shellPatterns: string[] | undefined = options.shell; let hadFailure = false; @@ -64,7 +64,11 @@ async function main(argv = process.argv) { } try { - await utils.runESLint({ fix, configPath: chosenConfig, explicitGlobs: eslintPatterns }); + await utils.runESLint({ + fix, + configPath: chosenConfig, + explicitGlobs: eslintPatterns, + }); } catch (err) { console.error(`ESLint failed: \n${err}`); hadFailure = true; diff --git a/src/types.ts b/src/types.ts index 4709a2a..70e98bc 100644 --- a/src/types.ts +++ b/src/types.ts @@ -14,7 +14,6 @@ type CLIOptions = { config?: string; eslint?: string[]; shell?: string[]; -} - +}; export type { MatrixAILintCfg, RawMatrixCfg, CLIOptions }; diff --git a/src/utils.ts b/src/utils.ts index cf3afcf..bab9b05 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -244,10 +244,6 @@ function buildPatterns( return { files, ignore }; } -function splitCommaOrSpace(s: string): string[] { - return s.split(/[, ]+/).filter(Boolean); -} - export { runESLint, findUserESLintConfig, @@ -255,5 +251,4 @@ export { commandExists, resolveMatrixConfig, buildPatterns, - splitCommaOrSpace }; From 962d37276f743332d1675a564fb5ac8ff2276d81 Mon Sep 17 00:00:00 2001 From: CDeltakai Date: Tue, 29 Apr 2025 17:16:31 +1000 Subject: [PATCH 5/8] refactor: reorganized the runESLint function to skip the default tsconfig and matrix config stuff if an explicit glob is given --- src/utils.ts | 56 ++++++++++++++++++++++++++++++---------------------- 1 file changed, 32 insertions(+), 24 deletions(-) diff --git a/src/utils.ts b/src/utils.ts index bab9b05..f094343 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -20,43 +20,53 @@ async function runESLint({ const dirname = path.dirname(url.fileURLToPath(import.meta.url)); const defaultConfigPath = path.resolve(dirname, './configs/js.js'); - const matrixaiLintConfig = resolveMatrixConfig(); - const forceInclude = matrixaiLintConfig.forceInclude; - const tsconfigPaths = matrixaiLintConfig.tsconfigPaths; + // PATH A – user supplied explicit globs + if (explicitGlobs?.length) { + console.log('Linting with explicit patterns:'); + explicitGlobs.forEach((g) => console.log(' ' + g)); + + const eslint = new ESLint({ + overrideConfigFile: configPath || defaultConfigPath, + fix, + errorOnUnmatchedPattern: false, + warnIgnored: false, + ignorePatterns: [], // Trust caller entirely + }); + + await lintAndReport(eslint, explicitGlobs, fix); + return; + } + + // PATH B – default behaviour (tsconfig + matrix config) + const { forceInclude, tsconfigPaths } = resolveMatrixConfig(); if (tsconfigPaths.length === 0) { console.error('[matrixai-lint] ⚠ No tsconfig.json files found.'); } console.log(`Found ${tsconfigPaths.length} tsconfig.json files:`); - tsconfigPaths.forEach((tsconfigPath) => console.log(' ' + tsconfigPath)); - - let patterns: string[] = []; - let ignorePats: string[] = []; + tsconfigPaths.forEach((p) => console.log(' ' + p)); - if (explicitGlobs?.length) { - patterns = explicitGlobs; - ignorePats = []; - } else { - const { files: lintFiles, ignore: ignorePatterns } = buildPatterns( - tsconfigPaths[0], - forceInclude, - ); - patterns = lintFiles; - ignorePats = ignorePatterns; - } + const { files: patterns, ignore: ignorePats } = buildPatterns( + tsconfigPaths[0], + forceInclude, + ); console.log('Linting files:'); - patterns.forEach((file) => console.log(' ' + file)); + patterns.forEach((p) => console.log(' ' + p)); const eslint = new ESLint({ overrideConfigFile: configPath || defaultConfigPath, fix, errorOnUnmatchedPattern: false, warnIgnored: false, - ignorePatterns: explicitGlobs?.length ? [] : ignorePats, + ignorePatterns: ignorePats, }); + await lintAndReport(eslint, patterns, fix); +} + +async function lintAndReport(eslint: ESLint, patterns: string[], fix: boolean) { const results = await eslint.lintFiles(patterns); if (fix) { @@ -64,11 +74,9 @@ async function runESLint({ } const formatter = await eslint.loadFormatter('stylish'); - const resultText = formatter.format(results); - console.log(resultText); - - /* eslint-enable no-console */ + console.log(formatter.format(results)); } +/* eslint-enable no-console */ /** * Find the user's ESLint config file in the current working directory. From dc0ef4b6849ecdb022738ccc6ec98032827a61f4 Mon Sep 17 00:00:00 2001 From: CDeltakai Date: Mon, 5 May 2025 09:49:04 +1000 Subject: [PATCH 6/8] fix: removed becnhes from include for tsconfig, testing new commander args for the lint command --- package.json | 4 ++-- tsconfig.json | 1 - 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/package.json b/package.json index 7d36f87..f9508b6 100644 --- a/package.json +++ b/package.json @@ -26,8 +26,8 @@ "build": "shx rm -rf ./dist && tsc -p ./tsconfig.build.json && shx chmod +x dist/bin/lint.js", "postversion": "npm install --package-lock-only --ignore-scripts --silent", "tsx": "tsx", - "lint": "test -f ./dist/bin/lint.js || npm run build && ./dist/bin/lint.js", - "lintfix": "sh -c 'test -f ./dist/bin/lint.js || npm run build && ./dist/bin/lint.js --fix --eslint \"{src,scripts}/**/*.{js,mjs,ts,mts,jsx,tsx}\"'", + "lint": "test -f ./dist/bin/lint.js || npm run build && ./dist/bin/lint.js --eslint \"{src,scripts,tests}/**/*.{js,mjs,ts,mts,jsx,tsx}\"", + "lintfix": "sh -c 'test -f ./dist/bin/lint.js || npm run build && ./dist/bin/lint.js --fix --eslint \"{src,scripts,tests}/**/*.{js,mjs,ts,mts,jsx,tsx}\"'", "lint-shell": "find ./src ./tests ./scripts -type f -regextype posix-extended -regex '.*\\.(sh)' -exec shellcheck {} +", "docs": "shx rm -rf ./docs && typedoc --entryPointStrategy expand --gitRevision master --tsconfig ./tsconfig.build.json --out ./docs src", "test": "node ./scripts/test.mjs" diff --git a/tsconfig.json b/tsconfig.json index 603c879..e18918c 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -26,6 +26,5 @@ "./src/**/*", "./tests/**/*", "./scripts/**/*", - "./benches/**/*" ] } From 9a5c0906244e065dfa4dfa5732ecdd89f86bdf0f Mon Sep 17 00:00:00 2001 From: CDeltakai Date: Tue, 6 May 2025 17:28:44 +1000 Subject: [PATCH 7/8] feat: implemented shell pattern args for linting --- package.json | 4 ++-- src/bin/lint.ts | 6 ++++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/package.json b/package.json index f9508b6..27c9bcf 100644 --- a/package.json +++ b/package.json @@ -26,8 +26,8 @@ "build": "shx rm -rf ./dist && tsc -p ./tsconfig.build.json && shx chmod +x dist/bin/lint.js", "postversion": "npm install --package-lock-only --ignore-scripts --silent", "tsx": "tsx", - "lint": "test -f ./dist/bin/lint.js || npm run build && ./dist/bin/lint.js --eslint \"{src,scripts,tests}/**/*.{js,mjs,ts,mts,jsx,tsx}\"", - "lintfix": "sh -c 'test -f ./dist/bin/lint.js || npm run build && ./dist/bin/lint.js --fix --eslint \"{src,scripts,tests}/**/*.{js,mjs,ts,mts,jsx,tsx}\"'", + "lint": "test -f ./dist/bin/lint.js || npm run build && ./dist/bin/lint.js --eslint \"{src,scripts,tests}/**/*.{js,mjs,ts,mts,jsx,tsx}\" --shell src scripts tests", + "lintfix": "sh -c 'test -f ./dist/bin/lint.js || npm run build && ./dist/bin/lint.js --fix --eslint \"{src,scripts,tests}/**/*.{js,mjs,ts,mts,jsx,tsx}\"' --shell src scripts tests", "lint-shell": "find ./src ./tests ./scripts -type f -regextype posix-extended -regex '.*\\.(sh)' -exec shellcheck {} +", "docs": "shx rm -rf ./docs && typedoc --entryPointStrategy expand --gitRevision master --tsconfig ./tsconfig.build.json --out ./docs src", "test": "node ./scripts/test.mjs" diff --git a/src/bin/lint.ts b/src/bin/lint.ts index a10d3b7..4c38fa0 100644 --- a/src/bin/lint.ts +++ b/src/bin/lint.ts @@ -10,6 +10,7 @@ import * as utils from '../utils.js'; const platform = os.platform(); const program = new Command(); +const DEFAULT_SHELLCHECK_SEARCH_ROOTS = ['./src', './scripts', './tests']; program .name('matrixai-lint') @@ -74,8 +75,9 @@ async function main(argv = process.argv) { hadFailure = true; } - const shellcheckDefaultSearchRoots = ['./src', './scripts', './tests']; - const searchRoots = shellcheckDefaultSearchRoots + const searchRoots = ( + shellPatterns?.length ? shellPatterns : DEFAULT_SHELLCHECK_SEARCH_ROOTS + ) .map((p) => path.resolve(process.cwd(), p)) .filter((p) => fs.existsSync(p)); From f5376cc36d3ff7982efb807e31980c4b67cd977e Mon Sep 17 00:00:00 2001 From: CDeltakai Date: Wed, 7 May 2025 13:21:52 +1000 Subject: [PATCH 8/8] fix: reintroduced benches to tsconfig to try and fix ci failure --- tsconfig.json | 1 + 1 file changed, 1 insertion(+) diff --git a/tsconfig.json b/tsconfig.json index e18918c..603c879 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -26,5 +26,6 @@ "./src/**/*", "./tests/**/*", "./scripts/**/*", + "./benches/**/*" ] }