@markuplint/create-rule 5.2.0 → 5.3.0
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/CHANGELOG.md +11 -0
- package/lib/create-rule-helper-error.d.ts +1 -0
- package/lib/create-rule-helper-error.js +1 -0
- package/lib/create-rule-helper.d.ts +10 -0
- package/lib/create-rule-helper.js +10 -0
- package/lib/index.d.ts +11 -0
- package/lib/index.js +10 -0
- package/lib/types.d.ts +15 -0
- package/package.json +7 -7
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,17 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
# [5.3.0](https://github.com/markuplint/markuplint/compare/v5.2.0...v5.3.0) (2026-10-21)
|
|
7
|
+
|
|
8
|
+
### Bug Fixes
|
|
9
|
+
|
|
10
|
+
* make published packages loadable from require() and put types first ([723106f](https://github.com/markuplint/markuplint/commit/723106f51aac4e60dc02db2c1a894617368b0253)), closes [#4198](https://github.com/markuplint/markuplint/issues/4198)
|
|
11
|
+
|
|
12
|
+
### Features
|
|
13
|
+
|
|
14
|
+
* **create-rule:** add the package entry point for the programmatic API ([1b2b1c0](https://github.com/markuplint/markuplint/commit/1b2b1c0fa7ccc959cc69787103e19e475544e621))
|
|
15
|
+
|
|
16
|
+
|
|
6
17
|
# [5.2.0](https://github.com/markuplint/markuplint/compare/v5.1.1...v5.2.0) (2026-10-13)
|
|
7
18
|
|
|
8
19
|
### Bug Fixes
|
|
@@ -1,2 +1,12 @@
|
|
|
1
1
|
import type { CreateRuleHelperParams, CreateRuleHelperResult } from './types.js';
|
|
2
|
+
/**
|
|
3
|
+
* Generates the scaffold of a new rule for the given purpose.
|
|
4
|
+
*
|
|
5
|
+
* @param params - What to generate and where (see {@link CreateRuleHelperParams}).
|
|
6
|
+
* `core` is required when `purpose` is `CONTRIBUTE_TO_CORE`.
|
|
7
|
+
* @returns The generated files and the dependencies to install.
|
|
8
|
+
* @throws {CreateRuleHelperError} The destination already exists or is not
|
|
9
|
+
* empty, `core` is missing for `CONTRIBUTE_TO_CORE`, or the markuplint
|
|
10
|
+
* repository cannot be found for it.
|
|
11
|
+
*/
|
|
2
12
|
export declare function createRuleHelper(params: CreateRuleHelperParams): Promise<CreateRuleHelperResult>;
|
|
@@ -1,6 +1,16 @@
|
|
|
1
1
|
import { createRulePackage } from './create-rule-package.js';
|
|
2
2
|
import { createRuleToCore } from './create-rule-to-core.js';
|
|
3
3
|
import { createRuleToProject } from './create-rule-to-project.js';
|
|
4
|
+
/**
|
|
5
|
+
* Generates the scaffold of a new rule for the given purpose.
|
|
6
|
+
*
|
|
7
|
+
* @param params - What to generate and where (see {@link CreateRuleHelperParams}).
|
|
8
|
+
* `core` is required when `purpose` is `CONTRIBUTE_TO_CORE`.
|
|
9
|
+
* @returns The generated files and the dependencies to install.
|
|
10
|
+
* @throws {CreateRuleHelperError} The destination already exists or is not
|
|
11
|
+
* empty, `core` is missing for `CONTRIBUTE_TO_CORE`, or the markuplint
|
|
12
|
+
* repository cannot be found for it.
|
|
13
|
+
*/
|
|
4
14
|
export async function createRuleHelper(params) {
|
|
5
15
|
switch (params.purpose) {
|
|
6
16
|
case 'ADD_TO_PROJECT': {
|
package/lib/index.d.ts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module @markuplint/create-rule
|
|
3
|
+
*
|
|
4
|
+
* Package entry point for the programmatic API behind the `create-rule` CLI
|
|
5
|
+
* (`bin/create-rule.mjs` imports `./cli.js` directly, not this file). Only the
|
|
6
|
+
* scaffold generator, its error class and its parameter/result types are
|
|
7
|
+
* public; the CLI wiring and the file-system helpers are not.
|
|
8
|
+
*/
|
|
9
|
+
export { createRuleHelper } from './create-rule-helper.js';
|
|
10
|
+
export { CreateRuleHelperError } from './create-rule-helper-error.js';
|
|
11
|
+
export type * from './types.js';
|
package/lib/index.js
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module @markuplint/create-rule
|
|
3
|
+
*
|
|
4
|
+
* Package entry point for the programmatic API behind the `create-rule` CLI
|
|
5
|
+
* (`bin/create-rule.mjs` imports `./cli.js` directly, not this file). Only the
|
|
6
|
+
* scaffold generator, its error class and its parameter/result types are
|
|
7
|
+
* public; the CLI wiring and the file-system helpers are not.
|
|
8
|
+
*/
|
|
9
|
+
export { createRuleHelper } from './create-rule-helper.js';
|
|
10
|
+
export { CreateRuleHelperError } from './create-rule-helper-error.js';
|
package/lib/types.d.ts
CHANGED
|
@@ -1,31 +1,46 @@
|
|
|
1
|
+
/** Everything `createRuleHelper` needs: the rule to create and where it goes. */
|
|
1
2
|
export type CreateRuleHelperParams = CreateRuleCreatorParams & {
|
|
3
|
+
/** Where the generated rule is placed. */
|
|
2
4
|
readonly purpose: CreateRulePurpose;
|
|
3
5
|
};
|
|
6
|
+
/** The rule to generate, independent of its destination. */
|
|
4
7
|
export type CreateRuleCreatorParams = {
|
|
8
|
+
/** Plugin or directory name (kebab-case). Unused for `CONTRIBUTE_TO_CORE`. */
|
|
5
9
|
readonly pluginName: string;
|
|
10
|
+
/** Rule name (kebab-case). */
|
|
6
11
|
readonly ruleName: string;
|
|
7
12
|
readonly lang: CreateRuleLanguage;
|
|
13
|
+
/** Whether to generate a spec file. */
|
|
8
14
|
readonly needTest: boolean;
|
|
15
|
+
/** Metadata for a core rule. Required for `CONTRIBUTE_TO_CORE`. */
|
|
9
16
|
readonly core?: CreateRuleCreatorCoreParams;
|
|
10
17
|
};
|
|
18
|
+
/** Metadata of a rule generated for core (`category` goes to `meta.ts`, `severity` to `schema.json`). */
|
|
11
19
|
export type CreateRuleCreatorCoreParams = {
|
|
12
20
|
readonly description: string;
|
|
13
21
|
readonly category: string;
|
|
14
22
|
readonly severity: string;
|
|
15
23
|
};
|
|
24
|
+
/** What `createRuleHelper` generated. */
|
|
16
25
|
export type CreateRuleHelperResult = {
|
|
17
26
|
readonly files: readonly File[];
|
|
27
|
+
/** Packages the generated rule needs at runtime. */
|
|
18
28
|
readonly dependencies: readonly string[];
|
|
29
|
+
/** Packages the generated rule needs for development and tests. */
|
|
19
30
|
readonly devDependencies: readonly string[];
|
|
20
31
|
};
|
|
32
|
+
/** Language of the generated rule source. */
|
|
21
33
|
export type CreateRuleLanguage = 'JAVASCRIPT' | 'TYPESCRIPT';
|
|
34
|
+
/** Where the generated rule is placed: an existing project, a new package, or the markuplint repository. */
|
|
22
35
|
export type CreateRulePurpose = 'ADD_TO_PROJECT' | 'PUBLISH_AS_PACKAGE' | 'CONTRIBUTE_TO_CORE';
|
|
36
|
+
/** A file generated by `createRuleHelper`. */
|
|
23
37
|
export type File = {
|
|
24
38
|
readonly ext: string;
|
|
25
39
|
/** Base name without extension or test suffix. */
|
|
26
40
|
readonly name: string;
|
|
27
41
|
/** Full file name including the test suffix, but without extension. */
|
|
28
42
|
readonly fileName: string;
|
|
43
|
+
/** Whether this is a spec file. */
|
|
29
44
|
readonly test: boolean;
|
|
30
45
|
readonly destDir: string;
|
|
31
46
|
readonly filePath: string;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@markuplint/create-rule",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.3.0",
|
|
4
4
|
"description": "Rule generator for markuplint",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -15,8 +15,8 @@
|
|
|
15
15
|
"type": "module",
|
|
16
16
|
"exports": {
|
|
17
17
|
".": {
|
|
18
|
-
"
|
|
19
|
-
"
|
|
18
|
+
"types": "./lib/index.d.ts",
|
|
19
|
+
"default": "./lib/index.js"
|
|
20
20
|
}
|
|
21
21
|
},
|
|
22
22
|
"bin": "./bin/create-rule.mjs",
|
|
@@ -29,15 +29,15 @@
|
|
|
29
29
|
"clean": "tsc --build --clean tsconfig.build.json"
|
|
30
30
|
},
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"@markuplint/cli-utils": "5.
|
|
33
|
-
"@markuplint/ml-core": "5.
|
|
32
|
+
"@markuplint/cli-utils": "5.3.0",
|
|
33
|
+
"@markuplint/ml-core": "5.3.0",
|
|
34
34
|
"glob": "^13.0.6",
|
|
35
|
-
"prettier": "^3.9.
|
|
35
|
+
"prettier": "^3.9.10",
|
|
36
36
|
"typescript": "~6.0.3"
|
|
37
37
|
},
|
|
38
38
|
"devDependencies": {
|
|
39
39
|
"@types/fs-extra": "11.0.4",
|
|
40
40
|
"fs-extra": "11.4.1"
|
|
41
41
|
},
|
|
42
|
-
"gitHead": "
|
|
42
|
+
"gitHead": "f587cf0206c8426e57369a48d6d5fb22306eafde"
|
|
43
43
|
}
|