pickier 0.1.18 → 0.1.19
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 +62 -39
- package/dist/bin/cli.js +10847 -11113
- package/dist/plugins/publint.d.ts +11 -0
- package/dist/plugins/utils.d.ts +2 -1
- package/dist/rules/general/prefer-template.d.ts +0 -6
- package/dist/rules/markdown/no-duplicate-heading.d.ts +5 -0
- package/dist/rules/publint/bin-file-not-executable.d.ts +2 -0
- package/dist/rules/publint/deprecated-field-jsnext.d.ts +2 -0
- package/dist/rules/publint/exports-default-should-be-last.d.ts +2 -0
- package/dist/rules/publint/exports-fallback-array-use.d.ts +2 -0
- package/dist/rules/publint/exports-missing-root-entrypoint.d.ts +2 -0
- package/dist/rules/publint/exports-module-should-be-esm.d.ts +2 -0
- package/dist/rules/publint/exports-module-should-precede-require.d.ts +2 -0
- package/dist/rules/publint/exports-types-should-be-first.d.ts +2 -0
- package/dist/rules/publint/exports-value-invalid.d.ts +2 -0
- package/dist/rules/publint/field-invalid-value-type.d.ts +2 -0
- package/dist/rules/publint/file-does-not-exist.d.ts +2 -0
- package/dist/rules/publint/file-invalid-format.d.ts +2 -0
- package/dist/rules/publint/has-module-but-no-exports.d.ts +2 -0
- package/dist/rules/publint/imports-default-should-be-last.d.ts +2 -0
- package/dist/rules/publint/imports-key-invalid.d.ts +2 -0
- package/dist/rules/publint/imports-module-should-precede-require.d.ts +2 -0
- package/dist/rules/publint/imports-value-invalid.d.ts +2 -0
- package/dist/rules/publint/index.d.ts +20 -0
- package/dist/rules/publint/local-dependency.d.ts +2 -0
- package/dist/rules/publint/module-should-be-esm.d.ts +2 -0
- package/dist/rules/publint/use-type.d.ts +2 -0
- package/dist/rules/publint/utils.d.ts +73 -0
- package/dist/src/index.js +2100 -316
- package/package.json +1 -1
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { } from '../rules/publint';
|
|
2
|
+
import type { PickierPlugin } from '../types';
|
|
3
|
+
/**
|
|
4
|
+
* publint plugin for pickier.
|
|
5
|
+
*
|
|
6
|
+
* Validates package.json files for correct npm publishing configuration.
|
|
7
|
+
* Checks exports/imports ordering, field types, file format, module system, etc.
|
|
8
|
+
*
|
|
9
|
+
* Ported from publint (https://publint.dev).
|
|
10
|
+
*/
|
|
11
|
+
export declare const publintPlugin: PickierPlugin;
|
package/dist/plugins/utils.d.ts
CHANGED
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
import type { RuleModule } from '../../types';
|
|
2
2
|
/**
|
|
3
3
|
* MD024 - Multiple headings with the same content
|
|
4
|
+
*
|
|
5
|
+
* Uses "siblings only" mode by default: only flags duplicate headings
|
|
6
|
+
* within the same parent section. This avoids false positives in
|
|
7
|
+
* changelogs and other documents where headings naturally repeat
|
|
8
|
+
* across different sections (e.g., each version has "Features", "Fixes").
|
|
4
9
|
*/
|
|
5
10
|
export declare const noDuplicateHeadingRule: RuleModule;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export { useType } from './use-type';
|
|
2
|
+
export { localDependency } from './local-dependency';
|
|
3
|
+
export { deprecatedFieldJsnext } from './deprecated-field-jsnext';
|
|
4
|
+
export { hasModuleButNoExports } from './has-module-but-no-exports';
|
|
5
|
+
export { fieldInvalidValueType } from './field-invalid-value-type';
|
|
6
|
+
export { exportsTypesShouldBeFirst } from './exports-types-should-be-first';
|
|
7
|
+
export { exportsDefaultShouldBeLast } from './exports-default-should-be-last';
|
|
8
|
+
export { exportsModuleShouldPrecedeRequire } from './exports-module-should-precede-require';
|
|
9
|
+
export { exportsValueInvalid } from './exports-value-invalid';
|
|
10
|
+
export { exportsMissingRootEntrypoint } from './exports-missing-root-entrypoint';
|
|
11
|
+
export { exportsFallbackArrayUse } from './exports-fallback-array-use';
|
|
12
|
+
export { importsKeyInvalid } from './imports-key-invalid';
|
|
13
|
+
export { importsValueInvalid } from './imports-value-invalid';
|
|
14
|
+
export { importsDefaultShouldBeLast } from './imports-default-should-be-last';
|
|
15
|
+
export { importsModuleShouldPrecedeRequire } from './imports-module-should-precede-require';
|
|
16
|
+
export { fileDoesNotExist } from './file-does-not-exist';
|
|
17
|
+
export { fileInvalidFormat } from './file-invalid-format';
|
|
18
|
+
export { moduleShouldBeEsm } from './module-should-be-esm';
|
|
19
|
+
export { binFileNotExecutable } from './bin-file-not-executable';
|
|
20
|
+
export { exportsModuleShouldBeEsm } from './exports-module-should-be-esm';
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import type { LintIssue } from '../../types';
|
|
2
|
+
/**
|
|
3
|
+
* Safely parse package.json content. Returns null on failure.
|
|
4
|
+
*/
|
|
5
|
+
export declare function parsePackageJson(content: string): Record<string, any> | null;
|
|
6
|
+
/**
|
|
7
|
+
* Find the line number where a JSON key path appears in the raw content.
|
|
8
|
+
* Walks through the path segments to find the most specific match.
|
|
9
|
+
*/
|
|
10
|
+
export declare function findJsonKeyLine(content: string, keyPath: string[]): number;
|
|
11
|
+
/**
|
|
12
|
+
* Get the package directory from a file path (dirname of the package.json).
|
|
13
|
+
*/
|
|
14
|
+
export declare function getPkgDir(filePath: string): string;
|
|
15
|
+
/**
|
|
16
|
+
* Resolve a package-relative path to an absolute path.
|
|
17
|
+
*/
|
|
18
|
+
export declare function resolvePkgPath(pkgDir: string, relativePath: string): string;
|
|
19
|
+
/**
|
|
20
|
+
* Format a JSON path for human-readable messages.
|
|
21
|
+
* e.g. ['exports', '.', 'types'] -> 'pkg.exports["."].types'
|
|
22
|
+
*/
|
|
23
|
+
export declare function formatPkgPath(path: string[]): string;
|
|
24
|
+
/**
|
|
25
|
+
* Get a published field value, respecting publishConfig overrides.
|
|
26
|
+
* Returns [value, path] tuple.
|
|
27
|
+
*/
|
|
28
|
+
export declare function getPublishedField(pkg: Record<string, any>, field: string): [any, string[]];
|
|
29
|
+
/**
|
|
30
|
+
* Detect the code format (ESM, CJS, mixed, or unknown) from file content.
|
|
31
|
+
*/
|
|
32
|
+
export declare function getCodeFormat(code: string): CodeFormat;
|
|
33
|
+
/**
|
|
34
|
+
* Determine the expected code format from a file path and nearest package.json type field.
|
|
35
|
+
*/
|
|
36
|
+
export declare function getFilePathFormat(filePath: string, pkgType?: string): 'ESM' | 'CJS';
|
|
37
|
+
/**
|
|
38
|
+
* Get the expected file extension for a given code format.
|
|
39
|
+
*/
|
|
40
|
+
export declare function getCodeFormatExtension(format: CodeFormat): string;
|
|
41
|
+
/**
|
|
42
|
+
* Whether an extension is explicit (.mjs or .cjs).
|
|
43
|
+
*/
|
|
44
|
+
export declare function isExplicitExtension(ext: string): boolean;
|
|
45
|
+
/**
|
|
46
|
+
* Check if a file path has a lintable extension for format checking.
|
|
47
|
+
*/
|
|
48
|
+
export declare function isLintableFilePath(filePath: string): boolean;
|
|
49
|
+
/**
|
|
50
|
+
* Check if a file starts with a shebang.
|
|
51
|
+
*/
|
|
52
|
+
export declare function startsWithShebang(code: string): boolean;
|
|
53
|
+
/**
|
|
54
|
+
* Recursively crawl an exports or imports object, calling visitor for each node.
|
|
55
|
+
* Handles string values, array values (fallback), and object values (conditions/subpaths).
|
|
56
|
+
*/
|
|
57
|
+
export declare function crawlExportsOrImports(value: any, basePath: string[], isImports: boolean, visitor: CrawlVisitor): void;
|
|
58
|
+
/**
|
|
59
|
+
* Create a LintIssue for a publint rule.
|
|
60
|
+
*/
|
|
61
|
+
export declare function createIssue(filePath: string, content: string, keyPath: string[], ruleId: string, message: string, severity: 'warning' | 'error', help?: string): LintIssue;
|
|
62
|
+
// Crawl exports/imports types
|
|
63
|
+
export declare interface CrawlContext {
|
|
64
|
+
path: string[]
|
|
65
|
+
isImports: boolean
|
|
66
|
+
}
|
|
67
|
+
export type CodeFormat = 'ESM' | 'CJS' | 'mixed' | 'unknown'
|
|
68
|
+
export type CrawlVisitor = (
|
|
69
|
+
value: any,
|
|
70
|
+
ctx: CrawlContext,
|
|
71
|
+
/** The keys of the current object level (for condition ordering checks) */
|
|
72
|
+
objectKeys?: string[],
|
|
73
|
+
) => void
|