@travetto/lint 8.0.0-alpha.26 → 8.0.0-alpha.28
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +65 -38
- package/__index__.ts +2 -2
- package/package.json +8 -5
- package/resources/cspell-node-modules.js +32 -0
- package/resources/cspell.json +45 -0
- package/support/{cli.lint.ts → cli.lint_check.ts} +8 -14
- package/support/cli.lint_format.ts +54 -0
- package/support/cli.lint_register.ts +50 -16
- package/support/cli.lint_spell.ts +50 -0
- package/support/oxfmt.ts +57 -0
- package/support/oxlint.ts +76 -0
- package/resources/biome.json +0 -146
package/README.md
CHANGED
|
@@ -13,7 +13,7 @@ npm install @travetto/lint
|
|
|
13
13
|
yarn add @travetto/lint
|
|
14
14
|
```
|
|
15
15
|
|
|
16
|
-
[
|
|
16
|
+
[Oxlint](https://oxc.rs/docs/guide/usage/linter.html), [Oxfmt](https://oxc.rs/docs/guide/usage/formatter.html), and [CSpell](https://cspell.org) are the tools used for linting, formatting, and spell checking in [Typescript](https://typescriptlang.org) and [Javascript](https://developer.mozilla.org/en-US/docs/Web/JavaScript) code. This module provides a unified CLI interface and standard linting, formatting, and spell checking configurations. In a new project, the first thing that will need to be done, post installation, is to register the configuration files.
|
|
17
17
|
|
|
18
18
|
## CLI - lint:register
|
|
19
19
|
|
|
@@ -24,64 +24,91 @@ $ trv lint:register --help
|
|
|
24
24
|
Usage: lint:register [options]
|
|
25
25
|
|
|
26
26
|
Description:
|
|
27
|
-
Generate the workspace
|
|
27
|
+
Generate the workspace oxlint, oxfmt, and cspell configuration entry files.
|
|
28
28
|
|
|
29
|
-
This bootstraps `
|
|
29
|
+
This bootstraps `oxlint.config.ts`, `oxfmt.config.ts`, and `cspell.json` to extend the framework-provided rules and formatting configuration.
|
|
30
30
|
|
|
31
31
|
Options:
|
|
32
32
|
--help display help for command
|
|
33
33
|
```
|
|
34
34
|
|
|
35
|
-
When registration completes, this
|
|
36
|
-
|
|
37
|
-
**Code: Sample configuration**
|
|
38
|
-
```json
|
|
39
|
-
{
|
|
40
|
-
"$schema": "https://biomejs.dev/schemas/2.5.4/schema.json",
|
|
41
|
-
"extends": ["./node_modules/@travetto/lint/resources/biome.jsonc"],
|
|
42
|
-
"files": {
|
|
43
|
-
"includes": [
|
|
44
|
-
"!**/out",
|
|
45
|
-
"!**/ui",
|
|
46
|
-
"!**/api-client",
|
|
47
|
-
"!**/*.d.ts",
|
|
48
|
-
"!**/fixtures",
|
|
49
|
-
"!**/resources",
|
|
50
|
-
"!**/DOC.html",
|
|
51
|
-
"!**/README.md",
|
|
52
|
-
"!**/.vscode",
|
|
53
|
-
"!archived",
|
|
54
|
-
"!related/travetto.github.io"
|
|
55
|
-
]
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
```
|
|
35
|
+
When registration completes, this bootstraps the configuration files the linter, formatter, and spell checker will use, as well as editor tooling (e.g. IDEs).
|
|
59
36
|
|
|
60
|
-
## CLI - lint
|
|
61
|
-
|
|
37
|
+
## CLI - lint:check
|
|
38
|
+
Linting is performed via the check command:
|
|
62
39
|
|
|
63
40
|
**Terminal: Running the Linter**
|
|
64
41
|
```bash
|
|
65
|
-
npx trv lint
|
|
42
|
+
npx trv lint:check
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
**Terminal: Help for lint:check**
|
|
46
|
+
```bash
|
|
47
|
+
$ trv lint:check --help
|
|
48
|
+
|
|
49
|
+
Usage: lint:check [options]
|
|
50
|
+
|
|
51
|
+
Description:
|
|
52
|
+
Run oxlint linter for the workspace or changed files.
|
|
53
|
+
|
|
54
|
+
Supports incremental mode (`changed`/`since`) and forwards fix
|
|
55
|
+
options to the underlying oxlint invocation.
|
|
56
|
+
|
|
57
|
+
Options:
|
|
58
|
+
-c, --changed Only check changed modules (default: false)
|
|
59
|
+
-s, --since <string> Since a specific git commit
|
|
60
|
+
-f, --fix Should we attempt to auto-fix lint errors? (default: false)
|
|
61
|
+
--help display help for command
|
|
66
62
|
```
|
|
67
63
|
|
|
68
|
-
|
|
64
|
+
## CLI - lint:format
|
|
65
|
+
Formatting is performed via the format command:
|
|
66
|
+
|
|
67
|
+
**Terminal: Running the Formatter**
|
|
68
|
+
```bash
|
|
69
|
+
npx trv lint:format
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
**Terminal: Help for lint:format**
|
|
73
|
+
```bash
|
|
74
|
+
$ trv lint:format --help
|
|
75
|
+
|
|
76
|
+
Usage: lint:format [options]
|
|
77
|
+
|
|
78
|
+
Description:
|
|
79
|
+
Run oxfmt formatter for the workspace or changed files.
|
|
80
|
+
|
|
81
|
+
Formats files in place by default. Use `--check` for read-only verification.
|
|
82
|
+
|
|
83
|
+
Options:
|
|
84
|
+
--changed Only format changed modules (default: false)
|
|
85
|
+
-s, --since <string> Since a specific git commit
|
|
86
|
+
-c, --check Report formatting violations without writing changes (default: false)
|
|
87
|
+
--help display help for command
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
## CLI - lint:spell
|
|
91
|
+
Spell checking is performed via the spell command:
|
|
92
|
+
|
|
93
|
+
**Terminal: Running the Spell Checker**
|
|
94
|
+
```bash
|
|
95
|
+
npx trv lint:spell
|
|
96
|
+
```
|
|
69
97
|
|
|
70
|
-
**Terminal: Help for lint**
|
|
98
|
+
**Terminal: Help for lint:spell**
|
|
71
99
|
```bash
|
|
72
|
-
$ trv lint --help
|
|
100
|
+
$ trv lint:spell --help
|
|
73
101
|
|
|
74
|
-
Usage: lint [options]
|
|
102
|
+
Usage: lint:spell [options]
|
|
75
103
|
|
|
76
104
|
Description:
|
|
77
|
-
Run
|
|
105
|
+
Run cspell spell checker for the workspace or changed files.
|
|
78
106
|
|
|
79
|
-
Supports incremental mode (`changed`/`since`) and forwards
|
|
80
|
-
|
|
107
|
+
Supports incremental mode (`changed`/`since`) and forwards options
|
|
108
|
+
to the underlying cspell invocation.
|
|
81
109
|
|
|
82
110
|
Options:
|
|
83
111
|
-c, --changed Only check changed modules (default: false)
|
|
84
112
|
-s, --since <string> Since a specific git commit
|
|
85
|
-
-f, --fix Should we attempt to fix/write formatting changes?
|
|
86
113
|
--help display help for command
|
|
87
114
|
```
|
package/__index__.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
export
|
|
1
|
+
export * from './support/oxlint.ts';
|
|
2
|
+
export * from './support/oxfmt.ts';
|
package/package.json
CHANGED
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@travetto/lint",
|
|
3
|
-
"version": "8.0.0-alpha.
|
|
3
|
+
"version": "8.0.0-alpha.28",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Linting and Formatting integration for Travetto",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"lint",
|
|
8
8
|
"travetto",
|
|
9
9
|
"typescript",
|
|
10
|
-
"
|
|
10
|
+
"oxlint",
|
|
11
|
+
"oxfmt",
|
|
12
|
+
"cspell"
|
|
11
13
|
],
|
|
12
14
|
"homepage": "https://travetto.io",
|
|
13
15
|
"license": "MIT",
|
|
@@ -26,11 +28,12 @@
|
|
|
26
28
|
"directory": "module/lint"
|
|
27
29
|
},
|
|
28
30
|
"dependencies": {
|
|
29
|
-
"@travetto/runtime": "^8.0.0-alpha.
|
|
30
|
-
"
|
|
31
|
+
"@travetto/runtime": "^8.0.0-alpha.23",
|
|
32
|
+
"oxlint": "^1.79.0",
|
|
33
|
+
"oxfmt": "^0.64.0"
|
|
31
34
|
},
|
|
32
35
|
"peerDependencies": {
|
|
33
|
-
"@travetto/cli": "^8.0.0-alpha.
|
|
36
|
+
"@travetto/cli": "^8.0.0-alpha.32"
|
|
34
37
|
},
|
|
35
38
|
"peerDependenciesMeta": {
|
|
36
39
|
"@travetto/cli": {
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import fs from 'node:fs';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Scans for installed node modules from package lock files or package.json.
|
|
5
|
+
*
|
|
6
|
+
* @returns An array of module names and package identifiers.
|
|
7
|
+
*/
|
|
8
|
+
function findInstalledNodeModules() {
|
|
9
|
+
for (const file of [
|
|
10
|
+
'package-lock.json',
|
|
11
|
+
'yarn.lock',
|
|
12
|
+
'pnpm-lock.yaml',
|
|
13
|
+
'package.json',
|
|
14
|
+
]) {
|
|
15
|
+
if (fs.existsSync(file)) {
|
|
16
|
+
const text = fs.readFileSync(file, 'utf8');
|
|
17
|
+
const found = text.matchAll(/[a-z][a-z\-_0-9]+/gi);
|
|
18
|
+
return [...new Set([...found].map(match => match[0]))];
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
return [];
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export default {
|
|
25
|
+
dictionaryDefinitions: [
|
|
26
|
+
{
|
|
27
|
+
name: 'installed-node-modules',
|
|
28
|
+
words: findInstalledNodeModules()
|
|
29
|
+
}
|
|
30
|
+
],
|
|
31
|
+
dictionaries: ['installed-node-modules']
|
|
32
|
+
};
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": "0.2",
|
|
3
|
+
"ignorePaths": [
|
|
4
|
+
"*.svg"
|
|
5
|
+
],
|
|
6
|
+
"useGitignore": true,
|
|
7
|
+
"import": [
|
|
8
|
+
"./cspell-node-modules.js"
|
|
9
|
+
],
|
|
10
|
+
"dictionaryDefinitions": [],
|
|
11
|
+
"dictionaries": [],
|
|
12
|
+
"words": [
|
|
13
|
+
"Appender",
|
|
14
|
+
"bgcolor",
|
|
15
|
+
"COLORFGBG",
|
|
16
|
+
"COLORTERM",
|
|
17
|
+
"cullable",
|
|
18
|
+
"httponly",
|
|
19
|
+
"maxlength",
|
|
20
|
+
"millis",
|
|
21
|
+
"pageable",
|
|
22
|
+
"premajor",
|
|
23
|
+
"preminor",
|
|
24
|
+
"prepatch",
|
|
25
|
+
"reinit",
|
|
26
|
+
"SIGUSR2",
|
|
27
|
+
"subsubtitle",
|
|
28
|
+
"workpool",
|
|
29
|
+
"xunit"
|
|
30
|
+
],
|
|
31
|
+
"ignoreRandomStrings": true,
|
|
32
|
+
"ignoreWords": [],
|
|
33
|
+
"ignoreRegExpList": [
|
|
34
|
+
"/(dockerImage|image)\\s*[:=]\\s*.*/",
|
|
35
|
+
"Δ",
|
|
36
|
+
"Ⲑ",
|
|
37
|
+
"jsx",
|
|
38
|
+
"/^(import|export)\\s*.*/",
|
|
39
|
+
"/import[(][^)]+[)]/",
|
|
40
|
+
"/[&]\\w+;/",
|
|
41
|
+
"/\\^[^$]+?[$]/",
|
|
42
|
+
"/\\b([a-z0-9]+(-[a-z0-9]+)*\\.)+[a-z]{2,}\\b/gi"
|
|
43
|
+
],
|
|
44
|
+
"enabled": true
|
|
45
|
+
}
|
|
@@ -4,21 +4,21 @@ import { CliCommand, type CliCommandShape, CliModuleUtil, CliParseUtil } from '@
|
|
|
4
4
|
import { Env, ExecUtil, Runtime } from '@travetto/runtime';
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
|
-
* Run
|
|
7
|
+
* Run oxlint linter for the workspace or changed files.
|
|
8
8
|
*
|
|
9
|
-
* Supports incremental mode (`changed`/`since`) and forwards
|
|
10
|
-
* options to the underlying
|
|
9
|
+
* Supports incremental mode (`changed`/`since`) and forwards fix
|
|
10
|
+
* options to the underlying oxlint invocation.
|
|
11
11
|
*/
|
|
12
12
|
@CliCommand()
|
|
13
|
-
export class
|
|
13
|
+
export class LintCheckCommand implements CliCommandShape {
|
|
14
14
|
/** Only check changed modules */
|
|
15
15
|
changed = false;
|
|
16
16
|
|
|
17
17
|
/** Since a specific git commit */
|
|
18
18
|
since?: string;
|
|
19
19
|
|
|
20
|
-
/** Should we attempt to fix
|
|
21
|
-
fix
|
|
20
|
+
/** Should we attempt to auto-fix lint errors? */
|
|
21
|
+
fix = false;
|
|
22
22
|
|
|
23
23
|
finalize(): void {
|
|
24
24
|
Env.DEBUG.set(false);
|
|
@@ -28,7 +28,7 @@ export class LintCommand implements CliCommandShape {
|
|
|
28
28
|
const paths = await CliModuleUtil.findChangedPaths({ changed: this.changed, since: this.since, logError: true });
|
|
29
29
|
|
|
30
30
|
if ((this.changed || this.since) && paths.length === 0) {
|
|
31
|
-
console.log('No changed files found to
|
|
31
|
+
console.log('No changed files found to check.');
|
|
32
32
|
return;
|
|
33
33
|
}
|
|
34
34
|
|
|
@@ -36,13 +36,7 @@ export class LintCommand implements CliCommandShape {
|
|
|
36
36
|
const result = await ExecUtil.getResult(
|
|
37
37
|
spawn(
|
|
38
38
|
process.argv0,
|
|
39
|
-
[
|
|
40
|
-
Runtime.workspaceRelative('node_modules', '.bin', 'biome'),
|
|
41
|
-
'check',
|
|
42
|
-
...(this.fix ? ['--write'] : []),
|
|
43
|
-
...paths,
|
|
44
|
-
...(state?.unknown ?? [])
|
|
45
|
-
],
|
|
39
|
+
[Runtime.workspaceRelative('node_modules', '.bin', 'oxlint'), ...(this.fix ? ['--fix'] : []), ...paths, ...(state?.unknown ?? [])],
|
|
46
40
|
{
|
|
47
41
|
stdio: 'inherit'
|
|
48
42
|
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { spawn } from 'node:child_process';
|
|
2
|
+
|
|
3
|
+
import { CliCommand, type CliCommandShape, CliFlag, CliModuleUtil, CliParseUtil } from '@travetto/cli';
|
|
4
|
+
import { Env, ExecUtil, Runtime } from '@travetto/runtime';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Run oxfmt formatter for the workspace or changed files.
|
|
8
|
+
*
|
|
9
|
+
* Formats files in place by default. Use `--check` for read-only verification.
|
|
10
|
+
*/
|
|
11
|
+
@CliCommand()
|
|
12
|
+
export class LintFormatCommand implements CliCommandShape {
|
|
13
|
+
/** Only format changed modules */
|
|
14
|
+
changed = false;
|
|
15
|
+
|
|
16
|
+
/** Since a specific git commit */
|
|
17
|
+
since?: string;
|
|
18
|
+
|
|
19
|
+
/** Report formatting violations without writing changes */
|
|
20
|
+
@CliFlag({ short: 'c' })
|
|
21
|
+
check = false;
|
|
22
|
+
|
|
23
|
+
finalize(): void {
|
|
24
|
+
Env.DEBUG.set(false);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
async main(): Promise<void> {
|
|
28
|
+
const paths = await CliModuleUtil.findChangedPaths({ changed: this.changed, since: this.since, logError: true });
|
|
29
|
+
|
|
30
|
+
if ((this.changed || this.since) && paths.length === 0) {
|
|
31
|
+
console.log('No changed files found to format.');
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
const state = CliParseUtil.getState(this);
|
|
36
|
+
const result = await ExecUtil.getResult(
|
|
37
|
+
spawn(
|
|
38
|
+
process.argv0,
|
|
39
|
+
[
|
|
40
|
+
Runtime.workspaceRelative('node_modules', '.bin', 'oxfmt'),
|
|
41
|
+
...(this.check ? ['--check'] : ['--write']),
|
|
42
|
+
...paths,
|
|
43
|
+
...(state?.unknown ?? [])
|
|
44
|
+
],
|
|
45
|
+
{
|
|
46
|
+
stdio: 'inherit'
|
|
47
|
+
}
|
|
48
|
+
),
|
|
49
|
+
{ catch: true }
|
|
50
|
+
);
|
|
51
|
+
|
|
52
|
+
process.exitCode = result.code;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
@@ -1,28 +1,62 @@
|
|
|
1
|
-
import fs from
|
|
1
|
+
import fs from "node:fs/promises";
|
|
2
2
|
|
|
3
|
-
import { CliCommand, type CliCommandShape } from
|
|
4
|
-
import {
|
|
3
|
+
import { CliCommand, type CliCommandShape } from "@travetto/cli";
|
|
4
|
+
import { Runtime, RuntimeIndex } from "@travetto/runtime";
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
|
-
* Generate the workspace
|
|
7
|
+
* Generate the workspace oxlint, oxfmt, and cspell configuration entry files.
|
|
8
8
|
*
|
|
9
|
-
* This bootstraps `
|
|
9
|
+
* This bootstraps `oxlint.config.ts`, `oxfmt.config.ts`, and `cspell.json` to extend the framework-provided rules and formatting configuration.
|
|
10
10
|
*/
|
|
11
11
|
@CliCommand({})
|
|
12
12
|
export class LintRegisterCommand implements CliCommandShape {
|
|
13
13
|
async main(): Promise<void> {
|
|
14
|
-
const
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
14
|
+
const PREAMBLE = `process.env.TRV_MANIFEST= '${Runtime.stripWorkspacePath(Runtime.workspaceRelative(RuntimeIndex.outputRoot, "node_modules", Runtime.workspace.name))}';`;
|
|
15
|
+
|
|
16
|
+
// Bootstrap oxlint configuration
|
|
17
|
+
const oxlintOutput = Runtime.workspaceRelative("oxlint.config.js");
|
|
18
|
+
if (!(await fs.stat(oxlintOutput, { throwIfNoEntry: false }))) {
|
|
19
|
+
const entry = RuntimeIndex.getFromImport("@travetto/lint/support/oxlint");
|
|
20
|
+
const content = `${PREAMBLE}
|
|
21
|
+
const { oxlintConfig } = await import('${Runtime.stripWorkspacePath(entry!.outputFile)}');
|
|
22
|
+
export default oxlintConfig();
|
|
23
|
+
`;
|
|
24
|
+
await fs.writeFile(oxlintOutput, content);
|
|
25
|
+
console.log(`Wrote lint config to ${oxlintOutput}`);
|
|
26
|
+
} else {
|
|
27
|
+
console.log(`Lint config already present ${oxlintOutput}`);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
// Bootstrap oxfmt configuration
|
|
31
|
+
const oxfmtOutput = Runtime.workspaceRelative("oxfmt.config.js");
|
|
32
|
+
if (!(await fs.stat(oxfmtOutput, { throwIfNoEntry: false }))) {
|
|
33
|
+
const entry = RuntimeIndex.getFromImport("@travetto/lint/support/oxfmt");
|
|
34
|
+
const content = `${PREAMBLE}
|
|
35
|
+
const { oxfmtConfig } = await import('${Runtime.stripWorkspacePath(entry!.outputFile)}');
|
|
36
|
+
export default oxfmtConfig();
|
|
37
|
+
`;
|
|
38
|
+
|
|
39
|
+
await fs.writeFile(oxfmtOutput, content);
|
|
40
|
+
console.log(`Wrote format config to ${oxfmtOutput}`);
|
|
41
|
+
} else {
|
|
42
|
+
console.log(`Format config already present ${oxfmtOutput}`);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
// Bootstrap cspell configuration
|
|
46
|
+
const cspellOutput = Runtime.workspaceRelative("cspell.json");
|
|
47
|
+
if (!(await fs.stat(cspellOutput, { throwIfNoEntry: false }))) {
|
|
48
|
+
const cspellContent =
|
|
49
|
+
JSON.stringify(
|
|
50
|
+
{
|
|
51
|
+
import: ["@travetto/lint/resources/cspell.json"],
|
|
52
|
+
},
|
|
53
|
+
null,
|
|
54
|
+
2,
|
|
55
|
+
) + "\n";
|
|
56
|
+
await fs.writeFile(cspellOutput, cspellContent);
|
|
57
|
+
console.log(`Wrote cspell config to ${cspellOutput}`);
|
|
24
58
|
} else {
|
|
25
|
-
console.log(`
|
|
59
|
+
console.log(`CSpell config already present ${cspellOutput}`);
|
|
26
60
|
}
|
|
27
61
|
}
|
|
28
62
|
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { spawn } from 'node:child_process';
|
|
2
|
+
|
|
3
|
+
import { CliCommand, type CliCommandShape, CliModuleUtil, CliParseUtil } from '@travetto/cli';
|
|
4
|
+
import { Env, ExecUtil } from '@travetto/runtime';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Run cspell spell checker for the workspace or changed files.
|
|
8
|
+
*
|
|
9
|
+
* Supports incremental mode (`changed`/`since`) and forwards options
|
|
10
|
+
* to the underlying cspell invocation.
|
|
11
|
+
*/
|
|
12
|
+
@CliCommand()
|
|
13
|
+
export class LintSpellCommand implements CliCommandShape {
|
|
14
|
+
/** Only check changed modules */
|
|
15
|
+
changed = false;
|
|
16
|
+
|
|
17
|
+
/** Since a specific git commit */
|
|
18
|
+
since?: string;
|
|
19
|
+
|
|
20
|
+
/** Output format as JSON */
|
|
21
|
+
json = false;
|
|
22
|
+
|
|
23
|
+
finalize(): void {
|
|
24
|
+
Env.DEBUG.set(false);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
async main(): Promise<void> {
|
|
28
|
+
const paths = await CliModuleUtil.findChangedPaths({ changed: this.changed, since: this.since, logError: true });
|
|
29
|
+
|
|
30
|
+
if ((this.changed || this.since) && paths.length === 0) {
|
|
31
|
+
if (!this.json) {
|
|
32
|
+
console.log('No changed files found to check.');
|
|
33
|
+
}
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
const reporterFlags = this.json ? ['--reporter', '@cspell/cspell-json-reporter'] : ['--no-progress', '--no-summary'];
|
|
38
|
+
|
|
39
|
+
const state = CliParseUtil.getState(this);
|
|
40
|
+
const targetPaths = paths.length > 0 ? paths : ['.'];
|
|
41
|
+
const result = await ExecUtil.getResult(
|
|
42
|
+
spawn('npx', ['cspell', 'lint', ...reporterFlags, ...targetPaths, ...(state?.unknown ?? [])], {
|
|
43
|
+
stdio: 'inherit'
|
|
44
|
+
}),
|
|
45
|
+
{ catch: true }
|
|
46
|
+
);
|
|
47
|
+
|
|
48
|
+
process.exitCode = result.code;
|
|
49
|
+
}
|
|
50
|
+
}
|
package/support/oxfmt.ts
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { defineConfig, type OxfmtConfig } from 'oxfmt';
|
|
2
|
+
|
|
3
|
+
export const baseOxfmtConfig: OxfmtConfig = {
|
|
4
|
+
useTabs: false,
|
|
5
|
+
tabWidth: 2,
|
|
6
|
+
printWidth: 140,
|
|
7
|
+
singleQuote: true,
|
|
8
|
+
jsxSingleQuote: false,
|
|
9
|
+
quoteProps: 'as-needed',
|
|
10
|
+
trailingComma: 'none',
|
|
11
|
+
semi: true,
|
|
12
|
+
arrowParens: 'avoid',
|
|
13
|
+
bracketSameLine: false,
|
|
14
|
+
bracketSpacing: true,
|
|
15
|
+
sortImports: {
|
|
16
|
+
newlinesBetween: true,
|
|
17
|
+
customGroups: [
|
|
18
|
+
{
|
|
19
|
+
groupName: 'travetto-package',
|
|
20
|
+
elementNamePattern: ['@travetto/*']
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
groupName: 'travetto-subpath',
|
|
24
|
+
elementNamePattern: ['@travetto/**/*.ts', '@travetto/**']
|
|
25
|
+
}
|
|
26
|
+
],
|
|
27
|
+
groups: ['builtin', 'external', 'travetto-package', 'travetto-subpath', ['parent', 'sibling', 'index']]
|
|
28
|
+
},
|
|
29
|
+
ignorePatterns: [
|
|
30
|
+
'**/node_modules/**',
|
|
31
|
+
'**/.trv/**',
|
|
32
|
+
'**/out/**',
|
|
33
|
+
'**/ui/**',
|
|
34
|
+
'**/api-client/**',
|
|
35
|
+
'**/*.d.ts',
|
|
36
|
+
'**/*.md',
|
|
37
|
+
'**/*.html',
|
|
38
|
+
'**/*.yml',
|
|
39
|
+
'**/*.yaml',
|
|
40
|
+
'**/package.json',
|
|
41
|
+
'**/package-lock.json',
|
|
42
|
+
'**/fixtures/**',
|
|
43
|
+
'**/resources/**',
|
|
44
|
+
'**/DOC.html',
|
|
45
|
+
'**/README.md',
|
|
46
|
+
'**/.vscode/**'
|
|
47
|
+
]
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
export function oxfmtConfig(overrides: Partial<OxfmtConfig> = {}): OxfmtConfig {
|
|
51
|
+
return defineConfig({
|
|
52
|
+
...baseOxfmtConfig,
|
|
53
|
+
...overrides,
|
|
54
|
+
ignorePatterns: [...(baseOxfmtConfig.ignorePatterns ?? []), ...(overrides.ignorePatterns ?? [])],
|
|
55
|
+
overrides: [...(baseOxfmtConfig.overrides ?? []), ...(overrides.overrides ?? [])]
|
|
56
|
+
});
|
|
57
|
+
}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { defineConfig, type OxlintConfig } from 'oxlint';
|
|
2
|
+
|
|
3
|
+
export const baseOxlintConfig: OxlintConfig = {
|
|
4
|
+
plugins: ['typescript', 'unicorn', 'oxc'],
|
|
5
|
+
categories: {
|
|
6
|
+
correctness: 'error'
|
|
7
|
+
},
|
|
8
|
+
rules: {
|
|
9
|
+
'no-var': 'error',
|
|
10
|
+
'prefer-const': [
|
|
11
|
+
'error',
|
|
12
|
+
{
|
|
13
|
+
destructuring: 'all',
|
|
14
|
+
ignoreReadBeforeAssign: true
|
|
15
|
+
}
|
|
16
|
+
],
|
|
17
|
+
'no-unused-vars': 'off',
|
|
18
|
+
'@typescript-eslint/no-unused-vars': 'off',
|
|
19
|
+
'@typescript-eslint/consistent-type-imports': [
|
|
20
|
+
'error',
|
|
21
|
+
{
|
|
22
|
+
prefer: 'type-imports',
|
|
23
|
+
fixStyle: 'inline-type-imports'
|
|
24
|
+
}
|
|
25
|
+
],
|
|
26
|
+
'@typescript-eslint/no-non-null-assertion': 'off',
|
|
27
|
+
'@typescript-eslint/no-empty-interface': 'off',
|
|
28
|
+
'@typescript-eslint/no-empty-object-type': 'off',
|
|
29
|
+
'@typescript-eslint/ban-ts-comment': 'off',
|
|
30
|
+
'@typescript-eslint/no-explicit-any': 'off',
|
|
31
|
+
'@typescript-eslint/no-wrapper-object-types': 'off',
|
|
32
|
+
'no-cond-assign': 'off',
|
|
33
|
+
'no-unused-expressions': 'off',
|
|
34
|
+
'no-unused-private-class-members': 'off',
|
|
35
|
+
'no-unassigned-vars': 'off',
|
|
36
|
+
'no-useless-escape': 'off',
|
|
37
|
+
'unicorn/no-useless-spread': 'off',
|
|
38
|
+
'unicorn/no-useless-fallback-in-spread': 'off',
|
|
39
|
+
'unicorn/prefer-string-starts-ends-with': 'off',
|
|
40
|
+
'unicorn/no-new-array': 'off'
|
|
41
|
+
},
|
|
42
|
+
overrides: [
|
|
43
|
+
{
|
|
44
|
+
files: ['**/test/**', '**/support/test/**', '**/doc/**', '**/global-test/**', '**/DOC.tsx'],
|
|
45
|
+
rules: {
|
|
46
|
+
'prefer-const': 'off'
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
],
|
|
50
|
+
ignorePatterns: [
|
|
51
|
+
'**/node_modules/**',
|
|
52
|
+
'**/.trv/**',
|
|
53
|
+
'**/out/**',
|
|
54
|
+
'**/ui/**',
|
|
55
|
+
'**/api-client/**',
|
|
56
|
+
'**/*.d.ts',
|
|
57
|
+
'**/fixtures/**',
|
|
58
|
+
'**/resources/**',
|
|
59
|
+
'**/DOC.html',
|
|
60
|
+
'**/README.md',
|
|
61
|
+
'**/.vscode/**'
|
|
62
|
+
]
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
export function oxlintConfig(overrides: Partial<OxlintConfig> = {}): OxlintConfig {
|
|
66
|
+
return defineConfig({
|
|
67
|
+
...baseOxlintConfig,
|
|
68
|
+
...overrides,
|
|
69
|
+
rules: {
|
|
70
|
+
...baseOxlintConfig.rules,
|
|
71
|
+
...overrides.rules
|
|
72
|
+
},
|
|
73
|
+
ignorePatterns: [...(baseOxlintConfig.ignorePatterns ?? []), ...(overrides.ignorePatterns ?? [])],
|
|
74
|
+
overrides: [...(baseOxlintConfig.overrides ?? []), ...(overrides.overrides ?? [])]
|
|
75
|
+
});
|
|
76
|
+
}
|
package/resources/biome.json
DELETED
|
@@ -1,146 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"root": false,
|
|
3
|
-
"$schema": "https://biomejs.dev/schemas/2.5.8/schema.json",
|
|
4
|
-
"vcs": {
|
|
5
|
-
"enabled": true,
|
|
6
|
-
"clientKind": "git",
|
|
7
|
-
"useIgnoreFile": true
|
|
8
|
-
},
|
|
9
|
-
"files": {
|
|
10
|
-
"ignoreUnknown": true,
|
|
11
|
-
"includes": [
|
|
12
|
-
"**",
|
|
13
|
-
"!**/*.d.ts",
|
|
14
|
-
"!**/fixtures",
|
|
15
|
-
"!**/resources",
|
|
16
|
-
"!**/DOC.html",
|
|
17
|
-
"!**/.vscode"
|
|
18
|
-
]
|
|
19
|
-
},
|
|
20
|
-
"formatter": {
|
|
21
|
-
"enabled": true,
|
|
22
|
-
"formatWithErrors": false,
|
|
23
|
-
"indentStyle": "space",
|
|
24
|
-
"indentWidth": 2,
|
|
25
|
-
"lineWidth": 140
|
|
26
|
-
},
|
|
27
|
-
"assist": {
|
|
28
|
-
"actions": {
|
|
29
|
-
"source": {
|
|
30
|
-
"organizeImports": {
|
|
31
|
-
"level": "on",
|
|
32
|
-
"options": {
|
|
33
|
-
"groups": [
|
|
34
|
-
[
|
|
35
|
-
":NODE:",
|
|
36
|
-
":BUN:"
|
|
37
|
-
],
|
|
38
|
-
":BLANK_LINE:",
|
|
39
|
-
[
|
|
40
|
-
":PACKAGE:",
|
|
41
|
-
"!@travetto/**"
|
|
42
|
-
],
|
|
43
|
-
":BLANK_LINE:",
|
|
44
|
-
"@travetto/*",
|
|
45
|
-
":BLANK_LINE:",
|
|
46
|
-
"@travetto/**/*.ts",
|
|
47
|
-
":BLANK_LINE:",
|
|
48
|
-
[
|
|
49
|
-
":ALIAS:",
|
|
50
|
-
":PATH:"
|
|
51
|
-
]
|
|
52
|
-
]
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
},
|
|
58
|
-
"linter": {
|
|
59
|
-
"enabled": true,
|
|
60
|
-
"rules": {
|
|
61
|
-
"preset": "recommended",
|
|
62
|
-
"style": {
|
|
63
|
-
"useImportType": "error",
|
|
64
|
-
"noNonNullAssertion": "off",
|
|
65
|
-
"useConst": "error"
|
|
66
|
-
},
|
|
67
|
-
"correctness": {
|
|
68
|
-
"noUnusedFunctionParameters": "off",
|
|
69
|
-
"noUnusedPrivateClassMembers": "off",
|
|
70
|
-
"noUnusedVariables": {
|
|
71
|
-
"level": "on",
|
|
72
|
-
"options": {
|
|
73
|
-
"ignore": {
|
|
74
|
-
"class": [
|
|
75
|
-
"*"
|
|
76
|
-
],
|
|
77
|
-
"typeParameter": [
|
|
78
|
-
"*"
|
|
79
|
-
]
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
},
|
|
84
|
-
"complexity": {
|
|
85
|
-
"noUselessSwitchCase": "off",
|
|
86
|
-
"useArrowFunction": "off",
|
|
87
|
-
"noStaticOnlyClass": "off",
|
|
88
|
-
"noThisInStatic": "off",
|
|
89
|
-
"noBannedTypes": "off"
|
|
90
|
-
},
|
|
91
|
-
"suspicious": {
|
|
92
|
-
"noVar": "error",
|
|
93
|
-
"noTsIgnore": "off",
|
|
94
|
-
"noConfusingVoidType": "off",
|
|
95
|
-
"noEmptyInterface": "off",
|
|
96
|
-
"noAssignInExpressions": "off"
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
},
|
|
100
|
-
"javascript": {
|
|
101
|
-
"formatter": {
|
|
102
|
-
"quoteStyle": "single",
|
|
103
|
-
"semicolons": "always",
|
|
104
|
-
"arrowParentheses": "asNeeded",
|
|
105
|
-
"trailingCommas": "none"
|
|
106
|
-
},
|
|
107
|
-
"parser": {
|
|
108
|
-
"unsafeParameterDecoratorsEnabled": true
|
|
109
|
-
}
|
|
110
|
-
},
|
|
111
|
-
"json": {
|
|
112
|
-
"formatter": {
|
|
113
|
-
"lineWidth": 80
|
|
114
|
-
}
|
|
115
|
-
},
|
|
116
|
-
"overrides": [
|
|
117
|
-
{
|
|
118
|
-
"includes": [
|
|
119
|
-
"**/test/**",
|
|
120
|
-
"**/support/test/**",
|
|
121
|
-
"**/doc/**",
|
|
122
|
-
"!module/test/src/**"
|
|
123
|
-
],
|
|
124
|
-
"linter": {
|
|
125
|
-
"rules": {
|
|
126
|
-
"complexity": {
|
|
127
|
-
"noUselessConstructor": "off"
|
|
128
|
-
},
|
|
129
|
-
"correctness": {
|
|
130
|
-
"noUnusedVariables": "off",
|
|
131
|
-
"noUnusedFunctionParameters": "off"
|
|
132
|
-
},
|
|
133
|
-
"security": {
|
|
134
|
-
"noBlankTarget": "off"
|
|
135
|
-
},
|
|
136
|
-
"style": {
|
|
137
|
-
"useConst": "off"
|
|
138
|
-
},
|
|
139
|
-
"suspicious": {
|
|
140
|
-
"noSelfCompare": "off"
|
|
141
|
-
}
|
|
142
|
-
}
|
|
143
|
-
}
|
|
144
|
-
}
|
|
145
|
-
]
|
|
146
|
-
}
|