Skip to content

eng-557 build centralized linting system for all repos #10

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
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
56 commits
Select commit Hold shift + click to select a range
f6418cb
feat: initial commit
CDeltakai Mar 21, 2025
6b934a1
fix: deleted old index.js file
CDeltakai Mar 21, 2025
c8ecb57
fix: update @typescript-eslint dependencies to latest version
CDeltakai Mar 21, 2025
626a974
feat: update ESLint plugin structure and integrate with recommended c…
CDeltakai Mar 21, 2025
a482d69
feat: updated all packages in repo including linter and created a fla…
CDeltakai Mar 21, 2025
cbe4f51
fix: ran lint f
CDeltakai Mar 26, 2025
bd41999
fix: removed bench and test from package as they are unneeded
CDeltakai Mar 26, 2025
16c7e50
fix: changed the config bundle to be js instead of ts, removed the ex…
CDeltakai Mar 26, 2025
d25a039
fix: fixed import ordering
CDeltakai Mar 26, 2025
ed540cf
wip: replacing config bundle with config from zeta.house, removing pa…
CDeltakai Mar 27, 2025
ec8c017
fix: did a lintfix and removed unnecessary comments
CDeltakai Mar 27, 2025
d98df43
fix: did a lintfix
CDeltakai Mar 27, 2025
f385fa4
fix: fixed up formatting for eslint config
CDeltakai Mar 27, 2025
b39e15e
feat: adding generic test files and necessary packages
CDeltakai Mar 28, 2025
5fd8914
wip: fixing up ESM
tegefaulkes Mar 28, 2025
ae54301
fix: fixed issue with jest test not working correctly
CDeltakai Mar 28, 2025
99a7bc6
refactor: removed the recommendedTypeaware ruleset and instead merged…
CDeltakai Mar 28, 2025
3073893
fix: removed unused import
CDeltakai Mar 28, 2025
bd7cb3b
fix: deleted old .eslintrc file since it was no longer needed
CDeltakai Mar 28, 2025
3d2e8d1
feat: implementing lint script and an external eslint runner that can…
CDeltakai Apr 1, 2025
0cd35e5
wip: testing changes to fix issue with lint.ts not running correctly
CDeltakai Apr 1, 2025
97234e9
wip: managed to get command mostly working, ironing out the kinks
CDeltakai Apr 4, 2025
552430b
wip: adjusting parameters to test for tsconfig related issues
CDeltakai Apr 4, 2025
a0892c0
wip: commenting out the shellcheck and prettier commands for now sinc…
CDeltakai Apr 8, 2025
9a2570c
wip: made runESlint detect tsconfig files inside the target repo and …
CDeltakai Apr 8, 2025
a3b75e3
feat: implemented working shellcheck linting and prettier linting
CDeltakai Apr 10, 2025
b86bd67
fix: removed unnecessary comment
CDeltakai Apr 10, 2025
44fd174
fix: removed await from runESLint as that was preventing the other li…
CDeltakai Apr 11, 2025
e0f502c
fix: did lintfix and removed unnecessary elements
CDeltakai Apr 11, 2025
6e36135
feat: added user-config and config flags to allow users to adjust whi…
CDeltakai Apr 11, 2025
bc7b831
fix: did a lintfix
CDeltakai Apr 11, 2025
1e72c7d
feat: update README.md
CDeltakai Apr 11, 2025
a7a70f7
fix: removed exporting index.ts since it wasnt needed anymore. also r…
CDeltakai Apr 11, 2025
26ccb3b
fix: reintroduced eslint as a peer depedency for convenience if users…
CDeltakai Apr 11, 2025
50ee4e7
refactor: moved util functions into its own folder and file
CDeltakai Apr 11, 2025
6d9b61d
feat: add comments to util functions
CDeltakai Apr 11, 2025
651a900
wip: designing solution to dealing with multiple .tsconfigs and edge …
CDeltakai Apr 11, 2025
9391406
feat: update readme
CDeltakai Apr 13, 2025
f27da91
fix: removed unnecessary comments and unnecessary method
CDeltakai Apr 14, 2025
b79d983
refactor: removed recommended config since it was no longer needed
CDeltakai Apr 14, 2025
e8b67b0
renamed primary config to js.ts, lintfixed
CDeltakai Apr 14, 2025
3e48f84
refactor: moves buildpatterns and resolveMatrixConfig into a single u…
CDeltakai Apr 14, 2025
d89a1e7
fix: update readme to match jslogger style
CDeltakai Apr 14, 2025
42948eb
feat: changed package.json to just run the lint script on the repo it…
CDeltakai Apr 15, 2025
5760f21
feat: ran npm docs
CDeltakai Apr 15, 2025
2853f15
fix: various review fixes and clean up - removed unnecessary elements
CDeltakai Apr 15, 2025
80bf13b
fix: changed collectMarkdown to just use the recursive option, made h…
CDeltakai Apr 15, 2025
16c788b
fix: added type guard for raw matrix cfg when resolving matrix config,
CDeltakai Apr 15, 2025
f8d9631
fix: update imports to use node module syntax for consistency
CDeltakai Apr 15, 2025
f914431
feat: turned MatrixAILintConfig and RawMatrixCfg into their own types…
CDeltakai Apr 15, 2025
7ec3b3d
feat: fixed up some comments and added some more documentation
CDeltakai Apr 15, 2025
e8891d1
feat: ran docs
CDeltakai Apr 15, 2025
bcca02a
refactor: moved runESLint into utils.ts and removed runners and its c…
CDeltakai Apr 15, 2025
94ab584
refactor: moved utils and types into src instead of their own folder.…
CDeltakai Apr 15, 2025
c62d59a
fix: update condition for excluding patterns in buildPatterns function
CDeltakai Apr 15, 2025
1257b31
fix: changed package.json to build before running lint or lintfix in …
CDeltakai Apr 15, 2025
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
177 changes: 0 additions & 177 deletions .eslintrc

This file was deleted.

173 changes: 172 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,172 @@
# js-eslint
# js-lint

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
- 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
- CLI options to override config and enable auto-fix

## Installation

```sh
npm install --save-dev @matrixai/lint
```

## Usage

```sh
matrixai-lint
```

To run with autofix:

```sh
matrixai-lint --fix
```

### CLI Options

| 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 |
| `--config <path>` | Explicitly use a custom ESLint config file | | |

### Examples

```sh
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.

By default:

- It looks for `tsconfig.json` in the project root
- Files are selected based on the `include` and `exclude` fields in the tsconfig

### 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:

```json
{
"tsconfigPaths": ["./tsconfig.base.json", "./packages/core/tsconfig.json"],
"forceInclude": ["scripts", "src/overrides"]
}
```

| Field | Type | Description |
| --------------- | ---------- | ---------------------------------------------------------------------------------------- |
| `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.

## ESLint Config Override

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

### 1. Inline Custom Config

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

### 2. Auto-detect with `--user-config`

```sh
matrixai-lint --user-config
```

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

Valid config filenames:

- `eslint.config.js`
- `eslint.config.cjs`
- `eslint.config.mjs`
- `eslint.config.ts`

### 3. Extend the base config

```ts
// 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:

```sh
# 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
```

### Docs Generation

```sh
npm run docs
```

See the docs at: https://matrixai.github.io/js-lint/

### Publishing

Publishing is handled automatically by the staging pipeline.

Prerelease:

```sh
# npm login
npm version prepatch --preid alpha # premajor/preminor/prepatch
git push --follow-tags
```

Release:

```sh
# npm login
npm version patch # major/minor/patch
git push --follow-tags
```

Manually:

```sh
# npm login
npm version patch # major/minor/patch
npm run build
npm publish --access public
git push
git push --tags
```
1 change: 1 addition & 0 deletions docs/.nojekyll
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
TypeDoc added this file to prevent GitHub Pages from using Jekyll. You can turn off this behavior by setting the `githubPages` option to false.
Loading