Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -209,8 +209,8 @@ Golden commands:
Notes:

- `npm run lint` and `npm run lintfix` invoke `npm run prepare` first so the
compiled CLI in `dist/bin/lint.js` stays up to date while keeping TypeScript
incremental rebuilds fast.
compiled CLI in `dist/bin/matrixai-lint.js` stays up to date while keeping
TypeScript incremental rebuilds fast.

For the authoritative contributor guidance see [AGENTS.md](AGENTS.md).

Expand Down
6 changes: 3 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 6 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@matrixai/lint",
"version": "0.4.0",
"version": "0.4.1",
"author": "Roger Qiu",
"description": "Org wide custom eslint rules",
"license": "Apache-2.0",
Expand Down Expand Up @@ -29,16 +29,16 @@
"#*": "./dist/*"
},
"bin": {
"matrixai-lint": "dist/bin/lint.js"
"matrixai-lint": "dist/bin/matrixai-lint.js"
},
"scripts": {
"prepare": "tsc -p ./tsconfig.build.json",
"build": "shx rm -rf ./dist && tsc -p ./tsconfig.build.json && shx chmod +x ./dist/bin/lint.js",
"build": "shx rm -rf ./dist && tsc -p ./tsconfig.build.json && shx chmod +x ./dist/bin/matrixai-lint.js",
"postversion": "npm install --package-lock-only --ignore-scripts --silent",
"tsx": "tsx",
"lint": "npm run prepare && node ./dist/bin/lint.js --domain eslint shell markdown --eslint \"{src,scripts,tests}/**/*.{js,mjs,ts,mts,jsx,tsx}\" --shell src scripts tests",
"lintfix": "npm run prepare && node ./dist/bin/lint.js --fix --domain eslint shell markdown --eslint \"{src,scripts,tests}/**/*.{js,mjs,ts,mts,jsx,tsx}\" --shell src scripts tests",
"lint-shell": "npm run prepare && node ./dist/bin/lint.js --domain shell --shell src scripts tests",
"lint": "npm run prepare && node ./dist/bin/matrixai-lint.js --domain eslint shell markdown --eslint \"{src,scripts,tests}/**/*.{js,mjs,ts,mts,jsx,tsx}\" --shell src scripts tests",
"lintfix": "npm run prepare && node ./dist/bin/matrixai-lint.js --fix --domain eslint shell markdown --eslint \"{src,scripts,tests}/**/*.{js,mjs,ts,mts,jsx,tsx}\" --shell src scripts tests",
"lint-shell": "npm run prepare && node ./dist/bin/matrixai-lint.js --domain shell --shell src scripts tests",
"docs": "shx rm -rf ./docs && typedoc --gitRevision master --tsconfig ./tsconfig.build.json --out ./docs src",
"test": "node ./scripts/test.mjs"
},
Expand Down
15 changes: 12 additions & 3 deletions scripts/test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import os from 'node:os';
import path from 'node:path';
import url from 'node:url';
import process from 'node:process';
import fs from 'node:fs';
import childProcess from 'node:child_process';

const projectPath = path.dirname(
Expand Down Expand Up @@ -40,9 +41,17 @@ async function main(argv = process.argv) {
}
/* eslint-enable no-console */

if (import.meta.url.startsWith('file:')) {
const modulePath = url.fileURLToPath(import.meta.url);
if (process.argv[1] === modulePath) {
if (import.meta.url.startsWith('file:') && process.argv[1] != null) {
const entryPath = process.argv[1];
let entryUrl;
try {
entryUrl = entryPath.startsWith('file:')
? new URL(entryPath).href
: url.pathToFileURL(fs.realpathSync.native(entryPath)).href;
} catch {
entryUrl = url.pathToFileURL(path.resolve(entryPath)).href;
}
if (entryUrl === new URL(import.meta.url).href) {
void main();
}
}
14 changes: 11 additions & 3 deletions src/bin/lint.ts → src/bin/matrixai-lint.ts
Original file line number Diff line number Diff line change
Expand Up @@ -234,9 +234,17 @@ async function main(argv = process.argv) {
}
}

if (import.meta.url.startsWith('file:')) {
const modulePath = url.fileURLToPath(import.meta.url);
if (process.argv[1] === modulePath) {
if (import.meta.url.startsWith('file:') && process.argv[1] != null) {
const entryPath = process.argv[1];
let entryUrl: string;
try {
entryUrl = entryPath.startsWith('file:')
? new URL(entryPath).href
: url.pathToFileURL(fs.realpathSync.native(entryPath)).href;
} catch {
entryUrl = url.pathToFileURL(path.resolve(entryPath)).href;
}
if (entryUrl === new URL(import.meta.url).href) {
void main();
}
}
Expand Down
2 changes: 1 addition & 1 deletion tests/bin/lint.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import path from 'node:path';
import fs from 'node:fs';
import childProcess from 'node:child_process';
import { jest } from '@jest/globals';
import main from '#bin/lint.js';
import main from '#bin/matrixai-lint.js';

describe('matrixai-lint CLI domain semantics', () => {
let capturedExecCalls: Array<{
Expand Down
Loading