pickier 0.1.27 → 0.1.29
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/dist/bin/cli.js +8464 -2966
- package/dist/src/index.js +7013 -1819
- package/dist/utils.d.ts +27 -24
- package/package.json +3 -3
- package/dist/rules/lockfile/index.d.ts +0 -6
- package/dist/rules/publint/bin-file-not-executable.d.ts +0 -2
- package/dist/rules/publint/deprecated-field-jsnext.d.ts +0 -2
- package/dist/rules/publint/exports-default-should-be-last.d.ts +0 -2
- package/dist/rules/publint/exports-fallback-array-use.d.ts +0 -2
- package/dist/rules/publint/exports-missing-root-entrypoint.d.ts +0 -2
- package/dist/rules/publint/exports-module-should-be-esm.d.ts +0 -2
- package/dist/rules/publint/exports-module-should-precede-require.d.ts +0 -2
- package/dist/rules/publint/exports-types-should-be-first.d.ts +0 -2
- package/dist/rules/publint/exports-value-invalid.d.ts +0 -2
- package/dist/rules/publint/field-invalid-value-type.d.ts +0 -2
- package/dist/rules/publint/file-does-not-exist.d.ts +0 -2
- package/dist/rules/publint/file-invalid-format.d.ts +0 -2
- package/dist/rules/publint/has-module-but-no-exports.d.ts +0 -2
- package/dist/rules/publint/imports-default-should-be-last.d.ts +0 -2
- package/dist/rules/publint/imports-key-invalid.d.ts +0 -2
- package/dist/rules/publint/imports-module-should-precede-require.d.ts +0 -2
- package/dist/rules/publint/imports-value-invalid.d.ts +0 -2
- package/dist/rules/publint/index.d.ts +0 -22
- package/dist/rules/publint/local-dependency.d.ts +0 -2
- package/dist/rules/publint/module-should-be-esm.d.ts +0 -2
- package/dist/rules/publint/use-type.d.ts +0 -2
- package/dist/rules/publint/utils.d.ts +0 -73
package/dist/utils.d.ts
CHANGED
|
@@ -33,9 +33,17 @@ export declare function loadConfigFromPath(pathLike: string | undefined): Promis
|
|
|
33
33
|
export declare function expandPatterns(patterns: string[]): string[];
|
|
34
34
|
export declare function isCodeFile(file: string, allowedExts: Set<string>): boolean;
|
|
35
35
|
/**
|
|
36
|
-
*
|
|
37
|
-
*
|
|
38
|
-
*
|
|
36
|
+
* Build a reusable matcher for ignore checks.
|
|
37
|
+
*
|
|
38
|
+
* File discovery may check the same ignore list tens of thousands of times, so
|
|
39
|
+
* callers should create one matcher per run and reuse it instead of reparsing
|
|
40
|
+
* glob strings for every path.
|
|
41
|
+
*/
|
|
42
|
+
export declare function createIgnoreMatcher(ignoreGlobs: readonly string[], cwd?: string): IgnoreMatcher;
|
|
43
|
+
/**
|
|
44
|
+
* Lightweight ignore matcher supporting common patterns like double-star slash
|
|
45
|
+
* dir slash double-star. Kept for public utility callers; the linter hot path
|
|
46
|
+
* should use `createIgnoreMatcher()` and reuse the returned function.
|
|
39
47
|
*/
|
|
40
48
|
export declare function shouldIgnorePath(absPath: string, ignoreGlobs: string[]): boolean;
|
|
41
49
|
/**
|
|
@@ -43,31 +51,12 @@ export declare function shouldIgnorePath(absPath: string, ignoreGlobs: string[])
|
|
|
43
51
|
* This prevents infinite loops when fixers keep modifying content.
|
|
44
52
|
*/
|
|
45
53
|
export declare const MAX_FIXER_PASSES: 5;
|
|
46
|
-
|
|
47
|
-
* Environment variable configuration with defaults.
|
|
48
|
-
* Centralized to avoid scattered parsing and provide documentation.
|
|
49
|
-
*/
|
|
50
|
-
export declare const ENV: {
|
|
51
|
-
/** Enable verbose trace logging. Set PICKIER_TRACE=1 to enable. */
|
|
52
|
-
get TRACE: () => unknown;
|
|
53
|
-
/** Glob timeout in milliseconds. Default: 8000ms */
|
|
54
|
-
get TIMEOUT_MS: () => unknown;
|
|
55
|
-
/** Per-rule timeout in milliseconds. Default: 5000ms */
|
|
56
|
-
get RULE_TIMEOUT_MS: () => unknown;
|
|
57
|
-
/** Parallel file processing concurrency. Default: 8 */
|
|
58
|
-
get CONCURRENCY: () => unknown;
|
|
59
|
-
/** Enable diagnostics mode. Set PICKIER_DIAGNOSTICS=1 to enable. */
|
|
60
|
-
get DIAGNOSTICS: () => unknown;
|
|
61
|
-
/** Treat warnings as errors. Set PICKIER_FAIL_ON_WARNINGS=1 to enable. */
|
|
62
|
-
get FAIL_ON_WARNINGS: () => unknown;
|
|
63
|
-
/** Disable auto-loading of config. Set PICKIER_NO_AUTO_CONFIG=1 to disable. */
|
|
64
|
-
get NO_AUTO_CONFIG: () => unknown
|
|
65
|
-
};
|
|
54
|
+
export declare const ENV: EnvConfig;
|
|
66
55
|
/**
|
|
67
56
|
* Universal ignore patterns that should apply everywhere.
|
|
68
57
|
* These are always excluded regardless of project-specific config.
|
|
69
58
|
*/
|
|
70
|
-
export declare const UNIVERSAL_IGNORES: readonly [
|
|
59
|
+
export declare const UNIVERSAL_IGNORES: readonly string[];
|
|
71
60
|
export declare const colors: {
|
|
72
61
|
green: (text: string) => string
|
|
73
62
|
red: (text: string) => string
|
|
@@ -88,3 +77,17 @@ declare interface GlobOptions {
|
|
|
88
77
|
absolute?: boolean
|
|
89
78
|
cwd?: string
|
|
90
79
|
}
|
|
80
|
+
/**
|
|
81
|
+
* Environment variable configuration with defaults.
|
|
82
|
+
* Centralized to avoid scattered parsing and provide documentation.
|
|
83
|
+
*/
|
|
84
|
+
export declare interface EnvConfig {
|
|
85
|
+
readonly TRACE: boolean
|
|
86
|
+
readonly TIMEOUT_MS: number
|
|
87
|
+
readonly RULE_TIMEOUT_MS: number
|
|
88
|
+
readonly CONCURRENCY: number
|
|
89
|
+
readonly DIAGNOSTICS: boolean
|
|
90
|
+
readonly FAIL_ON_WARNINGS: boolean
|
|
91
|
+
readonly NO_AUTO_CONFIG: boolean
|
|
92
|
+
}
|
|
93
|
+
declare type IgnoreMatcher = (absPath: string) => boolean;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pickier",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.1.
|
|
4
|
+
"version": "0.1.29",
|
|
5
5
|
"description": "Format, lint and more in a fraction of seconds.",
|
|
6
6
|
"author": "Chris Breuer <chris@stacksjs.org>",
|
|
7
7
|
"license": "MIT",
|
|
@@ -77,12 +77,12 @@
|
|
|
77
77
|
"test:watch": "PICKIER_NO_AUTO_CONFIG=1 bun test --watch"
|
|
78
78
|
},
|
|
79
79
|
"dependencies": {
|
|
80
|
-
"@stacksjs/clapp": "^0.2.
|
|
80
|
+
"@stacksjs/clapp": "^0.2.3"
|
|
81
81
|
},
|
|
82
82
|
"optionalDependencies": {
|
|
83
83
|
"@stacksjs/ts-spell-check": "^0.1.0"
|
|
84
84
|
},
|
|
85
85
|
"devDependencies": {
|
|
86
|
-
"bunfig": "^0.15.
|
|
86
|
+
"bunfig": "^0.15.13"
|
|
87
87
|
}
|
|
88
88
|
}
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
// Tier 1 - Pure JSON analysis
|
|
2
|
-
export { deprecatedFieldJsnext } from './deprecated-field-jsnext';
|
|
3
|
-
export { exportsDefaultShouldBeLast } from './exports-default-should-be-last';
|
|
4
|
-
export { exportsFallbackArrayUse } from './exports-fallback-array-use';
|
|
5
|
-
export { exportsMissingRootEntrypoint } from './exports-missing-root-entrypoint';
|
|
6
|
-
export { exportsModuleShouldPrecedeRequire } from './exports-module-should-precede-require';
|
|
7
|
-
export { exportsTypesShouldBeFirst } from './exports-types-should-be-first';
|
|
8
|
-
export { exportsValueInvalid } from './exports-value-invalid';
|
|
9
|
-
export { fieldInvalidValueType } from './field-invalid-value-type';
|
|
10
|
-
export { hasModuleButNoExports } from './has-module-but-no-exports';
|
|
11
|
-
export { importsDefaultShouldBeLast } from './imports-default-should-be-last';
|
|
12
|
-
export { importsKeyInvalid } from './imports-key-invalid';
|
|
13
|
-
export { importsModuleShouldPrecedeRequire } from './imports-module-should-precede-require';
|
|
14
|
-
export { importsValueInvalid } from './imports-value-invalid';
|
|
15
|
-
export { localDependency } from './local-dependency';
|
|
16
|
-
export { useType } from './use-type';
|
|
17
|
-
// Tier 2 - Filesystem access
|
|
18
|
-
export { binFileNotExecutable } from './bin-file-not-executable';
|
|
19
|
-
export { exportsModuleShouldBeEsm } from './exports-module-should-be-esm';
|
|
20
|
-
export { fileDoesNotExist } from './file-does-not-exist';
|
|
21
|
-
export { fileInvalidFormat } from './file-invalid-format';
|
|
22
|
-
export { moduleShouldBeEsm } from './module-should-be-esm';
|
|
@@ -1,73 +0,0 @@
|
|
|
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;
|