@lanelint/core 0.0.0-stage → 0.0.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 ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Anton Ödman
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,81 @@
1
- # Temporary Holding Version
1
+ # @lanelint/core
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ [![npm](https://img.shields.io/npm/v/@lanelint/core)](https://www.npmjs.com/package/@lanelint/core)
4
+
5
+ The engine and rule API behind [lanelint](https://github.com/banjo/lanelint), for authors of
6
+ plugins. To check a project, install [`lanelint`](https://www.npmjs.com/package/lanelint)
7
+ instead.
8
+
9
+ ## Install
10
+
11
+ Plugins depend on core as a peer dependency:
12
+
13
+ ```json
14
+ {
15
+ "peerDependencies": { "@lanelint/core": "^0.1.0" }
16
+ }
17
+ ```
18
+
19
+ ## Write a rule
20
+
21
+ ```ts
22
+ import { definePlugin, defineRule } from '@lanelint/core';
23
+
24
+ const noLegacyImports = defineRule({
25
+ meta: {
26
+ description: 'New code must not import from src/legacy.',
27
+ severity: 'error',
28
+ docs: 'src/legacy is being removed. To fix a finding, use the replacement in src/common.',
29
+ },
30
+ create: (context) => ({
31
+ import(edge) {
32
+ if (edge.target.type === 'internal' && edge.target.file.path.startsWith('src/legacy/')) {
33
+ context.report({ at: edge, message: `Do not import ${edge.target.file.path}.` });
34
+ }
35
+ },
36
+ }),
37
+ });
38
+
39
+ export default definePlugin({ name: 'legacy', rules: { 'no-legacy-imports': noLegacyImports } });
40
+ ```
41
+
42
+ Options take any [Standard Schema](https://standardschema.dev), such as Zod, Valibot, or
43
+ ArkType, and their types flow into `defineConfig`.
44
+
45
+ ## Test a rule
46
+
47
+ ```ts
48
+ import { testRule } from '@lanelint/core/testing';
49
+ import { describe, expect, it } from 'vitest';
50
+
51
+ testRule(
52
+ 'legacy/no-legacy-imports',
53
+ noLegacyImports,
54
+ {
55
+ valid: [
56
+ { files: { 'src/a.ts': "import { b } from './b.ts';", 'src/b.ts': 'export const b = 1;' } },
57
+ ],
58
+ invalid: [
59
+ {
60
+ files: {
61
+ 'src/a.ts': "import { c } from './legacy/c.ts';",
62
+ 'src/legacy/c.ts': 'export const c = 1;',
63
+ },
64
+ findings: [{ path: 'src/a.ts', line: 1 }],
65
+ },
66
+ ],
67
+ },
68
+ { describe, it, expect },
69
+ );
70
+ ```
71
+
72
+ ## Docs
73
+
74
+ - [Writing rules](https://github.com/banjo/lanelint/blob/main/docs/writing-rules.md): visitors,
75
+ context, options, tests, and publishing
76
+ - [Concepts](https://github.com/banjo/lanelint/blob/main/docs/concepts.md): elements, imports,
77
+ and findings
78
+
79
+ ## License
80
+
81
+ MIT