@venizia/dev-configs 0.3.6 → 0.4.1
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/LICENSE.md +1 -1
- package/README.md +18 -36
- package/dist/cli/index.js +1 -1
- package/dist/cli/index.js.map +1 -1
- package/dist/cli/lint.d.ts +8 -4
- package/dist/cli/lint.d.ts.map +1 -1
- package/dist/cli/lint.js +43 -24
- package/dist/cli/lint.js.map +1 -1
- package/dist/compilers/bun.js +1 -1
- package/dist/compilers/bun.js.map +1 -1
- package/dist/index.d.ts +0 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +0 -1
- package/dist/index.js.map +1 -1
- package/dist/linters/eslint.d.ts +2 -2
- package/dist/linters/eslint.d.ts.map +1 -1
- package/dist/linters/eslint.js +2 -6
- package/dist/linters/eslint.js.map +1 -1
- package/dist/linters/house/const-class-values.rule.js +1 -1
- package/dist/linters/house/const-class-values.rule.js.map +1 -1
- package/dist/linters/house/max-params-own.rule.js +1 -1
- package/dist/linters/house/max-params-own.rule.js.map +1 -1
- package/dist/linters/house/no-leaked-render.rule.js +4 -4
- package/dist/linters/house/no-leaked-render.rule.js.map +1 -1
- package/dist/linters/house/no-new-error.rule.js +1 -1
- package/dist/linters/house/no-new-error.rule.js.map +1 -1
- package/dist/linters/ignore.js +3 -3
- package/dist/linters/ignore.js.map +1 -1
- package/package.json +26 -45
- package/dist/formatters/index.d.ts +0 -3
- package/dist/formatters/index.d.ts.map +0 -1
- package/dist/formatters/index.js +0 -19
- package/dist/formatters/index.js.map +0 -1
- package/dist/formatters/oxfmt.d.ts +0 -28
- package/dist/formatters/oxfmt.d.ts.map +0 -1
- package/dist/formatters/oxfmt.js +0 -42
- package/dist/formatters/oxfmt.js.map +0 -1
- package/dist/formatters/prettier.d.ts +0 -3
- package/dist/formatters/prettier.d.ts.map +0 -1
- package/dist/formatters/prettier.js +0 -13
- package/dist/formatters/prettier.js.map +0 -1
package/LICENSE.md
CHANGED
|
@@ -36,7 +36,7 @@ This monorepo contains the following packages, all licensed under MIT:
|
|
|
36
36
|
| `@venizia/ignis-boot` | Application bootstrapping & artifact auto-discovery |
|
|
37
37
|
| `@venizia/ignis-helpers` | Utility helpers - logging, cron, Redis, queues, storage |
|
|
38
38
|
| `@venizia/ignis-inversion` | Dependency Injection & IoC container |
|
|
39
|
-
| `@venizia/dev-configs` | Shared
|
|
39
|
+
| `@venizia/dev-configs` | Shared oxlint, ESLint, TypeScript configurations |
|
|
40
40
|
| `@venizia/ignis-docs` | Documentation and MCP Server |
|
|
41
41
|
|
|
42
42
|
---
|
package/README.md
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
# @venizia/dev-configs
|
|
2
2
|
|
|
3
|
-
The oxlint,
|
|
3
|
+
The oxlint, ESLint and TypeScript settings every IGNIS package is built with. Install
|
|
4
4
|
it as a dev dependency in an application that wants the same rules.
|
|
5
5
|
|
|
6
6
|
## Install
|
|
7
7
|
|
|
8
8
|
```bash
|
|
9
|
-
bun add -d @venizia/dev-configs oxlint oxlint-tsgolint
|
|
9
|
+
bun add -d @venizia/dev-configs oxlint oxlint-tsgolint eslint typescript
|
|
10
10
|
```
|
|
11
11
|
|
|
12
|
-
`oxlint` (>=1.88.0), `oxlint-tsgolint` (>=7.0.2004), `
|
|
13
|
-
`
|
|
12
|
+
`oxlint` (>=1.88.0), `oxlint-tsgolint` (>=7.0.2004), `eslint` (9 or 10),
|
|
13
|
+
`typescript` (5 or 6) are optional peers. Install only the tools you use. Formatting is `bun fmt` (Bun 1.4.4 or newer), set in `bunfig.toml`: see [Formatting](#formatting). Keep the
|
|
14
14
|
ESLint config `.mjs`: a TypeScript one (`.mts`) makes ESLint require `jiti`, one more dependency. A
|
|
15
|
-
project that
|
|
15
|
+
project that only wants the full ESLint preset installs `eslint` and skips the oxc tools.
|
|
16
16
|
|
|
17
17
|
## Use it
|
|
18
18
|
|
|
@@ -26,14 +26,6 @@ import { oxlintConfigs } from '@venizia/dev-configs/linters/oxlint';
|
|
|
26
26
|
export default defineConfig(oxlintConfigs);
|
|
27
27
|
```
|
|
28
28
|
|
|
29
|
-
```typescript
|
|
30
|
-
// .configs/formatters/oxfmt.config.mts
|
|
31
|
-
import { defineConfig } from 'oxfmt';
|
|
32
|
-
import { oxfmtConfigs } from '@venizia/dev-configs/formatters';
|
|
33
|
-
|
|
34
|
-
export default defineConfig(oxfmtConfigs);
|
|
35
|
-
```
|
|
36
|
-
|
|
37
29
|
```typescript
|
|
38
30
|
// .configs/lints/eslint.config.mjs - what oxlint cannot run: naming convention + house rules
|
|
39
31
|
import { houseConfigs } from '@venizia/dev-configs/linters';
|
|
@@ -44,7 +36,7 @@ export default houseConfigs;
|
|
|
44
36
|
```bash
|
|
45
37
|
oxlint -c .configs/lints/oxlint.config.mts --deny-warnings
|
|
46
38
|
eslint -c .configs/lints/eslint.config.mjs .
|
|
47
|
-
|
|
39
|
+
bun fmt --check "**/*.{ts,tsx,mts,js,mjs}"
|
|
48
40
|
```
|
|
49
41
|
|
|
50
42
|
`tsconfig.json` stays at the project root. Bun, the editor and oxlint's type-aware engine only find it
|
|
@@ -75,7 +67,6 @@ browser version. A React project swaps it for the React version, which builds on
|
|
|
75
67
|
| Tool | Backend | Browser | React |
|
|
76
68
|
| :--- | :--- | :--- | :--- |
|
|
77
69
|
| oxlint | `oxlintConfigs` | `BrowserOxlintConfigs.create()` | `ReactOxlintConfigs.create()` |
|
|
78
|
-
| oxfmt | `oxfmtConfigs` | `browserOxfmtConfigs` | `browserOxfmtConfigs` |
|
|
79
70
|
| ESLint | `houseConfigs` | `houseConfigs` | `reactHouseConfigs` |
|
|
80
71
|
| tsconfig | `tsconfig.common.json` | `tsconfig.browser.json` | `tsconfig.react.json` |
|
|
81
72
|
|
|
@@ -113,7 +104,6 @@ Every IGNIS package and example does.
|
|
|
113
104
|
| :--- | :--- |
|
|
114
105
|
| `@venizia/dev-configs` | Everything below, re-exported |
|
|
115
106
|
| `@venizia/dev-configs/compilers` | `BunCompiler` |
|
|
116
|
-
| `@venizia/dev-configs/formatters` | `oxfmtConfigs`, `browserOxfmtConfigs`, `prettierConfigs` |
|
|
117
107
|
| `@venizia/dev-configs/testing` | `rejectionOf`, `expectRejection` - test helpers for a promise that must reject (imports `bun:test`; tests only) |
|
|
118
108
|
| `@venizia/dev-configs/linters` | `oxlintConfigs`, `OxlintConfigs`, `BrowserOxlintConfigs`, `ReactOxlintConfigs`, `LintIgnore`, `namingConventionConfigs`, `reactNamingConventionConfigs`, `houseConfigs`, `reactHouseConfigs`, `eslintConfigs`, `ReactEslintConfigs`, the rule classes and their types |
|
|
119
109
|
| `@venizia/dev-configs/linters/oxlint` | `oxlintConfigs`, `OxlintConfigs`, `IOxlintPresetOptions`, `BrowserOxlintConfigs`, `ReactOxlintConfigs`, `LintIgnore`, the rule classes and their types: everything an oxlint config needs, and nothing that loads ESLint. Loads in milliseconds: `/linters` also loads ESLint and its plugins, which an oxlint config never uses |
|
|
@@ -231,33 +221,25 @@ export default defineConfig({
|
|
|
231
221
|
});
|
|
232
222
|
```
|
|
233
223
|
|
|
234
|
-
###
|
|
224
|
+
### Formatting
|
|
235
225
|
|
|
236
|
-
`
|
|
237
|
-
matches. oxfmt differs from Prettier on long union types, which it breaks with a leading `|` per line.
|
|
226
|
+
There is no formatter preset to import: `bun fmt` reads the `[fmt]` table of `bunfig.toml` in the folder it runs in or any parent, so one table at the repository root serves every package. The same table serves backend, browser and React code.
|
|
238
227
|
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
| `bracketSpacing` | `true` |
|
|
247
|
-
| `arrowParens` | `'avoid'` |
|
|
248
|
-
|
|
249
|
-
`browserOxfmtConfigs` is `oxfmtConfigs` with two changes for browser and React code:
|
|
228
|
+
```toml
|
|
229
|
+
[fmt]
|
|
230
|
+
printWidth = 100
|
|
231
|
+
singleQuote = true
|
|
232
|
+
arrowParens = "always"
|
|
233
|
+
flavor = "oxfmt"
|
|
234
|
+
```
|
|
250
235
|
|
|
251
|
-
|
|
252
|
-
| :--- | :--- | :--- |
|
|
253
|
-
| `arrowParens` | `'always'` | `(x) => x` instead of `x => x` |
|
|
254
|
-
| `bracketSameLine` | `true` | The closing `>` of a multi-line JSX element stays on its last attribute line, which keeps JSX diffs small |
|
|
236
|
+
`flavor = "oxfmt"` keeps the output IGNIS was formatted with; without it Bun formats in its default flavor, which puts the first member of a long union type on its own `|` line. Bun's defaults supply the rest: `tabWidth` 2, `trailingComma` `"all"`, `semi`, `bracketSpacing`. `devz lint` runs `bun fmt --no-script` and passes each pattern of `.configs/formatters/.ignore` as `--ignore-pattern`.
|
|
255
237
|
|
|
256
238
|
### eslintConfigs
|
|
257
239
|
|
|
258
240
|
`eslintConfigs` keeps its shape and resolves to the same rules as before, but is now owned here instead
|
|
259
|
-
of wrapping `@minimaltech/eslint-node`: ESLint recommended, typescript-eslint,
|
|
260
|
-
|
|
241
|
+
of wrapping `@minimaltech/eslint-node`: ESLint recommended, typescript-eslint, naming
|
|
242
|
+
conventions, `curly`, `eslint-plugin-n`, plus these IGNIS rules:
|
|
261
243
|
|
|
262
244
|
| Rule | Setting |
|
|
263
245
|
| :--- | :--- |
|
package/dist/cli/index.js
CHANGED
|
@@ -15,7 +15,7 @@ const main = async (opts) => {
|
|
|
15
15
|
console.error(`devz: unknown command "${command ?? ''}"\n${USAGE}`);
|
|
16
16
|
return 1;
|
|
17
17
|
};
|
|
18
|
-
main({ argv: process.argv.slice(2) }).then(exitCode => process.exit(exitCode), (error) => {
|
|
18
|
+
main({ argv: process.argv.slice(2) }).then((exitCode) => process.exit(exitCode), (error) => {
|
|
19
19
|
console.error(error);
|
|
20
20
|
process.exit(1);
|
|
21
21
|
});
|
package/dist/cli/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/cli/index.ts"],"names":[],"mappings":";;;AACA,mC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AAE,CAAC;QACxB,OAAO,oBAAY,CAAC,GAAG,CAAC,EAAE,IAAI,EAAE,OAAO,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC;IACnD,CAAC;IAED,OAAO,CAAC,KAAK,CAAC,0BAA0B,OAAO,IAAI,EAAE,MAAM,KAAK,EAAE,CAAC,CAAC;IACpE,OAAO,CAAC,CAAC;AACX,CAAC,CAAC;AAEF,IAAI,CAAC,EAAE,IAAI,EAAE,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,IAAI,CACxC,CAAC,QAAQ,EAAE,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,EACpC,CAAC,KAAc,EAAE,EAAE;IACjB,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;IACrB,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC,CACF,CAAC","sourcesContent":["#!/usr/bin/env bun\nimport { CleanCommand } from './clean';\nimport { LintCommand } from './lint';\n\nconst USAGE = 'Usage: devz lint [--fix] [files] | devz clean';\n\nconst main = async (opts: { argv: string[] }): Promise<number> => {\n const [command, ...args] = opts.argv;\n\n if (command === 'lint') {\n return LintCommand.run({ root: process.cwd(), args });\n }\n\n if (command === 'clean') {\n return CleanCommand.run({ root: process.cwd() });\n }\n\n console.error(`devz: unknown command \"${command ?? ''}\"\\n${USAGE}`);\n return 1;\n};\n\nmain({ argv: process.argv.slice(2) }).then(\n (exitCode) => process.exit(exitCode),\n (error: unknown) => {\n console.error(error);\n process.exit(1);\n },\n);\n"]}
|
package/dist/cli/lint.d.ts
CHANGED
|
@@ -4,9 +4,10 @@ export interface ILintStep {
|
|
|
4
4
|
args: string[];
|
|
5
5
|
}
|
|
6
6
|
/**
|
|
7
|
-
* `devz lint [--fix] [files]`: oxlint, then ESLint, then
|
|
8
|
-
* `.configs/lints/` and `.configs/formatters
|
|
9
|
-
*
|
|
7
|
+
* `devz lint [--fix] [files]`: oxlint, then ESLint, then `bun fmt`, from the project's
|
|
8
|
+
* `.configs/lints/` and `.configs/formatters/.ignore`. `bun fmt` takes its options from the `[fmt]` table
|
|
9
|
+
* of the nearest `bunfig.toml`. With no file it checks the whole project; with files it handles only
|
|
10
|
+
* those, as a pre-commit hook passes them.
|
|
10
11
|
*/
|
|
11
12
|
export declare class LintCommand {
|
|
12
13
|
/**
|
|
@@ -18,7 +19,10 @@ export declare class LintCommand {
|
|
|
18
19
|
root: string;
|
|
19
20
|
file: string;
|
|
20
21
|
}): string[];
|
|
21
|
-
/**
|
|
22
|
+
/**
|
|
23
|
+
* The tool calls for these arguments, in order; empty when a file list holds nothing to lint or
|
|
24
|
+
* format. oxlint and ESLint take the code files; `bun fmt` takes those and the other formatted types.
|
|
25
|
+
*/
|
|
22
26
|
static plan(opts: {
|
|
23
27
|
root: string;
|
|
24
28
|
args: string[];
|
package/dist/cli/lint.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lint.d.ts","sourceRoot":"","sources":["../../src/cli/lint.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"lint.d.ts","sourceRoot":"","sources":["../../src/cli/lint.ts"],"names":[],"mappings":"AAuBA,iFAAiF;AACjF,MAAM,WAAW,SAAS;IACxB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,EAAE,CAAC;CAChB;AAED;;;;;GAKG;AACH,qBAAa,WAAW;IACtB;;;;OAIG;IACH,MAAM,CAAC,UAAU,CAAC,IAAI,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,GAAG,MAAM,EAAE;IAYjE;;;OAGG;IACH,MAAM,CAAC,IAAI,CAAC,IAAI,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,EAAE,CAAA;KAAE,GAAG,SAAS,EAAE;IA8DhE,iGAAiG;IACjG,MAAM,CAAC,WAAW,CAAC,IAAI,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,GAAG,MAAM;IAgBhE,4FAA4F;WAC/E,GAAG,CAAC,IAAI,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,EAAE,CAAA;KAAE,GAAG,OAAO,CAAC,MAAM,CAAC;CAgB1E"}
|
package/dist/cli/lint.js
CHANGED
|
@@ -5,17 +5,28 @@ const node_fs_1 = require("node:fs");
|
|
|
5
5
|
const node_path_1 = require("node:path");
|
|
6
6
|
const LINT_CONFIG = '.configs/lints/oxlint.config.mts';
|
|
7
7
|
const ESLINT_CONFIG = '.configs/lints/eslint.config.mjs';
|
|
8
|
-
const FORMAT_CONFIG = '.configs/formatters/oxfmt.config.mts';
|
|
9
8
|
const LINT_IGNORE_FILE = '.configs/lints/.ignore';
|
|
10
9
|
const FORMAT_IGNORE_FILE = '.configs/formatters/.ignore';
|
|
11
10
|
const ESLINT_CACHE = ['--cache', '--cache-location', 'node_modules/.cache/eslint/'];
|
|
12
11
|
const LINTED_EXTENSIONS = new Set(['.ts', '.tsx', '.mts', '.js', '.mjs']);
|
|
13
|
-
|
|
12
|
+
/** What `bun fmt` formats: the code, JSON (package.json keys are sorted), YAML, CSS, HTML and Vue - not Markdown. */
|
|
13
|
+
const FORMATTED_EXTENSIONS = new Set([
|
|
14
|
+
...LINTED_EXTENSIONS,
|
|
15
|
+
'.json',
|
|
16
|
+
'.jsonc',
|
|
17
|
+
'.yml',
|
|
18
|
+
'.yaml',
|
|
19
|
+
'.css',
|
|
20
|
+
'.html',
|
|
21
|
+
'.vue',
|
|
22
|
+
]);
|
|
23
|
+
const FORMAT_GLOB = '**/*.{ts,mts,tsx,js,mjs,json,jsonc,yml,yaml,css,html,vue}';
|
|
14
24
|
const FIX_FLAG = '--fix';
|
|
15
25
|
/**
|
|
16
|
-
* `devz lint [--fix] [files]`: oxlint, then ESLint, then
|
|
17
|
-
* `.configs/lints/` and `.configs/formatters
|
|
18
|
-
*
|
|
26
|
+
* `devz lint [--fix] [files]`: oxlint, then ESLint, then `bun fmt`, from the project's
|
|
27
|
+
* `.configs/lints/` and `.configs/formatters/.ignore`. `bun fmt` takes its options from the `[fmt]` table
|
|
28
|
+
* of the nearest `bunfig.toml`. With no file it checks the whole project; with files it handles only
|
|
29
|
+
* those, as a pre-commit hook passes them.
|
|
19
30
|
*/
|
|
20
31
|
class LintCommand {
|
|
21
32
|
/**
|
|
@@ -30,24 +41,31 @@ class LintCommand {
|
|
|
30
41
|
}
|
|
31
42
|
return (0, node_fs_1.readFileSync)(path, 'utf8')
|
|
32
43
|
.split('\n')
|
|
33
|
-
.map(line => line.trim())
|
|
34
|
-
.filter(line => line !== '' && !line.startsWith('#'));
|
|
44
|
+
.map((line) => line.trim())
|
|
45
|
+
.filter((line) => line !== '' && !line.startsWith('#'));
|
|
35
46
|
}
|
|
36
|
-
/**
|
|
47
|
+
/**
|
|
48
|
+
* The tool calls for these arguments, in order; empty when a file list holds nothing to lint or
|
|
49
|
+
* format. oxlint and ESLint take the code files; `bun fmt` takes those and the other formatted types.
|
|
50
|
+
*/
|
|
37
51
|
static plan(opts) {
|
|
38
52
|
const fix = opts.args[0] === FIX_FLAG;
|
|
39
53
|
const paths = fix ? opts.args.slice(1) : opts.args;
|
|
40
54
|
const whole = paths.length === 0;
|
|
41
|
-
const files = paths.filter(path => LINTED_EXTENSIONS.has((0, node_path_1.extname)(path)));
|
|
42
|
-
|
|
55
|
+
const files = paths.filter((path) => LINTED_EXTENSIONS.has((0, node_path_1.extname)(path)));
|
|
56
|
+
const formatted = paths.filter((path) => FORMATTED_EXTENSIONS.has((0, node_path_1.extname)(path)));
|
|
57
|
+
if (!whole && formatted.length === 0) {
|
|
43
58
|
return [];
|
|
44
59
|
}
|
|
45
60
|
const targets = whole ? ['.'] : files;
|
|
46
|
-
const lintIgnore = LintCommand.readIgnore({ root: opts.root, file: LINT_IGNORE_FILE }).flatMap(pattern => ['--ignore-pattern', pattern]);
|
|
47
|
-
const formatIgnore = LintCommand.readIgnore({
|
|
61
|
+
const lintIgnore = LintCommand.readIgnore({ root: opts.root, file: LINT_IGNORE_FILE }).flatMap((pattern) => ['--ignore-pattern', pattern]);
|
|
62
|
+
const formatIgnore = LintCommand.readIgnore({
|
|
63
|
+
root: opts.root,
|
|
64
|
+
file: FORMAT_IGNORE_FILE,
|
|
65
|
+
}).flatMap((pattern) => ['--ignore-pattern', pattern]);
|
|
48
66
|
const unmatched = whole ? [] : ['--no-error-on-unmatched-pattern'];
|
|
49
67
|
const eslintQuiet = whole ? [] : ['--no-warn-ignored'];
|
|
50
|
-
|
|
68
|
+
const linters = [
|
|
51
69
|
{
|
|
52
70
|
tool: 'oxlint',
|
|
53
71
|
args: [
|
|
@@ -71,18 +89,19 @@ class LintCommand {
|
|
|
71
89
|
...targets,
|
|
72
90
|
],
|
|
73
91
|
},
|
|
74
|
-
{
|
|
75
|
-
tool: 'oxfmt',
|
|
76
|
-
args: [
|
|
77
|
-
'-c',
|
|
78
|
-
FORMAT_CONFIG,
|
|
79
|
-
...unmatched,
|
|
80
|
-
...(fix ? [] : ['--check']),
|
|
81
|
-
...(whole ? [FORMAT_GLOB] : files),
|
|
82
|
-
...formatIgnore,
|
|
83
|
-
],
|
|
84
|
-
},
|
|
85
92
|
];
|
|
93
|
+
const formatter = {
|
|
94
|
+
tool: 'bun',
|
|
95
|
+
args: [
|
|
96
|
+
'fmt',
|
|
97
|
+
'--no-script',
|
|
98
|
+
...unmatched,
|
|
99
|
+
...formatIgnore,
|
|
100
|
+
...(fix ? [] : ['--check']),
|
|
101
|
+
...(whole ? [FORMAT_GLOB] : formatted),
|
|
102
|
+
],
|
|
103
|
+
};
|
|
104
|
+
return whole || files.length > 0 ? [...linters, formatter] : [formatter];
|
|
86
105
|
}
|
|
87
106
|
/** The tool's binary in the nearest `node_modules/.bin`, else its bare name for PATH to find. */
|
|
88
107
|
static resolveTool(opts) {
|
package/dist/cli/lint.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lint.js","sourceRoot":"","sources":["../../src/cli/lint.ts"],"names":[],"mappings":";;;AAAA,qCAAmD;AACnD,yCAAmD;AAEnD,MAAM,WAAW,GAAG,kCAAkC,CAAC;AACvD,MAAM,aAAa,GAAG,kCAAkC,CAAC;AACzD,MAAM,
|
|
1
|
+
{"version":3,"file":"lint.js","sourceRoot":"","sources":["../../src/cli/lint.ts"],"names":[],"mappings":";;;AAAA,qCAAmD;AACnD,yCAAmD;AAEnD,MAAM,WAAW,GAAG,kCAAkC,CAAC;AACvD,MAAM,aAAa,GAAG,kCAAkC,CAAC;AACzD,MAAM,gBAAgB,GAAG,wBAAwB,CAAC;AAClD,MAAM,kBAAkB,GAAG,6BAA6B,CAAC;AACzD,MAAM,YAAY,GAAG,CAAC,SAAS,EAAE,kBAAkB,EAAE,6BAA6B,CAAC,CAAC;AACpF,MAAM,iBAAiB,GAAG,IAAI,GAAG,CAAC,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,CAAC,CAAC,CAAC;AAC1E,qHAAqH;AACrH,MAAM,oBAAoB,GAAG,IAAI,GAAG,CAAC;IACnC,GAAG,iBAAiB;IACpB,OAAO;IACP,QAAQ;IACR,MAAM;IACN,OAAO;IACP,MAAM;IACN,OAAO;IACP,MAAM;CACP,CAAC,CAAC;AACH,MAAM,WAAW,GAAG,2DAA2D,CAAC;AAChF,MAAM,QAAQ,GAAG,OAAO,CAAC;AAQzB;;;;;GAKG;AACH,MAAa,WAAW;IACtB;;;;OAIG;IACH,MAAM,CAAC,UAAU,CAAC,IAAoC;QACpD,MAAM,IAAI,GAAG,IAAA,gBAAI,EAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC;QACxC,IAAI,CAAC,IAAA,oBAAU,EAAC,IAAI,CAAC,EAAE,CAAC;YACtB,OAAO,EAAE,CAAC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CAAC,IAAI;gBACd,KAAK,EAAE,CAAC,SAAS,EAAE,SAAS,EAAE,SAAS,CAAC;aACzC,CAAC,CAAC;YACH,MAAM,QAAQ,GAAG,MAAM,KAAK,CAAC,MAAM,CAAC;YAEpC,IAAI,QAAQ,KAAK,CAAC,EAAE,CAAC;gBACnB,OAAO,QAAQ,CAAC;YAClB,CAAC;QACH,CAAC;QAED,OAAO,CAAC,CAAC;IACX,CAAC;CACF;AAtHD,kCAsHC","sourcesContent":["import { existsSync, readFileSync } from 'node:fs';\nimport { dirname, extname, join } from 'node:path';\n\nconst LINT_CONFIG = '.configs/lints/oxlint.config.mts';\nconst ESLINT_CONFIG = '.configs/lints/eslint.config.mjs';\nconst LINT_IGNORE_FILE = '.configs/lints/.ignore';\nconst FORMAT_IGNORE_FILE = '.configs/formatters/.ignore';\nconst ESLINT_CACHE = ['--cache', '--cache-location', 'node_modules/.cache/eslint/'];\nconst LINTED_EXTENSIONS = new Set(['.ts', '.tsx', '.mts', '.js', '.mjs']);\n/** What `bun fmt` formats: the code, JSON (package.json keys are sorted), YAML, CSS, HTML and Vue - not Markdown. */\nconst FORMATTED_EXTENSIONS = new Set([\n ...LINTED_EXTENSIONS,\n '.json',\n '.jsonc',\n '.yml',\n '.yaml',\n '.css',\n '.html',\n '.vue',\n]);\nconst FORMAT_GLOB = '**/*.{ts,mts,tsx,js,mjs,json,jsonc,yml,yaml,css,html,vue}';\nconst FIX_FLAG = '--fix';\n\n/** One tool call: the tool name and its arguments, run from the project root. */\nexport interface ILintStep {\n tool: string;\n args: string[];\n}\n\n/**\n * `devz lint [--fix] [files]`: oxlint, then ESLint, then `bun fmt`, from the project's\n * `.configs/lints/` and `.configs/formatters/.ignore`. `bun fmt` takes its options from the `[fmt]` table\n * of the nearest `bunfig.toml`. With no file it checks the whole project; with files it handles only\n * those, as a pre-commit hook passes them.\n */\nexport class LintCommand {\n /**\n * The patterns of an ignore file, one per line, `#` comments and blank lines skipped. An ignore\n * file resolves its patterns from its own folder, so they go on the command line instead, which\n * resolves from the project root.\n */\n static readIgnore(opts: { root: string; file: string }): string[] {\n const path = join(opts.root, opts.file);\n if (!existsSync(path)) {\n return [];\n }\n\n return readFileSync(path, 'utf8')\n .split('\\n')\n .map((line) => line.trim())\n .filter((line) => line !== '' && !line.startsWith('#'));\n }\n\n /**\n * The tool calls for these arguments, in order; empty when a file list holds nothing to lint or\n * format. oxlint and ESLint take the code files; `bun fmt` takes those and the other formatted types.\n */\n static plan(opts: { root: string; args: string[] }): ILintStep[] {\n const fix = opts.args[0] === FIX_FLAG;\n const paths = fix ? opts.args.slice(1) : opts.args;\n const whole = paths.length === 0;\n const files = paths.filter((path) => LINTED_EXTENSIONS.has(extname(path)));\n const formatted = paths.filter((path) => FORMATTED_EXTENSIONS.has(extname(path)));\n\n if (!whole && formatted.length === 0) {\n return [];\n }\n\n const targets = whole ? ['.'] : files;\n const lintIgnore = LintCommand.readIgnore({ root: opts.root, file: LINT_IGNORE_FILE }).flatMap(\n (pattern) => ['--ignore-pattern', pattern],\n );\n const formatIgnore = LintCommand.readIgnore({\n root: opts.root,\n file: FORMAT_IGNORE_FILE,\n }).flatMap((pattern) => ['--ignore-pattern', pattern]);\n const unmatched = whole ? [] : ['--no-error-on-unmatched-pattern'];\n const eslintQuiet = whole ? [] : ['--no-warn-ignored'];\n\n const linters: ILintStep[] = [\n {\n tool: 'oxlint',\n args: [\n '-c',\n LINT_CONFIG,\n ...lintIgnore,\n ...unmatched,\n fix ? FIX_FLAG : '--deny-warnings',\n ...targets,\n ],\n },\n {\n tool: 'eslint',\n args: [\n '-c',\n ESLINT_CONFIG,\n ...ESLINT_CACHE,\n ...eslintQuiet,\n ...lintIgnore,\n ...(fix ? [FIX_FLAG] : []),\n ...targets,\n ],\n },\n ];\n const formatter: ILintStep = {\n tool: 'bun',\n args: [\n 'fmt',\n '--no-script',\n ...unmatched,\n ...formatIgnore,\n ...(fix ? [] : ['--check']),\n ...(whole ? [FORMAT_GLOB] : formatted),\n ],\n };\n\n return whole || files.length > 0 ? [...linters, formatter] : [formatter];\n }\n\n /** The tool's binary in the nearest `node_modules/.bin`, else its bare name for PATH to find. */\n static resolveTool(opts: { root: string; tool: string }): string {\n let dir = opts.root;\n while (true) {\n const candidate = join(dir, 'node_modules', '.bin', opts.tool);\n if (existsSync(candidate)) {\n return candidate;\n }\n\n const parent = dirname(dir);\n if (parent === dir) {\n return opts.tool;\n }\n dir = parent;\n }\n }\n\n /** Runs the plan in order and stops at the first tool that fails; returns the exit code. */\n static async run(opts: { root: string; args: string[] }): Promise<number> {\n for (const step of LintCommand.plan(opts)) {\n const child = Bun.spawn({\n cmd: [LintCommand.resolveTool({ root: opts.root, tool: step.tool }), ...step.args],\n cwd: opts.root,\n stdio: ['inherit', 'inherit', 'inherit'],\n });\n const exitCode = await child.exited;\n\n if (exitCode !== 0) {\n return exitCode;\n }\n }\n\n return 0;\n }\n}\n"]}
|
package/dist/compilers/bun.js
CHANGED
|
@@ -33,7 +33,7 @@ class BunCompiler {
|
|
|
33
33
|
// eslint-disable-next-line venizia/no-new-error -- getError would be a dev-configs -> inversion cycle
|
|
34
34
|
throw new Error([
|
|
35
35
|
`[BunCompiler] compile failed for entrypoint "${entrypoint}":`,
|
|
36
|
-
...built.logs.map(log => `[${log.level}] ${log.message}`),
|
|
36
|
+
...built.logs.map((log) => `[${log.level}] ${log.message}`),
|
|
37
37
|
].join('\n'));
|
|
38
38
|
}
|
|
39
39
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bun.js","sourceRoot":"","sources":["../../src/compilers/bun.ts"],"names":[],"mappings":";;;AAAA,MAAM,kBAAkB,GAAG,iBAAiB,CAAC;AAC7C,MAAM,eAAe,GAAG,YAAY,CAAC;AACrC,MAAM,sBAAsB,GAAG,eAAe,CAAC;AAE/C,gHAAgH;AAChH,MAAa,WAAW;IACtB;;;;OAIG;IACH,MAAM,CAAC,KAAK,CAAC,OAAO,CAClB,OAWI,EAAE;QAEN,MAAM,EACJ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U,IAAI,sBAAsB,EACrD,OAAO,GAAG,EAAE,EACZ,MAAM,GAAG,EAAE,EACX,KAAK,GAAG,KAAK,GACd,GAAG,IAAI,CAAC;QAET,MAAM,KAAK,GAAG,MAAM,GAAG,CAAC,KAAK,CAAC;YAC5B,WAAW,EAAE,CAAC,UAAU,EAAE,GAAG,OAAO,CAAC;YACrC,MAAM,EAAE,KAAK;YACb,MAAM,EAAE,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE;YAC1C,SAAS,EAAE,QAAQ;YACnB,KAAK,EAAE,KAAK;YACZ,OAAO,EAAE;gBACP,MAAM,EAAE,MAAiC;gBACzC,OAAO;aACR;YACD,MAAM;YACN,OAAO;YACP,KAAK;SACN,CAAC,CAAC;QAEH,IAAI,CAAC,KAAK,CAAC,OAAO,EAAE,CAAC;YACnB,4FAA4F;YAC5F,8FAA8F;YAC9F,sGAAsG;YACtG,MAAM,IAAI,KAAK,CACb;gBACE,gDAAgD,UAAU,IAAI;gBAC9D,GAAG,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,IAAI,GAAG,CAAC,KAAK,KAAK,GAAG,CAAC,OAAO,EAAE,CAAC;aAC5D,CAAC,IAAI,CAAC,IAAI,CAAC,CACb,CAAC;QACJ,CAAC;IACH,CAAC;CACF;AAzDD,kCAyDC","sourcesContent":["const DEFAULT_ENTRYPOINT = './dist/index.js';\nconst DEFAULT_OUTFILE = './dist/bin';\nconst DEFAULT_COMPILE_TARGET = 'bun-linux-x64';\n\n/** Bundles and compiles a single Bun executable: minified, linked sourcemaps, target read from `BUN_TARGET`. */\nexport class BunCompiler {\n /**\n * `plugins` is a parameter, never resolved here - `dev-configs` sits below every other IGNIS\n * package (see the Makefile chain) and must not import a plugin factory such as\n * `platformaticKafkaPlugins()` from `helpers`, which would invert that chain.\n */\n static async compile(\n opts: {\n entrypoint?: string;\n /** Bun Worker files the entrypoint starts (`new Worker('./x.worker.ts')`): compiled into the same binary. */\n workers?: string[];\n outfile?: string;\n target?: string;\n plugins?: Bun.BunPlugin[];\n /** Compile-time constants: each key is replaced by its value, a JSON-encoded expression, wherever the bundle reads it. */\n define?: Record<string, string>;\n /** Type-check the bundle first; a type error stops the compile. */\n check?: boolean;\n } = {},\n ): Promise<void> {\n const {\n entrypoint = DEFAULT_ENTRYPOINT,\n workers = [],\n outfile = DEFAULT_OUTFILE,\n target = Bun.env.BUN_TARGET ?? DEFAULT_COMPILE_TARGET,\n plugins = [],\n define = {},\n check = false,\n } = opts;\n\n const built = await Bun.build({\n entrypoints: [entrypoint, ...workers],\n target: 'bun',\n minify: { whitespace: true, syntax: true },\n sourcemap: 'linked',\n throw: false,\n compile: {\n target: target as Bun.Build.CompileTarget,\n outfile,\n },\n define,\n plugins,\n check,\n });\n\n if (!built.success) {\n // `getError` lives in `inversion`, which depends on `dev-configs` - importing it here would\n // create a circular workspace dependency, so a failed compile throws a plain `Error` instead.\n // eslint-disable-next-line venizia/no-new-error -- getError would be a dev-configs -> inversion cycle\n throw new Error(\n [\n `[BunCompiler] compile failed for entrypoint \"${entrypoint}\":`,\n ...built.logs.map((log) => `[${log.level}] ${log.message}`),\n ].join('\\n'),\n );\n }\n }\n}\n"]}
|
package/dist/index.d.ts
CHANGED
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,WAAW,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -15,6 +15,5 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
__exportStar(require("./compilers"), exports);
|
|
18
|
-
__exportStar(require("./formatters"), exports);
|
|
19
18
|
__exportStar(require("./linters"), exports);
|
|
20
19
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,8CAA4B;AAC5B
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,8CAA4B;AAC5B,4CAA0B","sourcesContent":["export * from './compilers';\nexport * from './linters';\n"]}
|
package/dist/linters/eslint.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { Linter } from 'eslint';
|
|
2
2
|
/**
|
|
3
|
-
* The full ESLint preset, owned here: the LoopBack 4 rule set on the ESLint
|
|
4
|
-
*
|
|
3
|
+
* The full ESLint preset, owned here: the LoopBack 4 rule set on the ESLint and typescript-eslint
|
|
4
|
+
* recommended presets, type-aware through the project service. A project on oxlint uses
|
|
5
5
|
* `oxlintConfigs` + `namingConventionConfigs` instead.
|
|
6
6
|
*/
|
|
7
7
|
export declare const eslintConfigs: Linter.Config[];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"eslint.d.ts","sourceRoot":"","sources":["../../src/linters/eslint.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;
|
|
1
|
+
{"version":3,"file":"eslint.d.ts","sourceRoot":"","sources":["../../src/linters/eslint.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAuFrC;;;;GAIG;AACH,eAAO,MAAM,aAAa,EAAE,MAAM,CAAC,MAAM,EAkCvC,CAAC;AAEH;;;;;;;;;;GAUG;AACH,eAAO,MAAM,uBAAuB,EAAE,MAAM,CAAC,MAAM,EAWlD,CAAC"}
|
package/dist/linters/eslint.js
CHANGED
|
@@ -7,7 +7,6 @@ exports.namingConventionConfigs = exports.eslintConfigs = void 0;
|
|
|
7
7
|
const js_1 = __importDefault(require("@eslint/js"));
|
|
8
8
|
const config_1 = require("eslint/config");
|
|
9
9
|
const eslint_plugin_n_1 = __importDefault(require("eslint-plugin-n"));
|
|
10
|
-
const recommended_1 = __importDefault(require("eslint-plugin-prettier/recommended"));
|
|
11
10
|
const eslint_plugin_unicorn_1 = __importDefault(require("eslint-plugin-unicorn"));
|
|
12
11
|
const typescript_eslint_1 = __importDefault(require("typescript-eslint"));
|
|
13
12
|
const rules_1 = require("./rules");
|
|
@@ -84,15 +83,13 @@ const STRICT_RULES = {
|
|
|
84
83
|
'@typescript-eslint/return-await': 'error',
|
|
85
84
|
};
|
|
86
85
|
/**
|
|
87
|
-
* The full ESLint preset, owned here: the LoopBack 4 rule set on the ESLint
|
|
88
|
-
*
|
|
86
|
+
* The full ESLint preset, owned here: the LoopBack 4 rule set on the ESLint and typescript-eslint
|
|
87
|
+
* recommended presets, type-aware through the project service. A project on oxlint uses
|
|
89
88
|
* `oxlintConfigs` + `namingConventionConfigs` instead.
|
|
90
89
|
*/
|
|
91
90
|
exports.eslintConfigs = (0, config_1.defineConfig)([
|
|
92
91
|
js_1.default.configs.recommended,
|
|
93
92
|
typescript_eslint_1.default.configs.recommended,
|
|
94
|
-
// Last of the presets, so it turns off every stylistic rule that would fight the formatter.
|
|
95
|
-
recommended_1.default,
|
|
96
93
|
{
|
|
97
94
|
files: SOURCE_FILES,
|
|
98
95
|
languageOptions: {
|
|
@@ -122,7 +119,6 @@ exports.eslintConfigs = (0, config_1.defineConfig)([
|
|
|
122
119
|
'**/.babelrc.*',
|
|
123
120
|
'**/eslint.config.*',
|
|
124
121
|
'**/.eslintrc.*',
|
|
125
|
-
'**/.prettierrc.*',
|
|
126
122
|
],
|
|
127
123
|
},
|
|
128
124
|
]);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"eslint.js","sourceRoot":"","sources":["../../src/linters/eslint.ts"],"names":[],"mappings":";;;;;;AAAA,oDAA4B;AAE5B,0CAA6C;AAC7C,sEAAgC;AAChC,
|
|
1
|
+
{"version":3,"file":"eslint.js","sourceRoot":"","sources":["../../src/linters/eslint.ts"],"names":[],"mappings":";;;;;;AAAA,oDAA4B;AAE5B,0CAA6C;AAC7C,sEAAgC;AAChC,kFAA4C;AAC5C,0EAAyC;AACzC,mCAKiB;AAEjB,mCAAmC;AACnC,MAAM,YAAY,GAAG;IACnB,SAAS;IACT,UAAU;IACV,UAAU;IACV,UAAU;IACV,SAAS;IACT,UAAU;IACV,UAAU;IACV,UAAU;CACX,CAAC;AAEF,qGAAqG;AACrG,MAAM,SAAS,GAAuB;IACpC,uBAAuB,EAAE,KAAK;IAC9B,UAAU,EAAE,KAAK;IACjB,gBAAgB,EAAE,KAAK;IACvB,oBAAoB,EAAE,KAAK;IAC3B,uBAAuB,EAAE,KAAK;IAC9B,uBAAuB,EAAE,KAAK;IAC9B,cAAc,EAAE,KAAK;IACrB,iBAAiB,EAAE,KAAK;IACxB,WAAW,EAAE,KAAK;IAClB,iBAAiB,EAAE,KAAK;IACxB,SAAS,EAAE,KAAK;IAChB,oCAAoC,EAAE,KAAK;IAC3C,4CAA4C,EAAE,KAAK;IACnD,kCAAkC,EAAE,KAAK;IACzC,yCAAyC,EAAE,KAAK;IAChD,yCAAyC,EAAE,KAAK;IAChD,iDAAiD,EAAE,KAAK;IACxD,wCAAwC,EAAE,KAAK;IAC/C,uCAAuC,EAAE,KAAK;IAC9C,+CAA+C,EAAE,KAAK;IACtD,kDAAkD,EAAE,KAAK;IACzD,kDAAkD,EAAE,KAAK;IACzD,mDAAmD,EAAE,KAAK;IAC1D,+BAA+B,EAAE,KAAK;IACtC,0CAA0C,EAAE,KAAK;IACjD,sCAAsC,EAAE,KAAK;IAC7C,+CAA+C,EAAE,KAAK;IACtD,wCAAwC,EAAE,KAAK;CAChD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YACL,GAAG,SAAS;YACZ,GAAG,YAAY;YACf,mCAAmC,EAAE,wBAAgB,CAAC,KAAK,EAAsB;YACjF,CAAC,+BAAuB,CAAC,IAAI,CAAC,EAAE,+BAAuB,CAAC,KAAK,EAAsB;YACnF,CAAC,4BAAoB,CAAC,IAAI,CAAC,EAAE,4BAAoB,CAAC,KAAK,EAAsB;YAC7E,CAAC,4BAAoB,CAAC,IAAI,CAAC,EAAE,4BAAoB,CAAC,KAAK,EAAE;SAC1D;KACF;IACD;QACE,OAAO,EAAE;YACP,kBAAkB;YAClB,WAAW;YACX,WAAW;YACX,UAAU;YACV,aAAa;YACb,mBAAmB;YACnB,eAAe;YACf,oBAAoB;YACpB,gBAAgB;SACjB;KACF;CACF,CAAC,CAAC;AAEH;;;;;;;;;;GAUG;AACU,QAAA,uBAAuB,GAAoB;IACtD,6FAA6F;IAC7F,EAAE,OAAO,EAAE,CAAC,YAAY,EAAE,aAAa,EAAE,gBAAgB,EAAE,WAAW,EAAE,mBAAmB,CAAC,EAAE;IAC9F;QACE,KAAK,EAAE,CAAC,uBAAuB,CAAC;QAChC,eAAe,EAAE,EAAE,MAAM,EAAE,2BAAQ,CAAC,MAAuB,EAAE;QAC7D,OAAO,EAAE,EAAE,oBAAoB,EAAE,2BAAQ,CAAC,MAAe,EAAE;QAC3D,4FAA4F;QAC5F,aAAa,EAAE,EAAE,6BAA6B,EAAE,KAAK,EAAE;QACvD,KAAK,EAAE,EAAE,CAAC,4BAAoB,CAAC,IAAI,CAAC,EAAE,4BAAoB,CAAC,KAAK,EAAE,EAAE;KACrE;CACF,CAAC","sourcesContent":["import js from '@eslint/js';\nimport type { Linter } from 'eslint';\nimport { defineConfig } from 'eslint/config';\nimport n from 'eslint-plugin-n';\nimport unicorn from 'eslint-plugin-unicorn';\nimport tseslint from 'typescript-eslint';\nimport {\n NamingConventionRule,\n NoRestrictedImportsRule,\n NoUnusedVarsRule,\n SwitchCaseBracesRule,\n} from './rules';\n\n/** Every file the preset lints. */\nconst SOURCE_FILES = [\n '**/*.js',\n '**/*.cjs',\n '**/*.mjs',\n '**/*.jsx',\n '**/*.ts',\n '**/*.cts',\n '**/*.mts',\n '**/*.tsx',\n];\n\n/** Rules that stay off: the type checker, the formatter or the framework's own style covers them. */\nconst OFF_RULES: Linter.RulesRecord = {\n 'no-constant-condition': 'off',\n 'no-undef': 'off',\n 'no-unused-vars': 'off',\n 'no-mixed-operators': 'off',\n 'no-inner-declarations': 'off',\n 'no-dupe-class-members': 'off',\n 'no-redeclare': 'off',\n 'no-invalid-this': 'off',\n 'no-shadow': 'off',\n 'no-return-await': 'off',\n camelcase: 'off',\n '@typescript-eslint/no-explicit-any': 'off',\n '@typescript-eslint/no-unsafe-function-type': 'off',\n '@typescript-eslint/no-this-alias': 'off',\n '@typescript-eslint/no-empty-object-type': 'off',\n '@typescript-eslint/no-invalid-void-type': 'off',\n '@typescript-eslint/no-confusing-void-expression': 'off',\n '@typescript-eslint/no-extraneous-class': 'off',\n '@typescript-eslint/no-require-imports': 'off',\n '@typescript-eslint/strict-boolean-expressions': 'off',\n '@typescript-eslint/explicit-function-return-type': 'off',\n '@typescript-eslint/explicit-member-accessibility': 'off',\n '@typescript-eslint/explicit-module-boundary-types': 'off',\n '@typescript-eslint/array-type': 'off',\n '@typescript-eslint/no-non-null-assertion': 'off',\n '@typescript-eslint/no-empty-function': 'off',\n '@typescript-eslint/consistent-type-assertions': 'off',\n '@typescript-eslint/no-misused-promises': 'off',\n};\n\n/** The LoopBack 4 rule set, on top of the recommended presets. */\nconst STRICT_RULES: Linter.RulesRecord = {\n 'prefer-const': 'error',\n 'no-var': 'error',\n curly: ['error', 'all'],\n 'no-new-wrappers': 'error',\n 'no-throw-literal': 'error',\n 'no-unused-expressions': 'error',\n eqeqeq: ['error', 'smart'],\n 'no-void': 'error',\n 'no-useless-escape': 'warn',\n 'no-caller': 'error',\n 'n/prefer-node-protocol': ['error'],\n '@typescript-eslint/adjacent-overload-signatures': 'error',\n '@typescript-eslint/prefer-for-of': 'error',\n '@typescript-eslint/unified-signatures': 'error',\n '@typescript-eslint/no-invalid-this': ['error'],\n '@typescript-eslint/no-use-before-define': 'error',\n '@typescript-eslint/no-shadow': 'error',\n '@typescript-eslint/ban-ts-comment': 'error',\n '@typescript-eslint/no-namespace': 'error',\n '@typescript-eslint/await-thenable': 'error',\n '@typescript-eslint/no-floating-promises': 'error',\n '@typescript-eslint/prefer-optional-chain': 'error',\n '@typescript-eslint/prefer-nullish-coalescing': [\n 'error',\n { allowRuleToRunWithoutStrictNullChecksIKnowWhatIAmDoing: true },\n ],\n '@typescript-eslint/return-await': 'error',\n};\n\n/**\n * The full ESLint preset, owned here: the LoopBack 4 rule set on the ESLint and typescript-eslint\n * recommended presets, type-aware through the project service. A project on oxlint uses\n * `oxlintConfigs` + `namingConventionConfigs` instead.\n */\nexport const eslintConfigs: Linter.Config[] = defineConfig([\n js.configs.recommended,\n tseslint.configs.recommended,\n {\n files: SOURCE_FILES,\n languageOptions: {\n parserOptions: {\n // Finds each file's tsconfig; the default project covers root-level scripts and configs.\n projectService: { allowDefaultProject: ['*.js', '*.cjs', '*.mjs', '.*.js'] },\n },\n },\n plugins: { n, unicorn },\n rules: {\n ...OFF_RULES,\n ...STRICT_RULES,\n '@typescript-eslint/no-unused-vars': NoUnusedVarsRule.build() as Linter.RuleEntry,\n [NoRestrictedImportsRule.NAME]: NoRestrictedImportsRule.build() as Linter.RuleEntry,\n [SwitchCaseBracesRule.NAME]: SwitchCaseBracesRule.build() as Linter.RuleEntry,\n [NamingConventionRule.NAME]: NamingConventionRule.build(),\n },\n },\n {\n ignores: [\n '**/node_modules/',\n '**/*.d.ts',\n '**/build/',\n '**/dist/',\n '**/release/',\n '**/babel.config.*',\n '**/.babelrc.*',\n '**/eslint.config.*',\n '**/.eslintrc.*',\n ],\n },\n]);\n\n/**\n * The one rule of `eslintConfigs` that oxlint cannot run yet, as a standalone ESLint preset to run\n * next to `oxlintConfigs`. It needs no type information, so ESLint stays fast.\n *\n * ```js\n * // .configs/lints/eslint.config.mjs\n * import { namingConventionConfigs } from '@venizia/dev-configs/linters';\n *\n * export default namingConventionConfigs;\n * ```\n */\nexport const namingConventionConfigs: Linter.Config[] = [\n // Global: ESLint does not read .gitignore, and still walks plain .js files no config claims.\n { ignores: ['**/dist/**', '**/build/**', '**/coverage/**', '**/*.d.ts', '**/*.{js,cjs,mjs}'] },\n {\n files: ['**/*.{ts,tsx,mts,cts}'],\n languageOptions: { parser: tseslint.parser as Linter.Parser },\n plugins: { '@typescript-eslint': tseslint.plugin as never },\n // oxlint owns every other rule, so the disable comments for them are not ESLint's to judge.\n linterOptions: { reportUnusedDisableDirectives: 'off' },\n rules: { [NamingConventionRule.NAME]: NamingConventionRule.build() },\n },\n];\n"]}
|
|
@@ -19,7 +19,7 @@ class ConstClassValuesRule {
|
|
|
19
19
|
constClass: 'An enumerable string is a const class plus TConstValue<typeof X>, not a union of string literals.',
|
|
20
20
|
},
|
|
21
21
|
},
|
|
22
|
-
create: context => {
|
|
22
|
+
create: (context) => {
|
|
23
23
|
const options = context.options[0];
|
|
24
24
|
const configured = (0, common_1.readField)({ node: options, key: 'namePattern' });
|
|
25
25
|
const namePattern = new RegExp(typeof configured === 'string' ? configured : ConstClassValuesRule.DEFAULT_NAME_PATTERN);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"const-class-values.rule.js","sourceRoot":"","sources":["../../../src/linters/house/const-class-values.rule.ts"],"names":[],"mappings":";;;AAEA,qCAAqF;AAErF;;;;;GAKG;AACH,MAAa,oBAAoB;aACf,SAAI,GAAG,GAAG,+BAAsB,qBAAqB,CAAC;aAEtD,yBAAoB,GAAG,sCAAsC,CAAC;aAE9D,SAAI,GAAoB;QACtC,IAAI,EAAE;YACJ,IAAI,EAAE,YAAY;YAClB,MAAM,EAAE,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,UAAU,EAAE,EAAE,WAAW,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,EAAE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import { AstNodeTypes, HOUSE_PLUGIN_NAMESPACE, nodeType, readField } from './common';\n\n/**\n * `venizia/const-class-values`. An enumerable string is a const class plus `TConstValue<typeof X>`,\n * never an exported union of string literals. Only a type whose name ends like a logic value is\n * checked (`State`, `Status`, `Stage`, `Mode`, `Kind`, `Type` by default): any other string union may\n * be a plain parameter type.\n */\nexport class ConstClassValuesRule {\n static readonly NAME = `${HOUSE_PLUGIN_NAMESPACE}/const-class-values`;\n\n static readonly DEFAULT_NAME_PATTERN = '(State|Status|Stage|Mode|Kind|Type)$';\n\n static readonly RULE: Rule.RuleModule = {\n meta: {\n type: 'suggestion',\n schema: [{ type: 'object', properties: { namePattern: { type: 'string' } } }],\n messages: {\n constClass:\n 'An enumerable string is a const class plus TConstValue<typeof X>, not a union of string literals.',\n },\n },\n create: (context) => {\n const options: unknown = context.options[0];\n const configured = readField({ node: options, key: 'namePattern' });\n const namePattern = new RegExp(\n typeof configured === 'string' ? configured : ConstClassValuesRule.DEFAULT_NAME_PATTERN,\n );\n\n const isStringLiteral = (member: unknown) =>\n nodeType({ node: member }) === 'TSLiteralType' &&\n typeof readField({ node: readField({ node: member, key: 'literal' }), key: 'value' }) ===\n 'string';\n\n return {\n [`${AstNodeTypes.EXPORT_NAMED_DECLARATION} > TSTypeAliasDeclaration`]: (\n node: Rule.Node,\n ) => {\n const id = readField({ node, key: 'id' });\n const name = readField({ node: id, key: 'name' });\n const typeAnnotation = readField({ node, key: 'typeAnnotation' });\n const members = readField({ node: typeAnnotation, key: 'types' });\n\n if (\n typeof name === 'string' &&\n namePattern.test(name) &&\n nodeType({ node: typeAnnotation }) === 'TSUnionType' &&\n Array.isArray(members) &&\n members.every(isStringLiteral)\n ) {\n context.report({ node, messageId: 'constClass' });\n }\n },\n };\n },\n };\n\n static build(opts: { severity?: TRuleSeverity; namePattern?: string } = {}): Linter.RuleEntry {\n const { severity = 'error', namePattern = ConstClassValuesRule.DEFAULT_NAME_PATTERN } = opts;\n return [severity, { namePattern }];\n }\n}\n"]}
|
|
@@ -57,7 +57,7 @@ class MaxParamsOwnRule {
|
|
|
57
57
|
tooMany: 'A function we write takes up to {{max}} positional parameters, not {{count}}: take one options object.',
|
|
58
58
|
},
|
|
59
59
|
},
|
|
60
|
-
create: context => {
|
|
60
|
+
create: (context) => {
|
|
61
61
|
const max = typeof context.options[0] === 'number' ? context.options[0] : MaxParamsOwnRule.DEFAULT_MAX;
|
|
62
62
|
const isCallback = (node) => {
|
|
63
63
|
const parent = node.parent;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"max-params-own.rule.js","sourceRoot":"","sources":["../../../src/linters/house/max-params-own.rule.ts"],"names":[],"mappings":";;;AAEA,qCAAqF;AAErF,MAAM,SAAS,GAAG,WAAW,CAAC;AAC9B,MAAM,UAAU,GAAG,IAAI,GAAG,CAAC,CAAC,gBAAgB,EAAE,eAAe,CAAC,CAAC,CAAC;AAEhE,MAAM,iBAAiB,GAAG,CAAC,IAAsC,EAAE,EAAE,CACnE,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAE5D,4DAA4D;AAC5D,MAAM,UAAU,GAAG,CAAC,IAAa,EAAE,EAAE;IACnC,MAAM,MAAM,GAAG,IAAA,kBAAS,EAAC,EAAE,IAAI,EAAE,IAAI,EAAE,GAAG,EAAE,QAAQ,EAAE,CAAC,CAAC;IACxD,MAAM,IAAI,GAAG,IAAA,kBAAS,EAAC,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,CAAC,CAAC;IACtD,OAAO,CACL,IAAA,iBAAQ,EAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC,KAAK,YAAY,IAAI,OAAO,IAAI,KAAK,QAAQ,IAAI,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,CAChG,CAAC;AACJ,CAAC,CAAC;AAEF,mEAAm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M,CAAC,MAAM,CAAC,MAAM,CAAC,EAAE,GAAG,EAAE,MAAM,CAAC,GAAG,CAAC,EAAE;iBACzD,CAAC,CAAC;YACL,CAAC,CAAC;YAEF,OAAO;gBACL,CAAC,qBAAY,CAAC,oBAAoB,CAAC,EAAE,KAAK;gBAC1C,CAAC,qBAAY,CAAC,mBAAmB,CAAC,EAAE,KAAK;gBACzC,CAAC,qBAAY,CAAC,yBAAyB,CAAC,EAAE,KAAK;aAChD,CAAC;QACJ,CAAC;KACF,CAAC;IAEF,MAAM,CAAC,KAAK,CAAC,OAAmD,EAAE;QAChE,MAAM,EAAE,QAAQ,GAAG,OAAO,EAAE,GAAG,GAAG,gBAAgB,CAAC,WAAW,EAAE,GAAG,IAAI,CAAC;QACxE,OAAO,CAAC,QAAQ,EAAE,GAAG,CAAC,CAAC;IACzB,CAAC;;AA7FH,4CA8FC","sourcesContent":["import type { Linter, Rule } from 'eslint';\nimport type { TRuleSeverity } from '../rules/common';\nimport { AstNodeTypes, HOUSE_PLUGIN_NAMESPACE, nodeType, readField } from './common';\n\nconst HOOK_NAME = /^use[A-Z]/;\nconst CALL_TYPES = new Set(['CallExpression', 'NewExpression']);\n\nconst isArrayContaining = (opts: { list: unknown; item: unknown }) =>\n Array.isArray(opts.list) && opts.list.includes(opts.item);\n\n/** `useX(...)`: a hook's callback is ours, so it counts. */\nconst isHookCall = (call: unknown) => {\n const callee = readField({ node: call, key: 'callee' });\n const name = readField({ node: callee, key: 'name' });\n return (\n nodeType({ node: callee }) === 'Identifier' && typeof name === 'string' && HOOK_NAME.test(name)\n );\n};\n\n/** `node` is an argument of a call or `new` that is not a hook. */\nconst isLibraryArgument = (opts: { node: unknown; parent: unknown }) =>\n CALL_TYPES.has(nodeType({ node: opts.parent }) ?? '') &&\n isArrayContaining({\n list: readField({ node: opts.parent, key: 'arguments' }),\n item: opts.node,\n }) &&\n !isHookCall(opts.parent);\n\n/**\n * An object literal whose shape something else declares: a typed variable, `satisfies`, or an argument\n * of a non-hook call (a library option bag). A nested literal inherits it.\n */\nconst hasDeclaredShape = (object: unknown): boolean => {\n let current = object;\n\n while (current) {\n const parent = readField({ node: current, key: 'parent' });\n const parentType = nodeType({ node: parent });\n const isTypedVariable =\n parentType === 'VariableDeclarator' &&\n Boolean(readField({ node: readField({ node: parent, key: 'id' }), key: 'typeAnnotation' }));\n\n if (\n isTypedVariable ||\n parentType === 'TSSatisfiesExpression' ||\n isLibraryArgument({ node: current, parent })\n ) {\n return true;\n }\n\n const isNestedValue =\n parentType === 'Property' && readField({ node: parent, key: 'value' }) === current;\n current = isNestedValue ? readField({ node: parent, key: 'parent' }) : undefined;\n }\n\n return false;\n};\n\n/**\n * `venizia/max-params-own`. A function we write takes at most `max` (default 5) positional parameters;\n * beyond that it takes one options object. A signature that belongs to someone else is not counted: an\n * inline callback handed to a call (map, reduce, sort, a library handler) or to a JSX prop, a function a\n * declared type fixes (`const x: TFn = (...)`, a member of a typed or `satisfies` object), and a\n * constructor whose every parameter is injected (`@inject`). A hook's callback (`useCallback(...)`) is ours.\n */\nexport class MaxParamsOwnRule {\n static readonly NAME = `${HOUSE_PLUGIN_NAMESPACE}/max-params-own`;\n\n static readonly DEFAULT_MAX = 5;\n\n static readonly RULE: Rule.RuleModule = {\n meta: {\n type: 'suggestion',\n schema: [{ type: 'integer', minimum: 0 }],\n messages: {\n tooMany:\n 'A function we write takes up to {{max}} positional parameters, not {{count}}: take one options object.',\n },\n },\n create: context => {\n const max =\n typeof context.options[0] === 'number' ? context.options[0] : MaxParamsOwnRule.DEFAULT_MAX;\n\n const isCallback = (node: Rule.Node) => {\n const parent = node.parent;\n const isJsxProp =\n nodeType({ node: parent }) === 'JSXExpressionContainer' &&\n nodeType({ node: readField({ node: parent, key: 'parent' }) }) === 'JSXAttribute';\n return isJsxProp || isLibraryArgument({ node, parent });\n };\n\n const isInjectedConstructor = (opts: { node: Rule.Node; params: unknown[] }) => {\n const parent = opts.node.parent;\n const isDecorated = (param: unknown) => {\n const own = readField({ node: param, key: 'decorators' });\n const property = readField({\n node: readField({ node: param, key: 'parameter' }),\n key: 'decorators',\n });\n return (\n (Array.isArray(own) && own.length > 0) ||\n (Array.isArray(property) && property.length > 0)\n );\n };\n\n return (\n nodeType({ node: parent }) === 'MethodDefinition' &&\n readField({ node: parent, key: 'kind' }) === 'constructor' &&\n opts.params.every(isDecorated)\n );\n };\n\n const isTypedByContext = (node: Rule.Node) => {\n const parent = node.parent;\n const parentType = nodeType({ node: parent });\n const isTypedInit =\n parentType === 'VariableDeclarator' &&\n readField({ node: parent, key: 'init' }) === node &&\n Boolean(\n readField({ node: readField({ node: parent, key: 'id' }), key: 'typeAnnotation' }),\n );\n const grandParent = readField({ node: parent, key: 'parent' });\n const isMember =\n parentType === 'Property' &&\n readField({ node: parent, key: 'value' }) === node &&\n nodeType({ node: grandParent }) === 'ObjectExpression';\n\n return isTypedInit || (isMember && hasDeclaredShape(grandParent));\n };\n\n const check = (node: Rule.Node) => {\n const params = readField({ node, key: 'params' });\n if (!Array.isArray(params) || params.length <= max) {\n return;\n }\n\n if (isCallback(node) || isInjectedConstructor({ node, params }) || isTypedByContext(node)) {\n return;\n }\n\n context.report({\n node,\n messageId: 'tooMany',\n data: { count: String(params.length), max: String(max) },\n });\n };\n\n return {\n [AstNodeTypes.FUNCTION_DECLARATION]: check,\n [AstNodeTypes.FUNCTION_EXPRESSION]: check,\n [AstNodeTypes.ARROW_FUNCTION_EXPRESSION]: check,\n };\n },\n };\n\n static build(opts: { severity?: TRuleSeverity; max?: number } = {}): Linter.RuleEntry {\n const { severity = 'error', max = MaxParamsOwnRule.DEFAULT_MAX } = opts;\n return [severity, max];\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"max-params-own.rule.js","sourceRoot":"","sources":["../../../src/linters/house/max-params-own.rule.ts"],"names":[],"mappings":";;;AAEA,qCAAqF;AAErF,MAAM,SAAS,GAAG,WAAW,CAAC;AAC9B,MAAM,UAAU,GAAG,IAAI,GAAG,CAAC,CAAC,gB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AC;;AA7FH,4CA8FC","sourcesContent":["import type { Linter, Rule } from 'eslint';\nimport type { TRuleSeverity } from '../rules/common';\nimport { AstNodeTypes, HOUSE_PLUGIN_NAMESPACE, nodeType, readField } from './common';\n\nconst HOOK_NAME = /^use[A-Z]/;\nconst CALL_TYPES = new Set(['CallExpression', 'NewExpression']);\n\nconst isArrayContaining = (opts: { list: unknown; item: unknown }) =>\n Array.isArray(opts.list) && opts.list.includes(opts.item);\n\n/** `useX(...)`: a hook's callback is ours, so it counts. */\nconst isHookCall = (call: unknown) => {\n const callee = readField({ node: call, key: 'callee' });\n const name = readField({ node: callee, key: 'name' });\n return (\n nodeType({ node: callee }) === 'Identifier' && typeof name === 'string' && HOOK_NAME.test(name)\n );\n};\n\n/** `node` is an argument of a call or `new` that is not a hook. */\nconst isLibraryArgument = (opts: { node: unknown; parent: unknown }) =>\n CALL_TYPES.has(nodeType({ node: opts.parent }) ?? '') &&\n isArrayContaining({\n list: readField({ node: opts.parent, key: 'arguments' }),\n item: opts.node,\n }) &&\n !isHookCall(opts.parent);\n\n/**\n * An object literal whose shape something else declares: a typed variable, `satisfies`, or an argument\n * of a non-hook call (a library option bag). A nested literal inherits it.\n */\nconst hasDeclaredShape = (object: unknown): boolean => {\n let current = object;\n\n while (current) {\n const parent = readField({ node: current, key: 'parent' });\n const parentType = nodeType({ node: parent });\n const isTypedVariable =\n parentType === 'VariableDeclarator' &&\n Boolean(readField({ node: readField({ node: parent, key: 'id' }), key: 'typeAnnotation' }));\n\n if (\n isTypedVariable ||\n parentType === 'TSSatisfiesExpression' ||\n isLibraryArgument({ node: current, parent })\n ) {\n return true;\n }\n\n const isNestedValue =\n parentType === 'Property' && readField({ node: parent, key: 'value' }) === current;\n current = isNestedValue ? readField({ node: parent, key: 'parent' }) : undefined;\n }\n\n return false;\n};\n\n/**\n * `venizia/max-params-own`. A function we write takes at most `max` (default 5) positional parameters;\n * beyond that it takes one options object. A signature that belongs to someone else is not counted: an\n * inline callback handed to a call (map, reduce, sort, a library handler) or to a JSX prop, a function a\n * declared type fixes (`const x: TFn = (...)`, a member of a typed or `satisfies` object), and a\n * constructor whose every parameter is injected (`@inject`). A hook's callback (`useCallback(...)`) is ours.\n */\nexport class MaxParamsOwnRule {\n static readonly NAME = `${HOUSE_PLUGIN_NAMESPACE}/max-params-own`;\n\n static readonly DEFAULT_MAX = 5;\n\n static readonly RULE: Rule.RuleModule = {\n meta: {\n type: 'suggestion',\n schema: [{ type: 'integer', minimum: 0 }],\n messages: {\n tooMany:\n 'A function we write takes up to {{max}} positional parameters, not {{count}}: take one options object.',\n },\n },\n create: (context) => {\n const max =\n typeof context.options[0] === 'number' ? context.options[0] : MaxParamsOwnRule.DEFAULT_MAX;\n\n const isCallback = (node: Rule.Node) => {\n const parent = node.parent;\n const isJsxProp =\n nodeType({ node: parent }) === 'JSXExpressionContainer' &&\n nodeType({ node: readField({ node: parent, key: 'parent' }) }) === 'JSXAttribute';\n return isJsxProp || isLibraryArgument({ node, parent });\n };\n\n const isInjectedConstructor = (opts: { node: Rule.Node; params: unknown[] }) => {\n const parent = opts.node.parent;\n const isDecorated = (param: unknown) => {\n const own = readField({ node: param, key: 'decorators' });\n const property = readField({\n node: readField({ node: param, key: 'parameter' }),\n key: 'decorators',\n });\n return (\n (Array.isArray(own) && own.length > 0) ||\n (Array.isArray(property) && property.length > 0)\n );\n };\n\n return (\n nodeType({ node: parent }) === 'MethodDefinition' &&\n readField({ node: parent, key: 'kind' }) === 'constructor' &&\n opts.params.every(isDecorated)\n );\n };\n\n const isTypedByContext = (node: Rule.Node) => {\n const parent = node.parent;\n const parentType = nodeType({ node: parent });\n const isTypedInit =\n parentType === 'VariableDeclarator' &&\n readField({ node: parent, key: 'init' }) === node &&\n Boolean(\n readField({ node: readField({ node: parent, key: 'id' }), key: 'typeAnnotation' }),\n );\n const grandParent = readField({ node: parent, key: 'parent' });\n const isMember =\n parentType === 'Property' &&\n readField({ node: parent, key: 'value' }) === node &&\n nodeType({ node: grandParent }) === 'ObjectExpression';\n\n return isTypedInit || (isMember && hasDeclaredShape(grandParent));\n };\n\n const check = (node: Rule.Node) => {\n const params = readField({ node, key: 'params' });\n if (!Array.isArray(params) || params.length <= max) {\n return;\n }\n\n if (isCallback(node) || isInjectedConstructor({ node, params }) || isTypedByContext(node)) {\n return;\n }\n\n context.report({\n node,\n messageId: 'tooMany',\n data: { count: String(params.length), max: String(max) },\n });\n };\n\n return {\n [AstNodeTypes.FUNCTION_DECLARATION]: check,\n [AstNodeTypes.FUNCTION_EXPRESSION]: check,\n [AstNodeTypes.ARROW_FUNCTION_EXPRESSION]: check,\n };\n },\n };\n\n static build(opts: { severity?: TRuleSeverity; max?: number } = {}): Linter.RuleEntry {\n const { severity = 'error', max = MaxParamsOwnRule.DEFAULT_MAX } = opts;\n return [severity, max];\n }\n}\n"]}
|
|
@@ -4,7 +4,7 @@ exports.NoLeakedRenderRule = void 0;
|
|
|
4
4
|
const common_1 = require("./common");
|
|
5
5
|
/** `&&` directly under a JSX child: `disabled={a && b}` is a value, not something drawn. */
|
|
6
6
|
const LEAKED_RENDER_SELECTOR = ['JSXElement', 'JSXFragment']
|
|
7
|
-
.map(parent => `${parent} > JSXExpressionContainer > LogicalExpression[operator='&&']`)
|
|
7
|
+
.map((parent) => `${parent} > JSXExpressionContainer > LogicalExpression[operator='&&']`)
|
|
8
8
|
.join(', ');
|
|
9
9
|
/**
|
|
10
10
|
* `venizia/no-leaked-render`. `{count && <X />}` draws `0` when `count` is `0`; draw nothing with
|
|
@@ -22,13 +22,13 @@ class NoLeakedRenderRule {
|
|
|
22
22
|
leaked: 'Draw nothing with `cond ? <X /> : null`; `&&` draws 0 when cond is 0.',
|
|
23
23
|
},
|
|
24
24
|
},
|
|
25
|
-
create: context => ({
|
|
25
|
+
create: (context) => ({
|
|
26
26
|
[LEAKED_RENDER_SELECTOR]: (node) => {
|
|
27
27
|
if (node.type !== 'LogicalExpression') {
|
|
28
28
|
return;
|
|
29
29
|
}
|
|
30
30
|
const source = context.sourceCode;
|
|
31
|
-
const operator = source.getTokenAfter(node.left, token => token.value === '&&');
|
|
31
|
+
const operator = source.getTokenAfter(node.left, (token) => token.value === '&&');
|
|
32
32
|
if (!operator) {
|
|
33
33
|
return;
|
|
34
34
|
}
|
|
@@ -36,7 +36,7 @@ class NoLeakedRenderRule {
|
|
|
36
36
|
context.report({
|
|
37
37
|
node,
|
|
38
38
|
messageId: 'leaked',
|
|
39
|
-
fix: fixer => fixer.replaceText(node, `${source.getText(node.left)} ? ${drawn} : null`),
|
|
39
|
+
fix: (fixer) => fixer.replaceText(node, `${source.getText(node.left)} ? ${drawn} : null`),
|
|
40
40
|
});
|
|
41
41
|
},
|
|
42
42
|
}),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"no-leaked-render.rule.js","sourceRoot":"","sources":["../../../src/linters/house/no-leaked-render.rule.ts"],"names":[],"mappings":";;;AAEA,qCAAkD;AAElD,4FAA4F;AAC5F,MAAM,sBAAsB,GAAG,CAAC,YAAY,EAAE,aAAa,CAAC;KACzD,GAAG,CAAC,MAAM,
|
|
1
|
+
{"version":3,"file":"no-leaked-render.rule.js","sourceRoot":"","sources":["../../../src/linters/house/no-leaked-render.rule.ts"],"names":[],"mappings":";;;AAEA,qCAAkD;AAElD,4FAA4F;AAC5F,MAAM,sBAAsB,GAAG,CAAC,YAAY,EAAE,aAAa,CAAC;KACzD,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,GAAG,MAAM,8DAA8D,CAAC;KACxF,IAAI,CAAC,IAAI,CAAC,CAAC;AAEd;;;;GAIG;AACH,MAAa,kBAAkB;aACb,SAAI,GAAG,GAAG,+BAAsB,mBAAmB,CAAC;aAEpD,SAAI,GAAoB;QACtC,IAAI,EAAE;YACJ,IAAI,EAAE,SAAS;YACf,OAAO,EAAE,MAAM;YACf,MAAM,EAAE,EAAE;YACV,QAAQ,EAAE;gBACR,MAAM,EAAE,uEAAuE;aAChF;SACF;QACD,MAAM,EAAE,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC;YACpB,CAAC,sBAAsB,CAAC,EAAE,CAAC,IAAe,EAAE,EAAE;gBAC5C,IAAI,IAAI,CAAC,IAAI,KAAK,mBAAmB,EAAE,CAAC;oBACtC,OAAO;gBACT,CAAC;gBAED,MAAM,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC;gBAClC,MAAM,QAAQ,GAAG,MAAM,CAAC,aAAa,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,KAAK,KAAK,IAAI,CAAC,CAAC;gBAClF,IAAI,CAAC,QAAQ,EAAE,CAAC;oBACd,OAAO;gBACT,CAAC;gBAED,MAAM,KAAK,GAAG,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;gBAC3E,OAAO,CAAC,MAAM,CAAC;oBACb,IAAI;oBACJ,SAAS,EAAE,QAAQ;oBACnB,GAAG,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,WAAW,CAAC,IAAI,EAAE,GAAG,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,KAAK,SAAS,CAAC;iBAC1F,CAAC,CAAC;YACL,CAAC;SACF,CAAC;KACH,CAAC;IAEF,MAAM,CAAC,KAAK,CAAC,OAAqC,EAAE;QAClD,OAAO,IAAI,CAAC,QAAQ,IAAI,OAAO,CAAC;IAClC,CAAC;;AApCH,gDAqCC","sourcesContent":["import type { Rule } from 'eslint';\nimport type { TRuleSeverity } from '../rules/common';\nimport { HOUSE_PLUGIN_NAMESPACE } from './common';\n\n/** `&&` directly under a JSX child: `disabled={a && b}` is a value, not something drawn. */\nconst LEAKED_RENDER_SELECTOR = ['JSXElement', 'JSXFragment']\n .map((parent) => `${parent} > JSXExpressionContainer > LogicalExpression[operator='&&']`)\n .join(', ');\n\n/**\n * `venizia/no-leaked-render`. `{count && <X />}` draws `0` when `count` is `0`; draw nothing with\n * `cond ? <X /> : null`. Only a child of JSX is checked. The fix rewrites it to the ternary and keeps\n * any comment between `&&` and the drawn part.\n */\nexport class NoLeakedRenderRule {\n static readonly NAME = `${HOUSE_PLUGIN_NAMESPACE}/no-leaked-render`;\n\n static readonly RULE: Rule.RuleModule = {\n meta: {\n type: 'problem',\n fixable: 'code',\n schema: [],\n messages: {\n leaked: 'Draw nothing with `cond ? <X /> : null`; `&&` draws 0 when cond is 0.',\n },\n },\n create: (context) => ({\n [LEAKED_RENDER_SELECTOR]: (node: Rule.Node) => {\n if (node.type !== 'LogicalExpression') {\n return;\n }\n\n const source = context.sourceCode;\n const operator = source.getTokenAfter(node.left, (token) => token.value === '&&');\n if (!operator) {\n return;\n }\n\n const drawn = source.text.slice(operator.range[1], node.range?.[1]).trim();\n context.report({\n node,\n messageId: 'leaked',\n fix: (fixer) => fixer.replaceText(node, `${source.getText(node.left)} ? ${drawn} : null`),\n });\n },\n }),\n };\n\n static build(opts: { severity?: TRuleSeverity } = {}): TRuleSeverity {\n return opts.severity ?? 'error';\n }\n}\n"]}
|
|
@@ -17,7 +17,7 @@ class NoNewErrorRule {
|
|
|
17
17
|
newError: 'Throw through getError({ message }) (or an ApplicationError), not `{{form}}`: only an ApplicationError carries the status, code and args.',
|
|
18
18
|
},
|
|
19
19
|
},
|
|
20
|
-
create: context => {
|
|
20
|
+
create: (context) => {
|
|
21
21
|
const report = (opts) => context.report({ node: opts.node, messageId: 'newError', data: { form: opts.form } });
|
|
22
22
|
const isErrorIdentifier = (callee) => (0, common_1.nodeType)({ node: callee }) === 'Identifier' &&
|
|
23
23
|
(0, common_1.readField)({ node: callee, key: 'name' }) === 'Error';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"no-new-error.rule.js","sourceRoot":"","sources":["../../../src/linters/house/no-new-error.rule.ts"],"names":[],"mappings":";;;AAEA,qCAAqF;AAErF;;;;GAIG;AACH,MAAa,cAAc;aACT,SAAI,GAAG,GAAG,+BAAsB,eAAe,CAAC;aAEhD,SAAI,GAAoB;QACtC,IAAI,EAAE;YACJ,IAAI,EAAE,SAAS;YACf,MAAM,EAAE,EAAE;YACV,QAAQ,EAAE;gBACR,QAAQ,EACN,2IAA2I;aAC9I;SACF;QACD,MAAM,EAAE,OAAO,
|
|
1
|
+
{"version":3,"file":"no-new-error.rule.js","sourceRoot":"","sources":["../../../src/linters/house/no-new-error.rule.ts"],"names":[],"mappings":";;;AAEA,qCAAqF;AAErF;;;;GAIG;AACH,MAAa,cAAc;aACT,SAAI,GAAG,GAAG,+BAAsB,eAAe,CAAC;aAEhD,SAAI,GAAoB;QACtC,IAAI,EAAE;YACJ,IAAI,EAAE,SAAS;YACf,MAAM,EAAE,EAAE;YACV,QAAQ,EAAE;gBACR,QAAQ,EACN,2IAA2I;aAC9I;SACF;QACD,MAAM,EAAE,CAAC,OAAO,EAAE,EAAE;YAClB,MAAM,MAAM,GAAG,CAAC,IAAuC,EAAE,EAAE,CACzD,OAAO,CAAC,MAAM,CAAC,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,SAAS,EAAE,UAAU,EAAE,IAAI,EAAE,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;YAExF,MAAM,iBAAiB,GAAG,CAAC,MAAe,EAAE,EAAE,CAC5C,IAAA,iBAAQ,EAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC,KAAK,YAAY;gBAC3C,IAAA,kBAAS,EAAC,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,CAAC,KAAK,OAAO,CAAC;YAEvD,OAAO;gBACL,CAAC,qBAAY,CAAC,cAAc,CAAC,EAAE,CAAC,IAAe,EAAE,EAAE;oBACjD,IAAI,iBAAiB,CAAC,IAAA,kBAAS,EAAC,EAAE,IAAI,EAAE,GAAG,EAAE,QAAQ,EAAE,CAAC,CAAC,EAAE,CAAC;wBAC1D,MAAM,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,gBAAgB,EAAE,CAAC,CAAC;oBAC3C,CAAC;gBACH,CAAC;gBACD,CAAC,qBAAY,CAAC,eAAe,CAAC,EAAE,CAAC,IAAe,EAAE,EAAE;oBAClD,IAAI,iBAAiB,CAAC,IAAA,kBAAS,EAAC,EAAE,IAAI,EAAE,GAAG,EAAE,QAAQ,EAAE,CAAC,CAAC,EAAE,CAAC;wBAC1D,MAAM,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,YAAY,EAAE,CAAC,CAAC;oBACvC,CAAC;gBACH,CAAC;aACF,CAAC;QACJ,CAAC;KACF,CAAC;IAEF,MAAM,CAAC,KAAK,CAAC,OAAqC,EAAE;QAClD,OAAO,IAAI,CAAC,QAAQ,IAAI,OAAO,CAAC;IAClC,CAAC;;AArCH,wCAsCC","sourcesContent":["import type { Rule } from 'eslint';\nimport type { TRuleSeverity } from '../rules/common';\nimport { AstNodeTypes, HOUSE_PLUGIN_NAMESPACE, nodeType, readField } from './common';\n\n/**\n * `venizia/no-new-error`. An error is thrown through `getError({ message })` (or an `ApplicationError`),\n * never `new Error(...)` or `Error(...)`: only an ApplicationError carries the status, the message code and\n * args, and the `extra` every IGNIS layer reads.\n */\nexport class NoNewErrorRule {\n static readonly NAME = `${HOUSE_PLUGIN_NAMESPACE}/no-new-error`;\n\n static readonly RULE: Rule.RuleModule = {\n meta: {\n type: 'problem',\n schema: [],\n messages: {\n newError:\n 'Throw through getError({ message }) (or an ApplicationError), not `{{form}}`: only an ApplicationError carries the status, code and args.',\n },\n },\n create: (context) => {\n const report = (opts: { node: Rule.Node; form: string }) =>\n context.report({ node: opts.node, messageId: 'newError', data: { form: opts.form } });\n\n const isErrorIdentifier = (callee: unknown) =>\n nodeType({ node: callee }) === 'Identifier' &&\n readField({ node: callee, key: 'name' }) === 'Error';\n\n return {\n [AstNodeTypes.NEW_EXPRESSION]: (node: Rule.Node) => {\n if (isErrorIdentifier(readField({ node, key: 'callee' }))) {\n report({ node, form: 'new Error(...)' });\n }\n },\n [AstNodeTypes.CALL_EXPRESSION]: (node: Rule.Node) => {\n if (isErrorIdentifier(readField({ node, key: 'callee' }))) {\n report({ node, form: 'Error(...)' });\n }\n },\n };\n },\n };\n\n static build(opts: { severity?: TRuleSeverity } = {}): TRuleSeverity {\n return opts.severity ?? 'error';\n }\n}\n"]}
|
package/dist/linters/ignore.js
CHANGED
|
@@ -31,15 +31,15 @@ class LintIgnore {
|
|
|
31
31
|
}
|
|
32
32
|
const rules = new Set([
|
|
33
33
|
...Object.keys(config.rules ?? {}),
|
|
34
|
-
...(config.overrides ?? []).flatMap(override => Object.keys(override.rules ?? {})),
|
|
34
|
+
...(config.overrides ?? []).flatMap((override) => Object.keys(override.rules ?? {})),
|
|
35
35
|
]);
|
|
36
36
|
return {
|
|
37
37
|
...config,
|
|
38
38
|
overrides: [
|
|
39
39
|
...(config.overrides ?? []),
|
|
40
40
|
{
|
|
41
|
-
files: patterns.map(pattern => LintIgnore.toGlob({ pattern })),
|
|
42
|
-
rules: Object.fromEntries([...rules].map(name => [name, 'off'])),
|
|
41
|
+
files: patterns.map((pattern) => LintIgnore.toGlob({ pattern })),
|
|
42
|
+
rules: Object.fromEntries([...rules].map((name) => [name, 'off'])),
|
|
43
43
|
},
|
|
44
44
|
],
|
|
45
45
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ignore.js","sourceRoot":"","sources":["../../src/linters/ignore.ts"],"names":[],"mappings":";;;AAGA;;;;;;;;;;;;;GAaG;AACH,MAAa,UAAU;IACrB,+GAA+G;IAC/G,MAAM,CAAC,MAAM,CAAC,IAAyB;QACrC,MAAM,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC;QACnD,OAAO,OAAO,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC,C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,OAAO,MAAM,CAAC;QAChB,CAAC;QAED,MAAM,KAAK,GAAG,IAAI,GAAG,CAAC;YACpB,GAAG,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,IAAI,EAAE,CAAC;YAClC,GAAG,CAAC,MAAM,CAAC,SAAS,IAAI,EAAE,CAAC,CAAC,OAAO,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,KAAK,IAAI,EAAE,CAAC,CAAC;SACrF,CAAC,CAAC;QAEH,OAAO;YACL,GAAG,MAAM;YACT,SAAS,EAAE;gBACT,GAAG,CAAC,MAAM,CAAC,SAAS,IAAI,EAAE,CAAC;gBAC3B;oBACE,KAAK,EAAE,QAAQ,CAAC,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,UAAU,CAAC,MAAM,CAAC,EAAE,OAAO,EAAE,CAAC,CAAC;oBAChE,KAAK,EAAE,MAAM,CAAC,WAAW,CAAC,CAAC,GAAG,KAAK,CAAC,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC,CAAC;iBACnE;aACF;SACF,CAAC;IACJ,CAAC;CACF;AAjCD,gCAiCC","sourcesContent":["import type { Linter } from 'eslint';\nimport type { OxlintConfig } from 'oxlint';\n\n/**\n * Project paths a lint run skips: generated files, vendored code, bundles. The same list feeds both\n * tools, because each reads it differently.\n *\n * - oxlint: `ignorePatterns` resolve against the folder of the config file, so one in `.configs/` can\n * never name a project path. `LintIgnore.oxlint` turns every rule off for the paths instead.\n * - ESLint: `LintIgnore.eslint` is a flat-config `ignores` entry, relative to where eslint runs.\n *\n * ```ts\n * const LINT_IGNORE = ['src/components/shadcn/**', 'dev-dist/**'];\n * defineConfig(ReactOxlintConfigs.create({ ignore: LINT_IGNORE })); // oxlint.config.mts\n * export default [LintIgnore.eslint({ patterns: LINT_IGNORE }), ...reactHouseConfigs]; // eslint.config.mjs\n * ```\n */\nexport class LintIgnore {\n /** A project path such as `src/gen/**`, as an override glob: it is matched from anywhere under the project. */\n static toGlob(opts: { pattern: string }): string {\n const pattern = opts.pattern.replace(/^\\.?\\//, '');\n return pattern.startsWith('**/') ? pattern : `**/${pattern}`;\n }\n\n static eslint(opts: { patterns: string[] }): Linter.Config {\n return { ignores: opts.patterns };\n }\n\n static oxlint(opts: { config: OxlintConfig; patterns: string[] }): OxlintConfig {\n const { config, patterns } = opts;\n if (patterns.length === 0) {\n return config;\n }\n\n const rules = new Set([\n ...Object.keys(config.rules ?? {}),\n ...(config.overrides ?? []).flatMap((override) => Object.keys(override.rules ?? {})),\n ]);\n\n return {\n ...config,\n overrides: [\n ...(config.overrides ?? []),\n {\n files: patterns.map((pattern) => LintIgnore.toGlob({ pattern })),\n rules: Object.fromEntries([...rules].map((name) => [name, 'off'])),\n },\n ],\n };\n }\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@venizia/dev-configs",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "Shareable development configurations for TypeScript projects: oxlint
|
|
3
|
+
"version": "0.4.1",
|
|
4
|
+
"description": "Shareable development configurations for TypeScript projects: oxlint presets with per-rule builders, the ESLint naming-convention rule, the legacy ESLint flat config, and TypeScript compiler options with critical decorator support (experimentalDecorators, emitDecoratorMetadata, useDefineForClassFields). Single source of truth for consistent code style, type checking, and build settings across monorepo packages.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"build-tools",
|
|
7
7
|
"bun",
|
|
@@ -29,10 +29,7 @@
|
|
|
29
29
|
"monorepo",
|
|
30
30
|
"monorepo-config",
|
|
31
31
|
"nodejs",
|
|
32
|
-
"oxfmt",
|
|
33
32
|
"oxlint",
|
|
34
|
-
"prettier",
|
|
35
|
-
"prettier-config",
|
|
36
33
|
"settings",
|
|
37
34
|
"shareable-config",
|
|
38
35
|
"shared-config",
|
|
@@ -44,26 +41,31 @@
|
|
|
44
41
|
"venizia"
|
|
45
42
|
],
|
|
46
43
|
"homepage": "https://ignis.venizia.ai",
|
|
47
|
-
"repository": {
|
|
48
|
-
"type": "git",
|
|
49
|
-
"url": "git+https://github.com/VENIZIA-AI/ignis.git",
|
|
50
|
-
"directory": "packages/dev-configs"
|
|
51
|
-
},
|
|
52
44
|
"bugs": {
|
|
53
45
|
"url": "https://github.com/VENIZIA-AI/ignis/issues"
|
|
54
46
|
},
|
|
47
|
+
"license": "MIT",
|
|
55
48
|
"author": {
|
|
56
49
|
"name": "VENIZIA AI Developer",
|
|
57
50
|
"email": "developer@venizia.ai",
|
|
58
51
|
"url": "https://venizia.ai"
|
|
59
52
|
},
|
|
60
|
-
"
|
|
53
|
+
"repository": {
|
|
54
|
+
"type": "git",
|
|
55
|
+
"url": "git+https://github.com/VENIZIA-AI/ignis.git",
|
|
56
|
+
"directory": "packages/dev-configs"
|
|
57
|
+
},
|
|
61
58
|
"bin": {
|
|
62
59
|
"devz": "./dist/cli/index.js"
|
|
63
60
|
},
|
|
64
|
-
"
|
|
65
|
-
"
|
|
66
|
-
|
|
61
|
+
"files": [
|
|
62
|
+
"README.md",
|
|
63
|
+
"LICENSE.md",
|
|
64
|
+
"dist",
|
|
65
|
+
"src/tsconfig",
|
|
66
|
+
"!**/__tests__",
|
|
67
|
+
"!**/*.tsbuildinfo"
|
|
68
|
+
],
|
|
67
69
|
"exports": {
|
|
68
70
|
".": {
|
|
69
71
|
"types": "./dist/index.d.ts",
|
|
@@ -73,10 +75,6 @@
|
|
|
73
75
|
"types": "./dist/compilers/index.d.ts",
|
|
74
76
|
"default": "./dist/compilers/index.js"
|
|
75
77
|
},
|
|
76
|
-
"./formatters": {
|
|
77
|
-
"types": "./dist/formatters/index.d.ts",
|
|
78
|
-
"default": "./dist/formatters/index.js"
|
|
79
|
-
},
|
|
80
78
|
"./linters": {
|
|
81
79
|
"types": "./dist/linters/index.d.ts",
|
|
82
80
|
"default": "./dist/linters/index.js"
|
|
@@ -95,64 +93,47 @@
|
|
|
95
93
|
"./tsconfig.react.json": "./src/tsconfig/tsconfig.react.json",
|
|
96
94
|
"./package.json": "./package.json"
|
|
97
95
|
},
|
|
98
|
-
"files": [
|
|
99
|
-
"README.md",
|
|
100
|
-
"LICENSE.md",
|
|
101
|
-
"dist",
|
|
102
|
-
"src/tsconfig",
|
|
103
|
-
"!**/__tests__",
|
|
104
|
-
"!**/*.tsbuildinfo"
|
|
105
|
-
],
|
|
106
96
|
"publishConfig": {
|
|
107
97
|
"access": "public"
|
|
108
98
|
},
|
|
109
99
|
"scripts": {
|
|
110
|
-
"force-update": "sh ../../scripts/force-update.sh",
|
|
100
|
+
"force-update": "sh ../../scripts/build/force-update.sh",
|
|
111
101
|
"prepublishOnly": "make rebuild"
|
|
112
102
|
},
|
|
113
103
|
"dependencies": {
|
|
114
104
|
"@eslint/js": "^10.0.1",
|
|
115
|
-
"eslint-config-prettier": "^10.1.8",
|
|
116
105
|
"eslint-plugin-n": "^18.5.0",
|
|
117
|
-
"eslint-plugin-prettier": "^5.5.7",
|
|
118
106
|
"eslint-plugin-unicorn": "^78.0.0",
|
|
119
107
|
"typescript-eslint": "^8.72.0"
|
|
120
108
|
},
|
|
109
|
+
"devDependencies": {
|
|
110
|
+
"@types/bun": "^1.4.3",
|
|
111
|
+
"eslint": "^10.13.0",
|
|
112
|
+
"oxlint": "1.89.0",
|
|
113
|
+
"oxlint-tsgolint": "7.0.2004",
|
|
114
|
+
"typescript": "^6.0.3"
|
|
115
|
+
},
|
|
121
116
|
"peerDependencies": {
|
|
122
117
|
"eslint": "^9.0.0 || ^10.0.0",
|
|
123
|
-
"oxfmt": ">=0.74.0",
|
|
124
118
|
"oxlint": ">=1.89.0",
|
|
125
119
|
"oxlint-tsgolint": ">=7.0.2004",
|
|
126
|
-
"prettier": "^3.9.10",
|
|
127
120
|
"typescript": "^5.0.0 || ^6.0.0"
|
|
128
121
|
},
|
|
129
122
|
"peerDependenciesMeta": {
|
|
130
123
|
"eslint": {
|
|
131
124
|
"optional": true
|
|
132
125
|
},
|
|
133
|
-
"oxfmt": {
|
|
134
|
-
"optional": true
|
|
135
|
-
},
|
|
136
126
|
"oxlint": {
|
|
137
127
|
"optional": true
|
|
138
128
|
},
|
|
139
129
|
"oxlint-tsgolint": {
|
|
140
130
|
"optional": true
|
|
141
131
|
},
|
|
142
|
-
"prettier": {
|
|
143
|
-
"optional": true
|
|
144
|
-
},
|
|
145
132
|
"typescript": {
|
|
146
133
|
"optional": true
|
|
147
134
|
}
|
|
148
135
|
},
|
|
149
|
-
"
|
|
150
|
-
"
|
|
151
|
-
"eslint": "^10.13.0",
|
|
152
|
-
"oxfmt": "0.74.0",
|
|
153
|
-
"oxlint": "1.89.0",
|
|
154
|
-
"oxlint-tsgolint": "7.0.2004",
|
|
155
|
-
"prettier": "^3.9.10",
|
|
156
|
-
"typescript": "^6.0.3"
|
|
136
|
+
"engines": {
|
|
137
|
+
"bun": ">=1.4.4"
|
|
157
138
|
}
|
|
158
139
|
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/formatters/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC;AACxB,cAAc,YAAY,CAAC"}
|
package/dist/formatters/index.js
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./oxfmt"), exports);
|
|
18
|
-
__exportStar(require("./prettier"), exports);
|
|
19
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/formatters/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,0CAAwB;AACxB,6CAA2B","sourcesContent":["export * from './oxfmt';\nexport * from './prettier';\n"]}
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import type { OxfmtConfig } from 'oxfmt';
|
|
2
|
-
/**
|
|
3
|
-
* The oxfmt port of `prettierConfigs` - the same seven options, so the output matches Prettier's.
|
|
4
|
-
*
|
|
5
|
-
* ```ts
|
|
6
|
-
* // .configs/formatters/oxfmt.config.mts
|
|
7
|
-
* import { defineConfig } from 'oxfmt';
|
|
8
|
-
* import { oxfmtConfigs } from '@venizia/dev-configs/formatters';
|
|
9
|
-
*
|
|
10
|
-
* export default defineConfig(oxfmtConfigs);
|
|
11
|
-
* ```
|
|
12
|
-
*/
|
|
13
|
-
export declare const oxfmtConfigs: OxfmtConfig;
|
|
14
|
-
/**
|
|
15
|
-
* `oxfmtConfigs` for browser and React code: arrow parameters always in parentheses (`(x) => x`),
|
|
16
|
-
* and the closing `>` of a multi-line JSX element on its last attribute line, which keeps JSX diffs
|
|
17
|
-
* small. `bracketSameLine` changes nothing outside JSX.
|
|
18
|
-
*
|
|
19
|
-
* ```ts
|
|
20
|
-
* // .configs/formatters/oxfmt.config.mts
|
|
21
|
-
* import { defineConfig } from 'oxfmt';
|
|
22
|
-
* import { browserOxfmtConfigs } from '@venizia/dev-configs/formatters';
|
|
23
|
-
*
|
|
24
|
-
* export default defineConfig(browserOxfmtConfigs);
|
|
25
|
-
* ```
|
|
26
|
-
*/
|
|
27
|
-
export declare const browserOxfmtConfigs: OxfmtConfig;
|
|
28
|
-
//# sourceMappingURL=oxfmt.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"oxfmt.d.ts","sourceRoot":"","sources":["../../src/formatters/oxfmt.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,OAAO,CAAC;AAEzC;;;;;;;;;;GAUG;AACH,eAAO,MAAM,YAAY,EAAE,WAQ1B,CAAC;AAEF;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,mBAAmB,EAAE,WAIjC,CAAC"}
|
package/dist/formatters/oxfmt.js
DELETED
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.browserOxfmtConfigs = exports.oxfmtConfigs = void 0;
|
|
4
|
-
/**
|
|
5
|
-
* The oxfmt port of `prettierConfigs` - the same seven options, so the output matches Prettier's.
|
|
6
|
-
*
|
|
7
|
-
* ```ts
|
|
8
|
-
* // .configs/formatters/oxfmt.config.mts
|
|
9
|
-
* import { defineConfig } from 'oxfmt';
|
|
10
|
-
* import { oxfmtConfigs } from '@venizia/dev-configs/formatters';
|
|
11
|
-
*
|
|
12
|
-
* export default defineConfig(oxfmtConfigs);
|
|
13
|
-
* ```
|
|
14
|
-
*/
|
|
15
|
-
exports.oxfmtConfigs = {
|
|
16
|
-
bracketSpacing: true,
|
|
17
|
-
singleQuote: true,
|
|
18
|
-
printWidth: 100,
|
|
19
|
-
tabWidth: 2,
|
|
20
|
-
trailingComma: 'all',
|
|
21
|
-
arrowParens: 'avoid',
|
|
22
|
-
semi: true,
|
|
23
|
-
};
|
|
24
|
-
/**
|
|
25
|
-
* `oxfmtConfigs` for browser and React code: arrow parameters always in parentheses (`(x) => x`),
|
|
26
|
-
* and the closing `>` of a multi-line JSX element on its last attribute line, which keeps JSX diffs
|
|
27
|
-
* small. `bracketSameLine` changes nothing outside JSX.
|
|
28
|
-
*
|
|
29
|
-
* ```ts
|
|
30
|
-
* // .configs/formatters/oxfmt.config.mts
|
|
31
|
-
* import { defineConfig } from 'oxfmt';
|
|
32
|
-
* import { browserOxfmtConfigs } from '@venizia/dev-configs/formatters';
|
|
33
|
-
*
|
|
34
|
-
* export default defineConfig(browserOxfmtConfigs);
|
|
35
|
-
* ```
|
|
36
|
-
*/
|
|
37
|
-
exports.browserOxfmtConfigs = {
|
|
38
|
-
...exports.oxfmtConfigs,
|
|
39
|
-
arrowParens: 'always',
|
|
40
|
-
bracketSameLine: true,
|
|
41
|
-
};
|
|
42
|
-
//# sourceMappingURL=oxfmt.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"oxfmt.js","sourceRoot":"","sources":["../../src/formatters/oxfmt.ts"],"names":[],"mappings":";;;AAEA;;;;;;;;;;GAUG;AACU,QAAA,YAAY,GAAgB;IACvC,cAAc,EAAE,IAAI;IACpB,WAAW,EAAE,IAAI;IACjB,UAAU,EAAE,GAAG;IACf,QAAQ,EAAE,CAAC;IACX,aAAa,EAAE,KAAK;IACpB,WAAW,EAAE,OAAO;IACpB,IAAI,EAAE,IAAI;CACX,CAAC;AAEF;;;;;;;;;;;;GAYG;AACU,QAAA,mBAAmB,GAAgB;IAC9C,GAAG,oBAAY;IACf,WAAW,EAAE,QAAQ;IACrB,eAAe,EAAE,IAAI;CACtB,CAAC","sourcesContent":["import type { OxfmtConfig } from 'oxfmt';\n\n/**\n * The oxfmt port of `prettierConfigs` - the same seven options, so the output matches Prettier's.\n *\n * ```ts\n * // .configs/formatters/oxfmt.config.mts\n * import { defineConfig } from 'oxfmt';\n * import { oxfmtConfigs } from '@venizia/dev-configs/formatters';\n *\n * export default defineConfig(oxfmtConfigs);\n * ```\n */\nexport const oxfmtConfigs: OxfmtConfig = {\n bracketSpacing: true,\n singleQuote: true,\n printWidth: 100,\n tabWidth: 2,\n trailingComma: 'all',\n arrowParens: 'avoid',\n semi: true,\n};\n\n/**\n * `oxfmtConfigs` for browser and React code: arrow parameters always in parentheses (`(x) => x`),\n * and the closing `>` of a multi-line JSX element on its last attribute line, which keeps JSX diffs\n * small. `bracketSameLine` changes nothing outside JSX.\n *\n * ```ts\n * // .configs/formatters/oxfmt.config.mts\n * import { defineConfig } from 'oxfmt';\n * import { browserOxfmtConfigs } from '@venizia/dev-configs/formatters';\n *\n * export default defineConfig(browserOxfmtConfigs);\n * ```\n */\nexport const browserOxfmtConfigs: OxfmtConfig = {\n ...oxfmtConfigs,\n arrowParens: 'always',\n bracketSameLine: true,\n};\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"prettier.d.ts","sourceRoot":"","sources":["../../src/formatters/prettier.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAEvC,eAAO,MAAM,eAAe,EAAE,MAQ7B,CAAC"}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.prettierConfigs = void 0;
|
|
4
|
-
exports.prettierConfigs = {
|
|
5
|
-
bracketSpacing: true,
|
|
6
|
-
singleQuote: true,
|
|
7
|
-
printWidth: 100,
|
|
8
|
-
tabWidth: 2,
|
|
9
|
-
trailingComma: 'all',
|
|
10
|
-
arrowParens: 'avoid',
|
|
11
|
-
semi: true,
|
|
12
|
-
};
|
|
13
|
-
//# sourceMappingURL=prettier.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"prettier.js","sourceRoot":"","sources":["../../src/formatters/prettier.ts"],"names":[],"mappings":";;;AAEa,QAAA,eAAe,GAAW;IACrC,cAAc,EAAE,IAAI;IACpB,WAAW,EAAE,IAAI;IACjB,UAAU,EAAE,GAAG;IACf,QAAQ,EAAE,CAAC;IACX,aAAa,EAAE,KAAK;IACpB,WAAW,EAAE,OAAO;IACpB,IAAI,EAAE,IAAI;CACX,CAAC","sourcesContent":["import type { Config } from 'prettier';\n\nexport const prettierConfigs: Config = {\n bracketSpacing: true,\n singleQuote: true,\n printWidth: 100,\n tabWidth: 2,\n trailingComma: 'all',\n arrowParens: 'avoid',\n semi: true,\n};\n"]}
|