Skip to content

ci: merge staging to master #31

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
May 28, 2025
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
10 changes: 9 additions & 1 deletion .prettierrc
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,13 @@
"trailingComma": "all",
"singleQuote": true,
"printWidth": 80,
"tabWidth": 2
"tabWidth": 2,
"overrides": [
{
"files": ["*.md", "*.mdx"],
"options": {
"proseWrap": "always"
}
}
]
}
28 changes: 18 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
# js-lint

A batteries-included, TypeScript-aware linting CLI and ESLint flat config bundle for use in Matrix AI JavaScript/TypeScript projects.
A batteries-included, TypeScript-aware linting CLI and ESLint flat config bundle
for use in Matrix AI JavaScript/TypeScript projects.

- Type-aware linting powered by `@typescript-eslint` using one or more `tsconfig.json` files
- Built-in support for React, Tailwind, JSX a11y, Prettier, and Matrix AI custom rules
- Type-aware linting powered by `@typescript-eslint` using one or more
`tsconfig.json` files
- Built-in support for React, Tailwind, JSX a11y, Prettier, and Matrix AI custom
rules
- Supports Prettier formatting for Markdown and ShellCheck for shell scripts
- Single command to lint JavaScript/TypeScript, Markdown, and shell scripts
- Customizable via `matrixai-lint-config.json` and extensible with your own ESLint config
- Customizable via `matrixai-lint-config.json` and extensible with your own
ESLint config
- CLI options to override config and enable auto-fix

## Installation
Expand Down Expand Up @@ -46,7 +50,8 @@ 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.
The linter is TypeScript-aware and requires a `tsconfig.json` to determine which
files to lint and how to parse them.

By default:

Expand All @@ -55,7 +60,9 @@ By default:

### Working with multiple tsconfigs

If your project uses more than one `tsconfig.json` or doesn't have one at the root, you can configure the linter using a `matrixai-lint-config.json` file at the root:
If your project uses more than one `tsconfig.json` or doesn't have one at the
root, you can configure the linter using a `matrixai-lint-config.json` file at
the root:

```json
{
Expand All @@ -69,7 +76,8 @@ If your project uses more than one `tsconfig.json` or doesn't have one at the ro
| `tsconfigPaths` | `string[]` | One or more paths to `tsconfig.json` files |
| `forceInclude` | `string[]` | Paths to always include, even if excluded by tsconfig (must be included by at least one) |

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

### ESLint Config Override

Expand Down Expand Up @@ -100,14 +108,14 @@ Valid config filenames:

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

export default [
...matrixai,
{
rules: {
'@typescript-eslint/no-explicit-any': 'error',
'no-console': 'off',
"@typescript-eslint/no-explicit-any": "error",
"no-console": "off",
},
},
];
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

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

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@matrixai/lint",
"version": "0.2.8",
"version": "0.2.9",
"author": "Roger Qiu",
"description": "Org wide custom eslint rules",
"license": "Apache-2.0",
Expand Down
24 changes: 19 additions & 5 deletions src/bin/lint.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,20 @@ import process from 'node:process';
import childProcess from 'node:child_process';
import fs from 'node:fs';
import { createRequire } from 'node:module';
import url from 'node:url';
import { Command } from 'commander';
import * as utils from '../utils.js';

const platform = os.platform();
const program = new Command();
const DEFAULT_SHELLCHECK_SEARCH_ROOTS = ['./src', './scripts', './tests'];

const dirname = path.dirname(url.fileURLToPath(import.meta.url));
const builtinPrettierCfg = path.resolve(
dirname,
'../configs/prettier.config.mjs',
);

program
.name('matrixai-lint')
.description(
Expand Down Expand Up @@ -139,7 +146,16 @@ async function main(argv = process.argv) {
return;
}

const prettierArgs = [fix ? '--write' : '--check', ...markdownFiles];
const prettierArgs = [
'--config',
builtinPrettierCfg,
'--config-precedence',
'cli-override',
'--no-editorconfig',
fix ? '--write' : '--check',
...markdownFiles,
];

console.error('Running prettier:');

const require = createRequire(import.meta.url);
Expand All @@ -153,9 +169,7 @@ async function main(argv = process.argv) {

try {
if (prettierBin) {
console.error(
` ${process.execPath} ${prettierBin} ${prettierArgs.join(' ')}`,
);
console.error(` ${prettierBin} \n ${prettierArgs.join('\n' + ' ')}`);
childProcess.execFileSync(
process.execPath,
[prettierBin, ...prettierArgs],
Expand All @@ -167,7 +181,7 @@ async function main(argv = process.argv) {
},
);
} else {
console.error(' prettier ' + prettierArgs.join(' '));
console.error('prettier' + prettierArgs.join('\n' + ' '));
childProcess.execFileSync('prettier', prettierArgs, {
stdio: 'inherit',
windowsHide: true,
Expand Down
Loading
Loading