@alint-js/core 0.0.9 → 0.0.11
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 +78 -0
- package/dist/index.mjs +1 -1
- package/package.json +1 -1
package/README.md
ADDED
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
# `@alint-js/core`
|
|
2
|
+
|
|
3
|
+
The public SDK and run engine for `alint`.
|
|
4
|
+
|
|
5
|
+
## What it does
|
|
6
|
+
|
|
7
|
+
This package provides the core APIs used by configs, plugins, rules, language processors, and agent adapters:
|
|
8
|
+
|
|
9
|
+
- `defineConfig`, `definePlugin`, and `defineRule`
|
|
10
|
+
- rule registry and flat config normalization
|
|
11
|
+
- source runtime helpers
|
|
12
|
+
- built-in JavaScript source extraction
|
|
13
|
+
- model resolution by size and capability
|
|
14
|
+
- diagnostics and progress payload types
|
|
15
|
+
- `runAlint`
|
|
16
|
+
- framework-neutral agent contracts under `@alint-js/core/agent`
|
|
17
|
+
|
|
18
|
+
## How to use
|
|
19
|
+
|
|
20
|
+
Define an `alint` config:
|
|
21
|
+
|
|
22
|
+
```ts
|
|
23
|
+
import examplePlugin from '@alint-js/plugin-example'
|
|
24
|
+
|
|
25
|
+
import { defineConfig } from '@alint-js/core'
|
|
26
|
+
|
|
27
|
+
export default defineConfig([
|
|
28
|
+
{
|
|
29
|
+
files: ['**/*.{js,ts,jsx,tsx}'],
|
|
30
|
+
plugins: {
|
|
31
|
+
example: examplePlugin,
|
|
32
|
+
},
|
|
33
|
+
rules: {
|
|
34
|
+
'example/no-redundant-jsdoc': 'warn',
|
|
35
|
+
},
|
|
36
|
+
},
|
|
37
|
+
])
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
Write a rule:
|
|
41
|
+
|
|
42
|
+
```ts
|
|
43
|
+
import { defineRule } from '@alint-js/core'
|
|
44
|
+
|
|
45
|
+
export const rule = defineRule({
|
|
46
|
+
create: ctx => ({
|
|
47
|
+
async onTarget(target) {
|
|
48
|
+
const model = await ctx.model({ size: 'small' })
|
|
49
|
+
|
|
50
|
+
ctx.report({
|
|
51
|
+
filePath: target.file.path,
|
|
52
|
+
loc: target.loc,
|
|
53
|
+
message: `reviewed with ${model.id}`,
|
|
54
|
+
})
|
|
55
|
+
},
|
|
56
|
+
}),
|
|
57
|
+
})
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
Use the agent contract for tool-using rules:
|
|
61
|
+
|
|
62
|
+
```ts
|
|
63
|
+
import { requireAgent } from '@alint-js/core/agent'
|
|
64
|
+
|
|
65
|
+
const agent = requireAgent(ctx)
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
## When to use
|
|
69
|
+
|
|
70
|
+
- You are writing an `alint` plugin or rule package.
|
|
71
|
+
- You are adding a language processor or source extractor.
|
|
72
|
+
- You are embedding `alint` in another tool.
|
|
73
|
+
- You are implementing an `AgentAdapter`.
|
|
74
|
+
|
|
75
|
+
## When not to use
|
|
76
|
+
|
|
77
|
+
- Use `@alint-js/cli` for command-line usage.
|
|
78
|
+
- Use `@alint-js/config` for setup TOML and config-file helpers only.
|
package/dist/index.mjs
CHANGED