From b89683aaf1e805ffabd9b0a8e4d4b3977fda8105 Mon Sep 17 00:00:00 2001 From: CDeltakai Date: Tue, 29 Apr 2025 13:56:23 +1000 Subject: [PATCH 01/10] 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 02/10] 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 03/10] 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 04/10] 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 05/10] 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 06/10] 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 07/10] 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 08/10] 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/**/*" ] } From 9b77f0b7e6ba76c6a24d2554931cc50604c8fca4 Mon Sep 17 00:00:00 2001 From: CDeltakai Date: Wed, 7 May 2025 13:42:07 +1000 Subject: [PATCH 09/10] fix: regenerate docs --- docs/assets/search.js | 2 +- docs/functions/bin_lint.default.html | 2 +- docs/functions/utils.buildPatterns.html | 2 +- docs/functions/utils.collectMarkdown.html | 2 +- docs/functions/utils.commandExists.html | 2 +- .../functions/utils.findUserESLintConfig.html | 2 +- docs/functions/utils.resolveMatrixConfig.html | 2 +- docs/functions/utils.runESLint.html | 4 +- docs/index.html | 30 +++------ docs/modules/types.html | 4 +- docs/types/types.CLIOptions.html | 67 +++++++++++++++++++ docs/types/types.MatrixAILintCfg.html | 3 +- docs/types/types.RawMatrixCfg.html | 3 +- 13 files changed, 93 insertions(+), 32 deletions(-) create mode 100644 docs/types/types.CLIOptions.html diff --git a/docs/assets/search.js b/docs/assets/search.js index 4c5860a..4c8574c 100644 --- a/docs/assets/search.js +++ b/docs/assets/search.js @@ -1 +1 @@ -window.searchData = JSON.parse("{\"rows\":[{\"kind\":2,\"name\":\"bin/lint\",\"url\":\"modules/bin_lint.html\",\"classes\":\"\"},{\"kind\":64,\"name\":\"default\",\"url\":\"functions/bin_lint.default.html\",\"classes\":\"\",\"parent\":\"bin/lint\"},{\"kind\":2,\"name\":\"configs/js\",\"url\":\"modules/configs_js.html\",\"classes\":\"\"},{\"kind\":32,\"name\":\"default\",\"url\":\"variables/configs_js.default.html\",\"classes\":\"\",\"parent\":\"configs/js\"},{\"kind\":2,\"name\":\"plugins/eslint-plugin-matrixai\",\"url\":\"modules/plugins_eslint_plugin_matrixai.html\",\"classes\":\"\"},{\"kind\":32,\"name\":\"default\",\"url\":\"variables/plugins_eslint_plugin_matrixai.default.html\",\"classes\":\"\",\"parent\":\"plugins/eslint-plugin-matrixai\"},{\"kind\":65536,\"name\":\"__type\",\"url\":\"variables/plugins_eslint_plugin_matrixai.default.html#__type\",\"classes\":\"\",\"parent\":\"plugins/eslint-plugin-matrixai.default\"},{\"kind\":1024,\"name\":\"meta\",\"url\":\"variables/plugins_eslint_plugin_matrixai.default.html#__type.meta\",\"classes\":\"\",\"parent\":\"plugins/eslint-plugin-matrixai.default.__type\"},{\"kind\":65536,\"name\":\"__type\",\"url\":\"variables/plugins_eslint_plugin_matrixai.default.html#__type.meta.__type-2\",\"classes\":\"\",\"parent\":\"plugins/eslint-plugin-matrixai.default.__type.meta\"},{\"kind\":1024,\"name\":\"name\",\"url\":\"variables/plugins_eslint_plugin_matrixai.default.html#__type.meta.__type-2.name\",\"classes\":\"\",\"parent\":\"plugins/eslint-plugin-matrixai.default.__type.meta.__type\"},{\"kind\":1024,\"name\":\"version\",\"url\":\"variables/plugins_eslint_plugin_matrixai.default.html#__type.meta.__type-2.version\",\"classes\":\"\",\"parent\":\"plugins/eslint-plugin-matrixai.default.__type.meta.__type\"},{\"kind\":1024,\"name\":\"rules\",\"url\":\"variables/plugins_eslint_plugin_matrixai.default.html#__type.rules\",\"classes\":\"\",\"parent\":\"plugins/eslint-plugin-matrixai.default.__type\"},{\"kind\":65536,\"name\":\"__type\",\"url\":\"variables/plugins_eslint_plugin_matrixai.default.html#__type.rules.__type-3\",\"classes\":\"\",\"parent\":\"plugins/eslint-plugin-matrixai.default.__type.rules\"},{\"kind\":1024,\"name\":\"no-aliased-imports\",\"url\":\"variables/plugins_eslint_plugin_matrixai.default.html#__type.rules.__type-3.no_aliased_imports\",\"classes\":\"\",\"parent\":\"plugins/eslint-plugin-matrixai.default.__type.rules.__type\"},{\"kind\":1024,\"name\":\"configs\",\"url\":\"variables/plugins_eslint_plugin_matrixai.default.html#__type.configs\",\"classes\":\"\",\"parent\":\"plugins/eslint-plugin-matrixai.default.__type\"},{\"kind\":65536,\"name\":\"__type\",\"url\":\"variables/plugins_eslint_plugin_matrixai.default.html#__type.configs.__type-1\",\"classes\":\"\",\"parent\":\"plugins/eslint-plugin-matrixai.default.__type.configs\"},{\"kind\":2,\"name\":\"rules/no-aliased-imports\",\"url\":\"modules/rules_no_aliased_imports.html\",\"classes\":\"\"},{\"kind\":32,\"name\":\"noAliasedImportsRule\",\"url\":\"variables/rules_no_aliased_imports.noAliasedImportsRule.html\",\"classes\":\"\",\"parent\":\"rules/no-aliased-imports\"},{\"kind\":8388608,\"name\":\"default\",\"url\":\"modules/rules_no_aliased_imports.html#default\",\"classes\":\"\",\"parent\":\"rules/no-aliased-imports\"},{\"kind\":2,\"name\":\"types\",\"url\":\"modules/types.html\",\"classes\":\"\"},{\"kind\":4194304,\"name\":\"MatrixAILintCfg\",\"url\":\"types/types.MatrixAILintCfg.html\",\"classes\":\"\",\"parent\":\"types\"},{\"kind\":65536,\"name\":\"__type\",\"url\":\"types/types.MatrixAILintCfg.html#__type\",\"classes\":\"\",\"parent\":\"types.MatrixAILintCfg\"},{\"kind\":1024,\"name\":\"tsconfigPaths\",\"url\":\"types/types.MatrixAILintCfg.html#__type.tsconfigPaths\",\"classes\":\"\",\"parent\":\"types.MatrixAILintCfg.__type\"},{\"kind\":1024,\"name\":\"forceInclude\",\"url\":\"types/types.MatrixAILintCfg.html#__type.forceInclude\",\"classes\":\"\",\"parent\":\"types.MatrixAILintCfg.__type\"},{\"kind\":4194304,\"name\":\"RawMatrixCfg\",\"url\":\"types/types.RawMatrixCfg.html\",\"classes\":\"\",\"parent\":\"types\"},{\"kind\":2,\"name\":\"utils\",\"url\":\"modules/utils.html\",\"classes\":\"\"},{\"kind\":64,\"name\":\"runESLint\",\"url\":\"functions/utils.runESLint.html\",\"classes\":\"\",\"parent\":\"utils\"},{\"kind\":64,\"name\":\"findUserESLintConfig\",\"url\":\"functions/utils.findUserESLintConfig.html\",\"classes\":\"\",\"parent\":\"utils\"},{\"kind\":64,\"name\":\"collectMarkdown\",\"url\":\"functions/utils.collectMarkdown.html\",\"classes\":\"\",\"parent\":\"utils\"},{\"kind\":64,\"name\":\"commandExists\",\"url\":\"functions/utils.commandExists.html\",\"classes\":\"\",\"parent\":\"utils\"},{\"kind\":64,\"name\":\"resolveMatrixConfig\",\"url\":\"functions/utils.resolveMatrixConfig.html\",\"classes\":\"\",\"parent\":\"utils\"},{\"kind\":64,\"name\":\"buildPatterns\",\"url\":\"functions/utils.buildPatterns.html\",\"classes\":\"\",\"parent\":\"utils\"},{\"kind\":65536,\"name\":\"__type\",\"url\":\"functions/utils.buildPatterns.html#buildPatterns.__type\",\"classes\":\"\",\"parent\":\"utils.buildPatterns.buildPatterns\"},{\"kind\":1024,\"name\":\"files\",\"url\":\"functions/utils.buildPatterns.html#buildPatterns.__type.files\",\"classes\":\"\",\"parent\":\"utils.buildPatterns.buildPatterns.__type\"},{\"kind\":1024,\"name\":\"ignore\",\"url\":\"functions/utils.buildPatterns.html#buildPatterns.__type.ignore\",\"classes\":\"\",\"parent\":\"utils.buildPatterns.buildPatterns.__type\"}],\"index\":{\"version\":\"2.3.9\",\"fields\":[\"name\",\"comment\"],\"fieldVectors\":[[\"name/0\",[0,33.804]],[\"comment/0\",[]],[\"name/1\",[1,22.119]],[\"comment/1\",[]],[\"name/2\",[2,33.804]],[\"comment/2\",[]],[\"name/3\",[1,22.119]],[\"comment/3\",[]],[\"name/4\",[3,19.395,4,19.395,5,19.395]],[\"comment/4\",[]],[\"name/5\",[1,22.119]],[\"comment/5\",[]],[\"name/6\",[6,18.207]],[\"comment/6\",[]],[\"name/7\",[7,33.804]],[\"comment/7\",[]],[\"name/8\",[6,18.207]],[\"comment/8\",[]],[\"name/9\",[8,33.804]],[\"comment/9\",[]],[\"name/10\",[9,33.804]],[\"comment/10\",[]],[\"name/11\",[10,33.804]],[\"comment/11\",[]],[\"name/12\",[6,18.207]],[\"comment/12\",[]],[\"name/13\",[11,19.395,12,16.278,13,16.278]],[\"comment/13\",[]],[\"name/14\",[14,33.804]],[\"comment/14\",[]],[\"name/15\",[6,18.207]],[\"comment/15\",[]],[\"name/16\",[12,16.278,13,16.278,15,19.395]],[\"comment/16\",[]],[\"name/17\",[16,33.804]],[\"comment/17\",[]],[\"name/18\",[1,22.119]],[\"comment/18\",[]],[\"name/19\",[17,33.804]],[\"comment/19\",[]],[\"name/20\",[18,33.804]],[\"comment/20\",[]],[\"name/21\",[6,18.207]],[\"comment/21\",[]],[\"name/22\",[19,33.804]],[\"comment/22\",[]],[\"name/23\",[20,33.804]],[\"comment/23\",[]],[\"name/24\",[21,33.804]],[\"comment/24\",[]],[\"name/25\",[22,33.804]],[\"comment/25\",[]],[\"name/26\",[23,33.804]],[\"comment/26\",[]],[\"name/27\",[24,33.804]],[\"comment/27\",[]],[\"name/28\",[25,33.804]],[\"comment/28\",[]],[\"name/29\",[26,33.804]],[\"comment/29\",[]],[\"name/30\",[27,33.804]],[\"comment/30\",[]],[\"name/31\",[28,33.804]],[\"comment/31\",[]],[\"name/32\",[6,18.207]],[\"comment/32\",[]],[\"name/33\",[29,33.804]],[\"comment/33\",[]],[\"name/34\",[30,33.804]],[\"comment/34\",[]]],\"invertedIndex\":[[\"__type\",{\"_index\":6,\"name\":{\"6\":{},\"8\":{},\"12\":{},\"15\":{},\"21\":{},\"32\":{}},\"comment\":{}}],[\"aliased\",{\"_index\":12,\"name\":{\"13\":{},\"16\":{}},\"comment\":{}}],[\"bin/lint\",{\"_index\":0,\"name\":{\"0\":{}},\"comment\":{}}],[\"buildpatterns\",{\"_index\":28,\"name\":{\"31\":{}},\"comment\":{}}],[\"collectmarkdown\",{\"_index\":25,\"name\":{\"28\":{}},\"comment\":{}}],[\"commandexists\",{\"_index\":26,\"name\":{\"29\":{}},\"comment\":{}}],[\"configs\",{\"_index\":14,\"name\":{\"14\":{}},\"comment\":{}}],[\"configs/js\",{\"_index\":2,\"name\":{\"2\":{}},\"comment\":{}}],[\"default\",{\"_index\":1,\"name\":{\"1\":{},\"3\":{},\"5\":{},\"18\":{}},\"comment\":{}}],[\"files\",{\"_index\":29,\"name\":{\"33\":{}},\"comment\":{}}],[\"findusereslintconfig\",{\"_index\":24,\"name\":{\"27\":{}},\"comment\":{}}],[\"forceinclude\",{\"_index\":20,\"name\":{\"23\":{}},\"comment\":{}}],[\"ignore\",{\"_index\":30,\"name\":{\"34\":{}},\"comment\":{}}],[\"imports\",{\"_index\":13,\"name\":{\"13\":{},\"16\":{}},\"comment\":{}}],[\"matrixai\",{\"_index\":5,\"name\":{\"4\":{}},\"comment\":{}}],[\"matrixailintcfg\",{\"_index\":18,\"name\":{\"20\":{}},\"comment\":{}}],[\"meta\",{\"_index\":7,\"name\":{\"7\":{}},\"comment\":{}}],[\"name\",{\"_index\":8,\"name\":{\"9\":{}},\"comment\":{}}],[\"no\",{\"_index\":11,\"name\":{\"13\":{}},\"comment\":{}}],[\"noaliasedimportsrule\",{\"_index\":16,\"name\":{\"17\":{}},\"comment\":{}}],[\"plugin\",{\"_index\":4,\"name\":{\"4\":{}},\"comment\":{}}],[\"plugins/eslint\",{\"_index\":3,\"name\":{\"4\":{}},\"comment\":{}}],[\"rawmatrixcfg\",{\"_index\":21,\"name\":{\"24\":{}},\"comment\":{}}],[\"resolvematrixconfig\",{\"_index\":27,\"name\":{\"30\":{}},\"comment\":{}}],[\"rules\",{\"_index\":10,\"name\":{\"11\":{}},\"comment\":{}}],[\"rules/no\",{\"_index\":15,\"name\":{\"16\":{}},\"comment\":{}}],[\"runeslint\",{\"_index\":23,\"name\":{\"26\":{}},\"comment\":{}}],[\"tsconfigpaths\",{\"_index\":19,\"name\":{\"22\":{}},\"comment\":{}}],[\"types\",{\"_index\":17,\"name\":{\"19\":{}},\"comment\":{}}],[\"utils\",{\"_index\":22,\"name\":{\"25\":{}},\"comment\":{}}],[\"version\",{\"_index\":9,\"name\":{\"10\":{}},\"comment\":{}}]],\"pipeline\":[]}}"); \ No newline at end of file +window.searchData = JSON.parse("{\"rows\":[{\"kind\":2,\"name\":\"bin/lint\",\"url\":\"modules/bin_lint.html\",\"classes\":\"\"},{\"kind\":64,\"name\":\"default\",\"url\":\"functions/bin_lint.default.html\",\"classes\":\"\",\"parent\":\"bin/lint\"},{\"kind\":2,\"name\":\"configs/js\",\"url\":\"modules/configs_js.html\",\"classes\":\"\"},{\"kind\":32,\"name\":\"default\",\"url\":\"variables/configs_js.default.html\",\"classes\":\"\",\"parent\":\"configs/js\"},{\"kind\":2,\"name\":\"plugins/eslint-plugin-matrixai\",\"url\":\"modules/plugins_eslint_plugin_matrixai.html\",\"classes\":\"\"},{\"kind\":32,\"name\":\"default\",\"url\":\"variables/plugins_eslint_plugin_matrixai.default.html\",\"classes\":\"\",\"parent\":\"plugins/eslint-plugin-matrixai\"},{\"kind\":65536,\"name\":\"__type\",\"url\":\"variables/plugins_eslint_plugin_matrixai.default.html#__type\",\"classes\":\"\",\"parent\":\"plugins/eslint-plugin-matrixai.default\"},{\"kind\":1024,\"name\":\"meta\",\"url\":\"variables/plugins_eslint_plugin_matrixai.default.html#__type.meta\",\"classes\":\"\",\"parent\":\"plugins/eslint-plugin-matrixai.default.__type\"},{\"kind\":65536,\"name\":\"__type\",\"url\":\"variables/plugins_eslint_plugin_matrixai.default.html#__type.meta.__type-2\",\"classes\":\"\",\"parent\":\"plugins/eslint-plugin-matrixai.default.__type.meta\"},{\"kind\":1024,\"name\":\"name\",\"url\":\"variables/plugins_eslint_plugin_matrixai.default.html#__type.meta.__type-2.name\",\"classes\":\"\",\"parent\":\"plugins/eslint-plugin-matrixai.default.__type.meta.__type\"},{\"kind\":1024,\"name\":\"version\",\"url\":\"variables/plugins_eslint_plugin_matrixai.default.html#__type.meta.__type-2.version\",\"classes\":\"\",\"parent\":\"plugins/eslint-plugin-matrixai.default.__type.meta.__type\"},{\"kind\":1024,\"name\":\"rules\",\"url\":\"variables/plugins_eslint_plugin_matrixai.default.html#__type.rules\",\"classes\":\"\",\"parent\":\"plugins/eslint-plugin-matrixai.default.__type\"},{\"kind\":65536,\"name\":\"__type\",\"url\":\"variables/plugins_eslint_plugin_matrixai.default.html#__type.rules.__type-3\",\"classes\":\"\",\"parent\":\"plugins/eslint-plugin-matrixai.default.__type.rules\"},{\"kind\":1024,\"name\":\"no-aliased-imports\",\"url\":\"variables/plugins_eslint_plugin_matrixai.default.html#__type.rules.__type-3.no_aliased_imports\",\"classes\":\"\",\"parent\":\"plugins/eslint-plugin-matrixai.default.__type.rules.__type\"},{\"kind\":1024,\"name\":\"configs\",\"url\":\"variables/plugins_eslint_plugin_matrixai.default.html#__type.configs\",\"classes\":\"\",\"parent\":\"plugins/eslint-plugin-matrixai.default.__type\"},{\"kind\":65536,\"name\":\"__type\",\"url\":\"variables/plugins_eslint_plugin_matrixai.default.html#__type.configs.__type-1\",\"classes\":\"\",\"parent\":\"plugins/eslint-plugin-matrixai.default.__type.configs\"},{\"kind\":2,\"name\":\"rules/no-aliased-imports\",\"url\":\"modules/rules_no_aliased_imports.html\",\"classes\":\"\"},{\"kind\":32,\"name\":\"noAliasedImportsRule\",\"url\":\"variables/rules_no_aliased_imports.noAliasedImportsRule.html\",\"classes\":\"\",\"parent\":\"rules/no-aliased-imports\"},{\"kind\":8388608,\"name\":\"default\",\"url\":\"modules/rules_no_aliased_imports.html#default\",\"classes\":\"\",\"parent\":\"rules/no-aliased-imports\"},{\"kind\":2,\"name\":\"types\",\"url\":\"modules/types.html\",\"classes\":\"\"},{\"kind\":4194304,\"name\":\"MatrixAILintCfg\",\"url\":\"types/types.MatrixAILintCfg.html\",\"classes\":\"\",\"parent\":\"types\"},{\"kind\":65536,\"name\":\"__type\",\"url\":\"types/types.MatrixAILintCfg.html#__type\",\"classes\":\"\",\"parent\":\"types.MatrixAILintCfg\"},{\"kind\":1024,\"name\":\"tsconfigPaths\",\"url\":\"types/types.MatrixAILintCfg.html#__type.tsconfigPaths\",\"classes\":\"\",\"parent\":\"types.MatrixAILintCfg.__type\"},{\"kind\":1024,\"name\":\"forceInclude\",\"url\":\"types/types.MatrixAILintCfg.html#__type.forceInclude\",\"classes\":\"\",\"parent\":\"types.MatrixAILintCfg.__type\"},{\"kind\":4194304,\"name\":\"RawMatrixCfg\",\"url\":\"types/types.RawMatrixCfg.html\",\"classes\":\"\",\"parent\":\"types\"},{\"kind\":4194304,\"name\":\"CLIOptions\",\"url\":\"types/types.CLIOptions.html\",\"classes\":\"\",\"parent\":\"types\"},{\"kind\":65536,\"name\":\"__type\",\"url\":\"types/types.CLIOptions.html#__type\",\"classes\":\"\",\"parent\":\"types.CLIOptions\"},{\"kind\":1024,\"name\":\"fix\",\"url\":\"types/types.CLIOptions.html#__type.fix\",\"classes\":\"\",\"parent\":\"types.CLIOptions.__type\"},{\"kind\":1024,\"name\":\"userConfig\",\"url\":\"types/types.CLIOptions.html#__type.userConfig\",\"classes\":\"\",\"parent\":\"types.CLIOptions.__type\"},{\"kind\":1024,\"name\":\"config\",\"url\":\"types/types.CLIOptions.html#__type.config\",\"classes\":\"\",\"parent\":\"types.CLIOptions.__type\"},{\"kind\":1024,\"name\":\"eslint\",\"url\":\"types/types.CLIOptions.html#__type.eslint\",\"classes\":\"\",\"parent\":\"types.CLIOptions.__type\"},{\"kind\":1024,\"name\":\"shell\",\"url\":\"types/types.CLIOptions.html#__type.shell\",\"classes\":\"\",\"parent\":\"types.CLIOptions.__type\"},{\"kind\":2,\"name\":\"utils\",\"url\":\"modules/utils.html\",\"classes\":\"\"},{\"kind\":64,\"name\":\"runESLint\",\"url\":\"functions/utils.runESLint.html\",\"classes\":\"\",\"parent\":\"utils\"},{\"kind\":64,\"name\":\"findUserESLintConfig\",\"url\":\"functions/utils.findUserESLintConfig.html\",\"classes\":\"\",\"parent\":\"utils\"},{\"kind\":64,\"name\":\"collectMarkdown\",\"url\":\"functions/utils.collectMarkdown.html\",\"classes\":\"\",\"parent\":\"utils\"},{\"kind\":64,\"name\":\"commandExists\",\"url\":\"functions/utils.commandExists.html\",\"classes\":\"\",\"parent\":\"utils\"},{\"kind\":64,\"name\":\"resolveMatrixConfig\",\"url\":\"functions/utils.resolveMatrixConfig.html\",\"classes\":\"\",\"parent\":\"utils\"},{\"kind\":64,\"name\":\"buildPatterns\",\"url\":\"functions/utils.buildPatterns.html\",\"classes\":\"\",\"parent\":\"utils\"},{\"kind\":65536,\"name\":\"__type\",\"url\":\"functions/utils.buildPatterns.html#buildPatterns.__type\",\"classes\":\"\",\"parent\":\"utils.buildPatterns.buildPatterns\"},{\"kind\":1024,\"name\":\"files\",\"url\":\"functions/utils.buildPatterns.html#buildPatterns.__type.files\",\"classes\":\"\",\"parent\":\"utils.buildPatterns.buildPatterns.__type\"},{\"kind\":1024,\"name\":\"ignore\",\"url\":\"functions/utils.buildPatterns.html#buildPatterns.__type.ignore\",\"classes\":\"\",\"parent\":\"utils.buildPatterns.buildPatterns.__type\"}],\"index\":{\"version\":\"2.3.9\",\"fields\":[\"name\",\"comment\"],\"fieldVectors\":[[\"name/0\",[0,35.366]],[\"comment/0\",[]],[\"name/1\",[1,23.788]],[\"comment/1\",[]],[\"name/2\",[2,35.366]],[\"comment/2\",[]],[\"name/3\",[1,23.788]],[\"comment/3\",[]],[\"name/4\",[3,20.157,4,20.157,5,20.157]],[\"comment/4\",[]],[\"name/5\",[1,23.788]],[\"comment/5\",[]],[\"name/6\",[6,18.404]],[\"comment/6\",[]],[\"name/7\",[7,35.366]],[\"comment/7\",[]],[\"name/8\",[6,18.404]],[\"comment/8\",[]],[\"name/9\",[8,35.366]],[\"comment/9\",[]],[\"name/10\",[9,35.366]],[\"comment/10\",[]],[\"name/11\",[10,35.366]],[\"comment/11\",[]],[\"name/12\",[6,18.404]],[\"comment/12\",[]],[\"name/13\",[11,20.157,12,17.089,13,17.089]],[\"comment/13\",[]],[\"name/14\",[14,35.366]],[\"comment/14\",[]],[\"name/15\",[6,18.404]],[\"comment/15\",[]],[\"name/16\",[12,17.089,13,17.089,15,20.157]],[\"comment/16\",[]],[\"name/17\",[16,35.366]],[\"comment/17\",[]],[\"name/18\",[1,23.788]],[\"comment/18\",[]],[\"name/19\",[17,35.366]],[\"comment/19\",[]],[\"name/20\",[18,35.366]],[\"comment/20\",[]],[\"name/21\",[6,18.404]],[\"comment/21\",[]],[\"name/22\",[19,35.366]],[\"comment/22\",[]],[\"name/23\",[20,35.366]],[\"comment/23\",[]],[\"name/24\",[21,35.366]],[\"comment/24\",[]],[\"name/25\",[22,35.366]],[\"comment/25\",[]],[\"name/26\",[6,18.404]],[\"comment/26\",[]],[\"name/27\",[23,35.366]],[\"comment/27\",[]],[\"name/28\",[24,35.366]],[\"comment/28\",[]],[\"name/29\",[25,35.366]],[\"comment/29\",[]],[\"name/30\",[26,35.366]],[\"comment/30\",[]],[\"name/31\",[27,35.366]],[\"comment/31\",[]],[\"name/32\",[28,35.366]],[\"comment/32\",[]],[\"name/33\",[29,35.366]],[\"comment/33\",[]],[\"name/34\",[30,35.366]],[\"comment/34\",[]],[\"name/35\",[31,35.366]],[\"comment/35\",[]],[\"name/36\",[32,35.366]],[\"comment/36\",[]],[\"name/37\",[33,35.366]],[\"comment/37\",[]],[\"name/38\",[34,35.366]],[\"comment/38\",[]],[\"name/39\",[6,18.404]],[\"comment/39\",[]],[\"name/40\",[35,35.366]],[\"comment/40\",[]],[\"name/41\",[36,35.366]],[\"comment/41\",[]]],\"invertedIndex\":[[\"__type\",{\"_index\":6,\"name\":{\"6\":{},\"8\":{},\"12\":{},\"15\":{},\"21\":{},\"26\":{},\"39\":{}},\"comment\":{}}],[\"aliased\",{\"_index\":12,\"name\":{\"13\":{},\"16\":{}},\"comment\":{}}],[\"bin/lint\",{\"_index\":0,\"name\":{\"0\":{}},\"comment\":{}}],[\"buildpatterns\",{\"_index\":34,\"name\":{\"38\":{}},\"comment\":{}}],[\"clioptions\",{\"_index\":22,\"name\":{\"25\":{}},\"comment\":{}}],[\"collectmarkdown\",{\"_index\":31,\"name\":{\"35\":{}},\"comment\":{}}],[\"commandexists\",{\"_index\":32,\"name\":{\"36\":{}},\"comment\":{}}],[\"config\",{\"_index\":25,\"name\":{\"29\":{}},\"comment\":{}}],[\"configs\",{\"_index\":14,\"name\":{\"14\":{}},\"comment\":{}}],[\"configs/js\",{\"_index\":2,\"name\":{\"2\":{}},\"comment\":{}}],[\"default\",{\"_index\":1,\"name\":{\"1\":{},\"3\":{},\"5\":{},\"18\":{}},\"comment\":{}}],[\"eslint\",{\"_index\":26,\"name\":{\"30\":{}},\"comment\":{}}],[\"files\",{\"_index\":35,\"name\":{\"40\":{}},\"comment\":{}}],[\"findusereslintconfig\",{\"_index\":30,\"name\":{\"34\":{}},\"comment\":{}}],[\"fix\",{\"_index\":23,\"name\":{\"27\":{}},\"comment\":{}}],[\"forceinclude\",{\"_index\":20,\"name\":{\"23\":{}},\"comment\":{}}],[\"ignore\",{\"_index\":36,\"name\":{\"41\":{}},\"comment\":{}}],[\"imports\",{\"_index\":13,\"name\":{\"13\":{},\"16\":{}},\"comment\":{}}],[\"matrixai\",{\"_index\":5,\"name\":{\"4\":{}},\"comment\":{}}],[\"matrixailintcfg\",{\"_index\":18,\"name\":{\"20\":{}},\"comment\":{}}],[\"meta\",{\"_index\":7,\"name\":{\"7\":{}},\"comment\":{}}],[\"name\",{\"_index\":8,\"name\":{\"9\":{}},\"comment\":{}}],[\"no\",{\"_index\":11,\"name\":{\"13\":{}},\"comment\":{}}],[\"noaliasedimportsrule\",{\"_index\":16,\"name\":{\"17\":{}},\"comment\":{}}],[\"plugin\",{\"_index\":4,\"name\":{\"4\":{}},\"comment\":{}}],[\"plugins/eslint\",{\"_index\":3,\"name\":{\"4\":{}},\"comment\":{}}],[\"rawmatrixcfg\",{\"_index\":21,\"name\":{\"24\":{}},\"comment\":{}}],[\"resolvematrixconfig\",{\"_index\":33,\"name\":{\"37\":{}},\"comment\":{}}],[\"rules\",{\"_index\":10,\"name\":{\"11\":{}},\"comment\":{}}],[\"rules/no\",{\"_index\":15,\"name\":{\"16\":{}},\"comment\":{}}],[\"runeslint\",{\"_index\":29,\"name\":{\"33\":{}},\"comment\":{}}],[\"shell\",{\"_index\":27,\"name\":{\"31\":{}},\"comment\":{}}],[\"tsconfigpaths\",{\"_index\":19,\"name\":{\"22\":{}},\"comment\":{}}],[\"types\",{\"_index\":17,\"name\":{\"19\":{}},\"comment\":{}}],[\"userconfig\",{\"_index\":24,\"name\":{\"28\":{}},\"comment\":{}}],[\"utils\",{\"_index\":28,\"name\":{\"32\":{}},\"comment\":{}}],[\"version\",{\"_index\":9,\"name\":{\"10\":{}},\"comment\":{}}]],\"pipeline\":[]}}"); \ No newline at end of file diff --git a/docs/functions/bin_lint.default.html b/docs/functions/bin_lint.default.html index 38326b3..6205082 100644 --- a/docs/functions/bin_lint.default.html +++ b/docs/functions/bin_lint.default.html @@ -27,7 +27,7 @@

Parameters

argv: string[] = process.argv

Returns Promise<void>

+
  • Defined in src/bin/lint.ts:31
  • +
  • Defined in src/utils.ts:112
  • +
  • Defined in src/utils.ts:125
  • +
  • Defined in src/utils.ts:92
  • Returns Promise<void>

    Flag Description - - (no flag) Uses built-in Matrix AI ESLint config - - --fix Enables auto-fixing via ESLint and Prettier - - --user-config -Uses detected `eslint.config.[c -m -t]js` from the project root if found +Uses detected `eslint.config.[js,mjs,cjs,ts] from the project root if found --config <path> Explicitly use a custom ESLint config file - -

    Examples

    matrixai-lint --fix
    matrixai-lint --user-config
    matrixai-lint --config ./eslint.config.js --fix
    -

    TypeScript Support

    The linter is TypeScript-aware and **requires a **tsconfig.json to determine which files to lint and how to parse them.

    +

    TypeScript Support

    The linter is TypeScript-aware and requires a tsconfig.json to determine which files to lint and how to parse them.

    By default:

    • It looks for tsconfig.json in the project root
    • @@ -95,10 +85,10 @@

      @matrixai/lint

    ⚠ If a path in forceInclude is not included in any of the tsconfigPaths, TypeScript will throw a parsing error.

    -

    ESLint Config Override

    You can use your own ESLint config by one of the following methods:

    -

    1. Inline Custom Config

    matrixai-lint --config ./eslint.config.js
    +

    ESLint Config Override

    You can use your own ESLint config by one of the following methods:

    +

    1. Inline Custom Config

    matrixai-lint --config ./eslint.config.js
     
    -

    2. Auto-detect with --user-config

    matrixai-lint --user-config
    +

    2. Auto-detect with --user-config

    matrixai-lint --user-config
     

    This will look for a valid eslint.config file in the project root.

    Valid config filenames:

    @@ -108,7 +98,7 @@

    @matrixai/lint

  • eslint.config.mjs
  • eslint.config.ts
  • -

    3. Extend the base config

    // eslint.config.js
    import matrixai from '@matrixai/lint/config';

    export default [
    ...matrixai,
    {
    rules: {
    '@typescript-eslint/no-explicit-any': 'error',
    'no-console': 'off',
    },
    },
    ]; +

    3. Extend the base config

    // eslint.config.js
    import matrixai from '@matrixai/lint/config';

    export default [
    ...matrixai,
    {
    rules: {
    '@typescript-eslint/no-explicit-any': 'error',
    'no-console': 'off',
    },
    },
    ];

    Development

    Run nix develop, and once you're inside, you can use:

    # install (or reinstall packages from package.json)
    npm install
    # build the dist
    npm run build
    # run the repl (this allows you to import from ./src)
    npm run tsx
    # run the tests
    npm run test
    # lint the source code
    npm run lint
    # automatically fix the source
    npm run lintfix @@ -156,17 +146,15 @@

    CLI Options -
  • Examples
  • +
  • Examples
  • TypeScript Support
  • -
  • -
  • +
  • Working with multiple tsconfigs
  • ESLint Config Override
  • +
  • 3. Extend the base config
  • Development
    • diff --git a/docs/modules/types.html b/docs/modules/types.html index 52bcf37..fcd3a34 100644 --- a/docs/modules/types.html +++ b/docs/modules/types.html @@ -22,7 +22,8 @@

      Module types

    From 48afb33d6504931a05b631567bc9dc0f4588ade0 Mon Sep 17 00:00:00 2001 From: CDeltakai Date: Wed, 7 May 2025 13:44:49 +1000 Subject: [PATCH 10/10] 0.2.0 --- package-lock.json | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/package-lock.json b/package-lock.json index e5f350a..07b933a 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@matrixai/lint", - "version": "0.1.0", + "version": "0.2.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@matrixai/lint", - "version": "0.1.0", + "version": "0.2.0", "license": "Apache-2.0", "dependencies": { "@eslint/compat": "^1.2.5", diff --git a/package.json b/package.json index 27c9bcf..9716d16 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@matrixai/lint", - "version": "0.1.0", + "version": "0.2.0", "author": "Roger Qiu", "description": "Org wide custom eslint rules", "license": "Apache-2.0",