@oxlint-config-inspector/core 0.0.0-tegami-trusted-publish-setup → 0.0.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/LICENSE +21 -0
- package/README.md +97 -3
- package/dist/index.d.mts +160 -0
- package/dist/index.d.mts.map +1 -0
- package/dist/index.mjs +874 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +56 -3
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026-present Nelson Lai
|
|
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,5 +1,99 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @oxlint-config-inspector/core
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
[](https://npmx.dev/package/@oxlint-config-inspector/core)
|
|
4
|
+
[](https://npmx.dev/package/@oxlint-config-inspector/core)
|
|
5
|
+
[](https://github.com/nelsonlaidev/oxlint-config-inspector/blob/main/LICENSE)
|
|
4
6
|
|
|
5
|
-
|
|
7
|
+
Core config loading and inspection utilities for Oxlint Config Inspector.
|
|
8
|
+
|
|
9
|
+
This package loads an Oxlint configuration, resolves supported `extends` chains, loads JavaScript plugins, and returns a normalized inspection model for configured, builtin, plugin, and unknown rules.
|
|
10
|
+
|
|
11
|
+
## Requirements
|
|
12
|
+
|
|
13
|
+
- Node.js 22 or newer.
|
|
14
|
+
- The `oxlint` binary should be available on `PATH` for builtin rule metadata.
|
|
15
|
+
If it is missing, inspection still returns a result, but builtin rules are not
|
|
16
|
+
cataloged and an error is logged.
|
|
17
|
+
|
|
18
|
+
## Install
|
|
19
|
+
|
|
20
|
+
```sh
|
|
21
|
+
pnpm add @oxlint-config-inspector/core
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
## Usage
|
|
25
|
+
|
|
26
|
+
```ts
|
|
27
|
+
import { inspectConfig } from '@oxlint-config-inspector/core'
|
|
28
|
+
|
|
29
|
+
const result = await inspectConfig({
|
|
30
|
+
cwd: process.cwd(),
|
|
31
|
+
})
|
|
32
|
+
|
|
33
|
+
if (!result) {
|
|
34
|
+
throw new Error('No Oxlint config found')
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
console.log(result.rules)
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
To inspect a specific config file:
|
|
41
|
+
|
|
42
|
+
```ts
|
|
43
|
+
import { inspectConfig } from '@oxlint-config-inspector/core'
|
|
44
|
+
|
|
45
|
+
const result = await inspectConfig({
|
|
46
|
+
configFile: 'oxlint.config.ts',
|
|
47
|
+
cwd: process.cwd(),
|
|
48
|
+
})
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
## API
|
|
52
|
+
|
|
53
|
+
### `inspectConfig(options?)`
|
|
54
|
+
|
|
55
|
+
Loads and inspects an Oxlint config.
|
|
56
|
+
|
|
57
|
+
Options:
|
|
58
|
+
|
|
59
|
+
- `cwd`: directory to search from. Defaults to `process.cwd()`.
|
|
60
|
+
- `configFile`: explicit config file path, resolved from `cwd`.
|
|
61
|
+
- `cache`: whether to cache discovered and loaded config files. Defaults to
|
|
62
|
+
`true`.
|
|
63
|
+
|
|
64
|
+
Returns `Promise<InspectConfigResult | null>`. `null` means no config file was found.
|
|
65
|
+
|
|
66
|
+
The result includes:
|
|
67
|
+
|
|
68
|
+
- `configFilepath`: absolute path to the root config file.
|
|
69
|
+
- `generatedAt`: ISO 8601 timestamp for when the inspection result was generated.
|
|
70
|
+
- `configFiles`: config files visited while resolving `extends`.
|
|
71
|
+
- `plugins`: JavaScript plugins loaded during inspection.
|
|
72
|
+
- `pluginErrors`: JavaScript plugin load errors.
|
|
73
|
+
- `rules`: builtin, JavaScript plugin, and unknown rules known to the inspector.
|
|
74
|
+
- `stats`: aggregate counts for configured, enabled, builtin, plugin, unknown,
|
|
75
|
+
deprecated, recommended, and fixable rules.
|
|
76
|
+
- `unknownRules`: configured rules that were not found in the builtin catalog or loaded plugins.
|
|
77
|
+
|
|
78
|
+
## Config Resolution
|
|
79
|
+
|
|
80
|
+
The loader searches for:
|
|
81
|
+
|
|
82
|
+
- `.oxlintrc.json`
|
|
83
|
+
- `.oxlintrc.jsonc`
|
|
84
|
+
- `oxlint.config.ts`
|
|
85
|
+
|
|
86
|
+
String `extends` entries are resolved relative to the config file that declares
|
|
87
|
+
them. Inline object `extends` entries from TypeScript configs are resolved
|
|
88
|
+
recursively. Only Oxlint's extendable fields are inherited from extended files:
|
|
89
|
+
`plugins`, `rules`, and `overrides`.
|
|
90
|
+
|
|
91
|
+
## JavaScript Plugins
|
|
92
|
+
|
|
93
|
+
`jsPlugins` entries from the root config and override blocks are loaded
|
|
94
|
+
dynamically. Plugin load failures are reported in `pluginErrors` instead of
|
|
95
|
+
throwing, so a partial inspection result can still be rendered.
|
|
96
|
+
|
|
97
|
+
## Runtime
|
|
98
|
+
|
|
99
|
+
This package is ESM-only and requires Node.js 22 or newer.
|
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
//#region src/config.d.ts
|
|
2
|
+
type GetConfigOptions = {
|
|
3
|
+
/** Whether to cache discovered and loaded config files. Defaults to `true`. */cache?: boolean; /** An explicit path to the config file. When provided, cosmiconfig loads this file directly instead of searching. */
|
|
4
|
+
configFile?: string; /** The directory to search for a config file. Defaults to `process.cwd()`. */
|
|
5
|
+
cwd?: string;
|
|
6
|
+
};
|
|
7
|
+
/** Known Oxlint config file names, searched in order by cosmiconfig. */
|
|
8
|
+
declare const searchPlaces: string[];
|
|
9
|
+
//#endregion
|
|
10
|
+
//#region src/plugins.d.ts
|
|
11
|
+
/**
|
|
12
|
+
* Represents an error that occurred while loading a JS plugin entry.
|
|
13
|
+
*/
|
|
14
|
+
type PluginLoadError = {
|
|
15
|
+
message: string;
|
|
16
|
+
name?: string;
|
|
17
|
+
specifier: string;
|
|
18
|
+
};
|
|
19
|
+
//#endregion
|
|
20
|
+
//#region src/inspect.d.ts
|
|
21
|
+
/**
|
|
22
|
+
* Origin of a plugin entry discovered during config inspection.
|
|
23
|
+
*/
|
|
24
|
+
type InspectedPluginSource = 'builtin' | 'js-plugin';
|
|
25
|
+
/**
|
|
26
|
+
* Summary information about a builtin or JS plugin discovered during config inspection.
|
|
27
|
+
*/
|
|
28
|
+
type InspectedPlugin = {
|
|
29
|
+
/** Number of rules exported by the plugin. */ruleCount: number; /** The plugin name used as the rule prefix. */
|
|
30
|
+
name: string; /** The original specifier used to load the JS plugin (path or package name). */
|
|
31
|
+
specifier?: string; /** Whether this is an Oxlint builtin plugin scope or a loaded JS plugin. */
|
|
32
|
+
source: InspectedPluginSource;
|
|
33
|
+
};
|
|
34
|
+
/**
|
|
35
|
+
* Error information for a JS plugin that failed to load during config inspection.
|
|
36
|
+
*/
|
|
37
|
+
type InspectedPluginLoadError = PluginLoadError;
|
|
38
|
+
/**
|
|
39
|
+
* Normalized severity for a configured or cataloged Oxlint rule.
|
|
40
|
+
*/
|
|
41
|
+
type RuleSeverity = 'error' | 'warn' | 'off' | 'unknown';
|
|
42
|
+
/**
|
|
43
|
+
* Origin of a rule discovered during config inspection.
|
|
44
|
+
*/
|
|
45
|
+
type InspectedRuleSource = 'builtin' | 'js-plugin' | 'unknown';
|
|
46
|
+
/**
|
|
47
|
+
* ESLint-compatible rule type, when supplied by JS plugin metadata.
|
|
48
|
+
*/
|
|
49
|
+
type InspectedRuleType = 'layout' | 'problem' | 'suggestion';
|
|
50
|
+
/**
|
|
51
|
+
* Normalized severity state used by the inspector UI.
|
|
52
|
+
*/
|
|
53
|
+
type InspectedRuleUsageSeverity = 'error' | 'warn' | 'off';
|
|
54
|
+
/**
|
|
55
|
+
* Normalized representation of a rule entry from an Oxlint config.
|
|
56
|
+
*/
|
|
57
|
+
type InspectedRuleConfig = {
|
|
58
|
+
/** Rule options after the severity tuple item, or an empty array when none are configured. */options: unknown[]; /** The original unmodified config value for the rule. */
|
|
59
|
+
raw: unknown; /** The rule ID exactly as it appeared in the config entry. */
|
|
60
|
+
ruleId: string; /** The normalized severity parsed from the config value. */
|
|
61
|
+
severity: RuleSeverity;
|
|
62
|
+
};
|
|
63
|
+
/**
|
|
64
|
+
* Aggregate counts derived from inspected rules.
|
|
65
|
+
*/
|
|
66
|
+
type InspectConfigStats = {
|
|
67
|
+
/** Number of builtin rules known to the inspector. */builtinRules: number; /** Number of rules configured at the root config level. */
|
|
68
|
+
configuredRules: number; /** Number of deprecated rules known to the inspector. */
|
|
69
|
+
deprecatedRules: number; /** Number of rules enabled by default, root config, or override config. */
|
|
70
|
+
enabledRules: number; /** Number of rules that can apply an automatic fix. */
|
|
71
|
+
fixableRules: number; /** Number of JS plugin rules known to the inspector. */
|
|
72
|
+
jsPluginRules: number; /** Number of rules configured in one or more override blocks. */
|
|
73
|
+
overrideRules: number; /** Number of rules that belong to a recommended rule set. */
|
|
74
|
+
recommendedRules: number; /** Total number of builtin, JS plugin, and unknown rules known to the inspector. */
|
|
75
|
+
totalRules: number; /** Number of configured rules that were not found in the builtin catalog or loaded JS plugins. */
|
|
76
|
+
unknownRules: number;
|
|
77
|
+
};
|
|
78
|
+
/**
|
|
79
|
+
* Compact usage references for category, root, and override configuration.
|
|
80
|
+
*/
|
|
81
|
+
type InspectedRuleUsage = {
|
|
82
|
+
/** Whether this rule is enabled by a category-level severity config. */category: boolean; /** Override group indexes that configure this rule. */
|
|
83
|
+
overrideGroups: number[]; /** Whether this rule is configured at the root config level. */
|
|
84
|
+
root: boolean;
|
|
85
|
+
};
|
|
86
|
+
/**
|
|
87
|
+
* A builtin, JS plugin, or unknown rule with its catalog metadata and config state.
|
|
88
|
+
*/
|
|
89
|
+
type InspectedRule = {
|
|
90
|
+
/** Rule IDs that resolve to this rule, including compatibility aliases. */aliases: string[]; /** Oxlint category for builtin rules, when available. */
|
|
91
|
+
category?: string; /** Root-level config applied to this rule, when configured. */
|
|
92
|
+
configured?: InspectedRuleConfig; /** Severity implied by the rule catalog before user configuration is applied. */
|
|
93
|
+
defaultSeverity: RuleSeverity; /** Human-readable rule description from ESLint-compatible rule metadata, when available. */
|
|
94
|
+
description?: string; /** Whether the rule is deprecated. */
|
|
95
|
+
deprecated: boolean; /** Documentation URL for builtin rules, when available. */
|
|
96
|
+
docsUrl?: string; /** Whether the rule can apply an automatic fix. */
|
|
97
|
+
fixable: boolean; /** Whether the rule can provide editor suggestions. */
|
|
98
|
+
hasSuggestions: boolean; /** Rule metadata provided by a JS plugin rule, when available. */
|
|
99
|
+
meta?: unknown; /** Rule name without the plugin prefix. */
|
|
100
|
+
name: string; /** Whether this rule is configured but explicitly turned off everywhere. */
|
|
101
|
+
offOnly: boolean; /** Whether this rule has more than one normalized usage severity. */
|
|
102
|
+
overloaded: boolean; /** Plugin or scope name for the rule, when the rule ID has one. */
|
|
103
|
+
pluginName?: string; /** Whether the rule belongs to the recommended/default-enabled rule set. */
|
|
104
|
+
recommended: boolean; /** Replacement rule IDs or names declared by deprecation metadata. */
|
|
105
|
+
replacedBy: string[]; /** Canonical rule ID used by the inspector. */
|
|
106
|
+
ruleId: string; /** Lowercase text index used by inspector search. */
|
|
107
|
+
searchText: string; /** Unique normalized severities present on this rule, ordered as error, warn, then off. */
|
|
108
|
+
severityStates: InspectedRuleUsageSeverity[]; /** ESLint-compatible rule type, when available. */
|
|
109
|
+
ruleType?: InspectedRuleType; /** Source that supplied this rule. */
|
|
110
|
+
source: InspectedRuleSource; /** Whether a builtin rule requires type information, when available. */
|
|
111
|
+
typeAware?: boolean; /** Compact usage references for default, root, and override configuration. */
|
|
112
|
+
usage: InspectedRuleUsage; /** Whether this rule is used by default, root config, or override config. */
|
|
113
|
+
used: boolean;
|
|
114
|
+
};
|
|
115
|
+
/**
|
|
116
|
+
* A rule entry grouped under a config override block.
|
|
117
|
+
*/
|
|
118
|
+
type InspectedOverrideGroupRule = {
|
|
119
|
+
/** Rule options after the severity tuple item, or an empty array when none are configured. */options: unknown[]; /** The original unmodified config value for the rule. */
|
|
120
|
+
raw: unknown; /** Canonical rule ID used by the inspector. */
|
|
121
|
+
ruleId: string; /** Normalized severity parsed from the override config value. */
|
|
122
|
+
severity: RuleSeverity; /** Source that supplied this rule. */
|
|
123
|
+
source: InspectedRuleSource;
|
|
124
|
+
};
|
|
125
|
+
/**
|
|
126
|
+
* A normalized config override block.
|
|
127
|
+
*/
|
|
128
|
+
type InspectedOverrideGroup = {
|
|
129
|
+
/** File globs excluded by the override, when configured. */excludeFiles?: string[]; /** File globs included by the override. */
|
|
130
|
+
files: string[]; /** Zero-based position of the override in the resolved config. */
|
|
131
|
+
index: number; /** Plugins enabled by this override block. */
|
|
132
|
+
plugins?: string[]; /** Rules configured by this override block. */
|
|
133
|
+
rules: InspectedOverrideGroupRule[];
|
|
134
|
+
};
|
|
135
|
+
/**
|
|
136
|
+
* Complete inspection result for a resolved Oxlint config.
|
|
137
|
+
*/
|
|
138
|
+
type InspectConfigResult = {
|
|
139
|
+
/** Every config file visited while resolving `extends`. */configFiles: string[]; /** Absolute path to the root config file that was inspected. */
|
|
140
|
+
configFilepath: string; /** ISO 8601 timestamp for when this inspection result was generated. */
|
|
141
|
+
generatedAt: string; /** Override blocks from the resolved config, including blocks without rule configs. */
|
|
142
|
+
overrideGroups: InspectedOverrideGroup[]; /** JS plugin load errors encountered during inspection. */
|
|
143
|
+
pluginErrors: InspectedPluginLoadError[]; /** Builtin plugin scopes and JS plugins discovered during inspection. */
|
|
144
|
+
plugins: InspectedPlugin[]; /** Available plugin filter values derived from inspected rules. */
|
|
145
|
+
rulePluginFilters: string[]; /** All builtin, JS plugin, and unknown rules known to the inspector. */
|
|
146
|
+
rules: InspectedRule[]; /** Aggregate counts derived from inspected rules. */
|
|
147
|
+
stats: InspectConfigStats; /** Configured rules that were not found in the builtin catalog or loaded JS plugins. */
|
|
148
|
+
unknownRules: InspectedRule[]; /** The inspector package version that produced this result. */
|
|
149
|
+
version: string;
|
|
150
|
+
};
|
|
151
|
+
/**
|
|
152
|
+
* Loads an Oxlint config and returns an inspection model for its rules and JS plugins.
|
|
153
|
+
*
|
|
154
|
+
* @param options - See {@link GetConfigOptions}.
|
|
155
|
+
* @returns The inspected config result, or `null` if no config file is found.
|
|
156
|
+
*/
|
|
157
|
+
declare function inspectConfig(options?: GetConfigOptions): Promise<InspectConfigResult | null>;
|
|
158
|
+
//#endregion
|
|
159
|
+
export { type GetConfigOptions, type InspectConfigResult, type InspectConfigStats, type InspectedOverrideGroup, type InspectedOverrideGroupRule, type InspectedPlugin, type InspectedPluginLoadError, type InspectedPluginSource, type InspectedRule, type InspectedRuleConfig, type InspectedRuleSource, type InspectedRuleType, type InspectedRuleUsage, type InspectedRuleUsageSeverity, type RuleSeverity, inspectConfig, searchPlaces };
|
|
160
|
+
//# sourceMappingURL=index.d.mts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