Skip to content

Commit 7ffab8e

Browse files
committed
feat: making jslint use local prettier
1 parent 7a709f4 commit 7ffab8e

File tree

5 files changed

+202
-156
lines changed

5 files changed

+202
-156
lines changed

.prettierrc

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,13 @@
33
"trailingComma": "all",
44
"singleQuote": true,
55
"printWidth": 80,
6-
"tabWidth": 2
6+
"tabWidth": 2,
7+
"overrides": [
8+
{
9+
"files": ["*.md", "*.mdx"],
10+
"options": {
11+
"proseWrap": "always"
12+
}
13+
}
14+
]
715
}

README.md

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,16 @@
11
# js-lint
22

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

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

1216
## Installation
@@ -46,7 +50,8 @@ matrixai-lint --config ./eslint.config.js --fix
4650

4751
### TypeScript Support
4852

49-
The linter is TypeScript-aware and requires a `tsconfig.json` to determine which files to lint and how to parse them.
53+
The linter is TypeScript-aware and requires a `tsconfig.json` to determine which
54+
files to lint and how to parse them.
5055

5156
By default:
5257

@@ -55,7 +60,9 @@ By default:
5560

5661
### Working with multiple tsconfigs
5762

58-
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:
63+
If your project uses more than one `tsconfig.json` or doesn't have one at the
64+
root, you can configure the linter using a `matrixai-lint-config.json` file at
65+
the root:
5966

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

72-
> ⚠ If a path in `forceInclude` is not included in any of the `tsconfigPaths`, TypeScript will throw a parsing error.
79+
> ⚠ If a path in `forceInclude` is not included in any of the `tsconfigPaths`,
80+
> TypeScript will throw a parsing error.
7381
7482
### ESLint Config Override
7583

@@ -100,14 +108,14 @@ Valid config filenames:
100108

101109
```ts
102110
// eslint.config.js
103-
import matrixai from '@matrixai/lint/config';
111+
import matrixai from "@matrixai/lint/config";
104112

105113
export default [
106114
...matrixai,
107115
{
108116
rules: {
109-
'@typescript-eslint/no-explicit-any': 'error',
110-
'no-console': 'off',
117+
"@typescript-eslint/no-explicit-any": "error",
118+
"no-console": "off",
111119
},
112120
},
113121
];

src/bin/lint.ts

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,20 @@ import process from 'node:process';
66
import childProcess from 'node:child_process';
77
import fs from 'node:fs';
88
import { createRequire } from 'node:module';
9+
import url from 'node:url';
910
import { Command } from 'commander';
1011
import * as utils from '../utils.js';
1112

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

17+
const dirname = path.dirname(url.fileURLToPath(import.meta.url));
18+
const builtinPrettierCfg = path.resolve(
19+
dirname,
20+
'../configs/prettier.config.mjs',
21+
);
22+
1623
program
1724
.name('matrixai-lint')
1825
.description(
@@ -139,7 +146,16 @@ async function main(argv = process.argv) {
139146
return;
140147
}
141148

142-
const prettierArgs = [fix ? '--write' : '--check', ...markdownFiles];
149+
const prettierArgs = [
150+
'--config',
151+
builtinPrettierCfg,
152+
'--config-precedence',
153+
'cli-override',
154+
'--no-editorconfig',
155+
fix ? '--write' : '--check',
156+
...markdownFiles,
157+
];
158+
143159
console.error('Running prettier:');
144160

145161
const require = createRequire(import.meta.url);

0 commit comments

Comments
 (0)