oxlint-plugin-utilities 0.1.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 +44 -0
- package/dist/build-metadata.json +5 -0
- package/dist/index.d.ts +77 -0
- package/dist/index.js +23 -0
- package/package.json +91 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 HowManySmall
|
|
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
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
# oxlint-plugin-utilities
|
|
2
|
+
|
|
3
|
+
## CI/CD & Branch Protection
|
|
4
|
+
|
|
5
|
+
### Branch Protection Rules
|
|
6
|
+
|
|
7
|
+
Configure these rules for `main` branch in GitHub Settings → Branches:
|
|
8
|
+
|
|
9
|
+
1. **Require status checks to pass before merging**
|
|
10
|
+
- Required check: `validate` (from CI workflow)
|
|
11
|
+
|
|
12
|
+
2. **Require branches to be up to date before merging**
|
|
13
|
+
- Ensures PR tests run on latest main
|
|
14
|
+
|
|
15
|
+
3. **Require linear history** (optional)
|
|
16
|
+
- Prevents merge commits, keeps history clean
|
|
17
|
+
|
|
18
|
+
4. **Require signed commits** (optional)
|
|
19
|
+
- Enhances security with commit signatures
|
|
20
|
+
|
|
21
|
+
5. **Do not allow bypassing the above settings**
|
|
22
|
+
- Enforces rules for everyone (including admins)
|
|
23
|
+
|
|
24
|
+
### Release Process
|
|
25
|
+
|
|
26
|
+
1. **Version bump**: Run `bun run release` locally (bumpp)
|
|
27
|
+
- Interactive version selection
|
|
28
|
+
- Auto-commits, tags, and pushes
|
|
29
|
+
|
|
30
|
+
2. **Automated publishing**:
|
|
31
|
+
- Tag push triggers `release.yaml` workflow
|
|
32
|
+
- Validates tag matches package.json version
|
|
33
|
+
- Runs tests
|
|
34
|
+
- Publishes to NPM with provenance
|
|
35
|
+
- Creates GitHub release with changelog
|
|
36
|
+
|
|
37
|
+
3. **NPM Trusted Publishing**:
|
|
38
|
+
- No NPM_TOKEN secret needed
|
|
39
|
+
- Uses GitHub OIDC for authentication
|
|
40
|
+
- Configure at npmjs.com → Package Settings → Trusted Publishers
|
|
41
|
+
- Add trusted publisher:
|
|
42
|
+
- Repository: `howmanysmall/oxlint-plugin-utilities`
|
|
43
|
+
- Workflow: `release.yaml`
|
|
44
|
+
- Environment: (leave empty)
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import type { Context as OxlintContext } from "@oxlint/plugins";
|
|
2
|
+
import type { Diagnostic as OxlintDiagnostic } from "@oxlint/plugins";
|
|
3
|
+
import type { Rule as OxlintRule } from "@oxlint/plugins";
|
|
4
|
+
import type { Rule as PluginsOxlintRule } from "@oxlint/plugins";
|
|
5
|
+
import type { RuleMeta as OxlintRuleMeta } from "@oxlint/plugins";
|
|
6
|
+
import type { Visitor } from "@oxlint/plugins";
|
|
7
|
+
import type { VisitorWithHooks } from "@oxlint/plugins";
|
|
8
|
+
import type { Except } from "type-fest";
|
|
9
|
+
|
|
10
|
+
export type { AfterHook, BeforeHook, BooleanToken, Comment, CountOptions, Definition, DefinitionType, DiagnosticData, Envs, ESTree, FilterFn, FilterFn as FilterFunction, Fix, Fixer, FixFn, FixFn as FixFunction, Globals, IdentifierToken, JSXIdentifierToken, JSXTextToken, KeywordToken, LanguageOptions, Context as LegacyContext, CreateOnceRule as LegacyCreateOnceRule, CreateRule as LegacyCreateRule, Diagnostic as LegacyDiagnostic, Plugin as LegacyPlugin, Rule as LegacyRule, RuleMeta as LegacyRuleMeta, LineColumn, Location, Node, NullToken, NumericToken, Options, PrivateIdentifierToken, PunctuatorToken, Range, Ranged, RangeOptions, Reference, RegularExpressionToken, RuleDeprecatedInfo, RuleDocs, RuleOptionsSchema, RuleReplacedByExternalSpecifier, RuleReplacedByInfo, Scope, ScopeManager, ScopeType, Settings, SkipOptions, SourceCode, Span, StringToken, Suggestion, TemplateToken, Token, Variable, Visitor, VisitorWithHooks, } from "@oxlint/plugins";
|
|
11
|
+
|
|
12
|
+
type RuleOptions<TRecord = Record<string, never>> = readonly [
|
|
13
|
+
TRecord
|
|
14
|
+
];
|
|
15
|
+
|
|
16
|
+
type Diagnostic<TMessageIds extends string = string> = Readonly<Except<OxlintDiagnostic, "messageId">> & {
|
|
17
|
+
readonly messageId: TMessageIds;
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
type Context<TOptions, TMessageIds extends string = string> = Except<OxlintContext, "options" | "report"> & {
|
|
21
|
+
readonly options: RuleOptions<TOptions>;
|
|
22
|
+
report(this: void, diagnostic: Diagnostic<TMessageIds>): void;
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
interface RuleMeta<TMessageIds extends string = string> extends Readonly<Except<OxlintRuleMeta, "messages">> {
|
|
26
|
+
readonly messages?: Record<TMessageIds, string>;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
interface CreateOnceRule<TOptions = Record<string, never>, TMessageIds extends string = string> {
|
|
30
|
+
readonly create?: (context: Context<TOptions, TMessageIds>, optionsWithDefault: TOptions) => Visitor;
|
|
31
|
+
readonly createOnce: (context: Context<TOptions, TMessageIds>, optionsWithDefault: TOptions) => VisitorWithHooks;
|
|
32
|
+
readonly meta?: RuleMeta<TMessageIds>;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
interface CreateRule<TOptions = Record<string, never>, TMessageIds extends string = string> {
|
|
36
|
+
readonly create: (context: Context<TOptions, TMessageIds>, optionsWithDefault: TOptions) => Visitor;
|
|
37
|
+
readonly meta?: RuleMeta<TMessageIds>;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
type Rule<TOptions = Record<string, never>, TMessageIds extends string = string> = CreateOnceRule<TOptions, TMessageIds> | CreateRule<TOptions, TMessageIds>;
|
|
41
|
+
|
|
42
|
+
interface Plugin<TRules extends Record<string, PluginsOxlintRule | Rule>> {
|
|
43
|
+
readonly meta?: {
|
|
44
|
+
readonly name?: string;
|
|
45
|
+
};
|
|
46
|
+
readonly rules: TRules;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Define a plugin.
|
|
51
|
+
*
|
|
52
|
+
* No-op function, just to provide type safety. Input is passed through unchanged. This is a stronger typed version of
|
|
53
|
+
* the original definePlugin.
|
|
54
|
+
*
|
|
55
|
+
* @template TRules - The rules of the plugin
|
|
56
|
+
* @param plugin - Plugin to define
|
|
57
|
+
* @returns Same plugin as passed in
|
|
58
|
+
*/
|
|
59
|
+
declare function definePlugin<TRules extends Record<string, OxlintRule | Rule>>(plugin: Plugin<TRules>): Plugin<TRules>;
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* Define a rule.
|
|
63
|
+
*
|
|
64
|
+
* No-op function, just to provide type safety. Input is passed through unchanged. This is a stronger typed version of
|
|
65
|
+
* the original defineRule.
|
|
66
|
+
*
|
|
67
|
+
* @template TOptions - The rule options type
|
|
68
|
+
* @template TMessageIds - The message IDs type
|
|
69
|
+
* @param rule - Rule to define
|
|
70
|
+
* @returns Same rule as passed in
|
|
71
|
+
*/
|
|
72
|
+
declare function defineRule<TOptions, TMessageIds extends string>(rule: CreateRule<TOptions, TMessageIds>): CreateRule<TOptions, TMessageIds>;
|
|
73
|
+
|
|
74
|
+
type InferContextFromRule<TRule> = TRule extends CreateRule<infer TOptions, infer TMessageIds> ? Context<TOptions, TMessageIds> : TRule extends CreateOnceRule<infer TOptions, infer TMessageIds> ? Context<TOptions, TMessageIds> : never;
|
|
75
|
+
|
|
76
|
+
export type { Context, CreateOnceRule, CreateRule, Diagnostic, InferContextFromRule, Plugin, Rule, RuleMeta, RuleOptions };
|
|
77
|
+
export { definePlugin, defineRule };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Define a plugin.
|
|
3
|
+
*
|
|
4
|
+
* No-op function, just to provide type safety. Input is passed through unchanged. This is a stronger typed version of
|
|
5
|
+
* the original definePlugin.
|
|
6
|
+
*
|
|
7
|
+
* @template TRules - The rules of the plugin
|
|
8
|
+
* @param plugin - Plugin to define
|
|
9
|
+
* @returns Same plugin as passed in
|
|
10
|
+
*/
|
|
11
|
+
function definePlugin(plugin){return plugin}
|
|
12
|
+
/**
|
|
13
|
+
* Define a rule.
|
|
14
|
+
*
|
|
15
|
+
* No-op function, just to provide type safety. Input is passed through unchanged. This is a stronger typed version of
|
|
16
|
+
* the original defineRule.
|
|
17
|
+
*
|
|
18
|
+
* @template TOptions - The rule options type
|
|
19
|
+
* @template TMessageIds - The message IDs type
|
|
20
|
+
* @param rule - Rule to define
|
|
21
|
+
* @returns Same rule as passed in
|
|
22
|
+
*/
|
|
23
|
+
function defineRule(rule){return rule}export{defineRule,definePlugin};
|
package/package.json
ADDED
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "oxlint-plugin-utilities",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "A smarter wrapper around Oxlint's JS plugins types.",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"lint",
|
|
7
|
+
"linting",
|
|
8
|
+
"oxlint",
|
|
9
|
+
"plugin",
|
|
10
|
+
"rules",
|
|
11
|
+
"utilities"
|
|
12
|
+
],
|
|
13
|
+
"license": "MIT",
|
|
14
|
+
"author": {
|
|
15
|
+
"name": "HowManySmall"
|
|
16
|
+
},
|
|
17
|
+
"repository": {
|
|
18
|
+
"type": "git",
|
|
19
|
+
"url": "git+https://github.com/howmanysmall/oxlint-plugin-utilities.git"
|
|
20
|
+
},
|
|
21
|
+
"files": [
|
|
22
|
+
"dist"
|
|
23
|
+
],
|
|
24
|
+
"type": "module",
|
|
25
|
+
"module": "src/index.ts",
|
|
26
|
+
"types": "./dist/index.d.ts",
|
|
27
|
+
"exports": {
|
|
28
|
+
".": {
|
|
29
|
+
"types": "./dist/index.d.ts",
|
|
30
|
+
"import": "./dist/index.js"
|
|
31
|
+
}
|
|
32
|
+
},
|
|
33
|
+
"publishConfig": {
|
|
34
|
+
"access": "public"
|
|
35
|
+
},
|
|
36
|
+
"scripts": {
|
|
37
|
+
"biome:check": "biome check",
|
|
38
|
+
"biome:ci": "biome ci",
|
|
39
|
+
"biome:lint": "biome lint",
|
|
40
|
+
"build": "bun run ./scripts/build.ts",
|
|
41
|
+
"commitlint": "commitlint --edit",
|
|
42
|
+
"format": "oxfmt",
|
|
43
|
+
"knip": "knip-bun",
|
|
44
|
+
"lint": "bash -c 'a=$(bash scripts/default-src.sh \"$@\"); bun run oxc $a && bun run biome:check $a' _",
|
|
45
|
+
"oxc": "oxlint",
|
|
46
|
+
"prepare": "lefthook install",
|
|
47
|
+
"prepublishOnly": "bun run build",
|
|
48
|
+
"release": "bumpp",
|
|
49
|
+
"test": "tsd --files 'src/**/*.test-d.ts'",
|
|
50
|
+
"type-check": "tsgo --noEmit"
|
|
51
|
+
},
|
|
52
|
+
"dependencies": {
|
|
53
|
+
"@oxlint/plugins": "^1.58.0",
|
|
54
|
+
"type-fest": "^5.5.0"
|
|
55
|
+
},
|
|
56
|
+
"devDependencies": {
|
|
57
|
+
"@biomejs/biome": "^2.4.10",
|
|
58
|
+
"@commitlint/config-conventional": "^20.5.0",
|
|
59
|
+
"@commitlint/types": "^20.5.0",
|
|
60
|
+
"@jsr/cliffy__command": "^1.0.0",
|
|
61
|
+
"@total-typescript/ts-reset": "^0.6.1",
|
|
62
|
+
"@types/bun": "latest",
|
|
63
|
+
"@types/node": "^25.5.2",
|
|
64
|
+
"@typescript/native-preview": "^7.0.0-dev.20260403.1",
|
|
65
|
+
"bumpp": "^11.0.1",
|
|
66
|
+
"changelogithub": "^13.2.0",
|
|
67
|
+
"commitlint": "^20.5.0",
|
|
68
|
+
"consola": "^3.4.2",
|
|
69
|
+
"knip": "^6.3.0",
|
|
70
|
+
"oxfmt": "^0.43.0",
|
|
71
|
+
"oxlint": "^1.58.0",
|
|
72
|
+
"oxlint-tsgolint": "^0.19.0",
|
|
73
|
+
"picocolors": "^1.1.1",
|
|
74
|
+
"pretty-bytes": "^7.1.0",
|
|
75
|
+
"pretty-ms": "^9.3.0",
|
|
76
|
+
"temporal-polyfill": "^0.3.2",
|
|
77
|
+
"tsd": "^0.33.0"
|
|
78
|
+
},
|
|
79
|
+
"peerDependencies": {
|
|
80
|
+
"typescript": "^5"
|
|
81
|
+
},
|
|
82
|
+
"tsd": {
|
|
83
|
+
"files": [
|
|
84
|
+
"src/**/*.test-d.ts"
|
|
85
|
+
]
|
|
86
|
+
},
|
|
87
|
+
"engines": {
|
|
88
|
+
"node": ">=18"
|
|
89
|
+
},
|
|
90
|
+
"packageManager": "bun@1.3.11"
|
|
91
|
+
}
|