-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement 99% of the toolkit (good baseline)
- Loading branch information
Showing
16 changed files
with
359 additions
and
109 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
import type { ConfigObject, Plugin } from '@steiger/types' | ||
|
||
/** Accepts a plugin as a type parameter and returns the config object for these rules. */ | ||
export type ConfigObjectOf<ThisPlugin> = ThisPlugin extends Plugin<infer Rules> ? ConfigObject<Rules> : never | ||
export type ConfigObjectOf<ThisPlugin> = ThisPlugin extends Plugin<unknown, infer Rules> ? ConfigObject<Rules> : never |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import type { Config, ConfigObject, OptionsForRule, Plugin, Rule, RuleNames, Severity } from '@steiger/types' | ||
|
||
export function enableAllRules<Context, Rules extends Array<Rule>>( | ||
plugin: Plugin<Context, Rules>, | ||
options?: { severity: Exclude<Severity, 'off'> }, | ||
): [Plugin<Context, Rules>, ConfigObject<Rules>] { | ||
return [ | ||
plugin, | ||
{ | ||
rules: Object.fromEntries(plugin.ruleDefinitions.map((rule) => [rule.name, options?.severity ?? 'error'])) as { | ||
[key in RuleNames<Rules>]?: Severity | [Severity, OptionsForRule<Rules, key>] | ||
}, | ||
}, | ||
] | ||
} | ||
|
||
export function createConfigs(configs: Record<string, Config>): Record<string, Config> { | ||
return configs | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,7 @@ | ||
import type { Plugin } from '@steiger/types' | ||
import type { Plugin, Rule } from '@steiger/types' | ||
|
||
export function createPlugin<Rules extends string>(plugin: Plugin<Rules>) { | ||
export function createPlugin<const Context, const Rules extends Array<Rule<Context>>>( | ||
plugin: Plugin<Context, Rules>, | ||
): Plugin<Context, Rules> { | ||
return plugin | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,15 @@ | ||
import { exec } from 'child_process' | ||
import { defineConfig } from 'tsup' | ||
|
||
export default defineConfig({ | ||
entry: ['src/index.ts'], | ||
format: ['esm'], | ||
dts: true, | ||
dts: { | ||
entry: 'src/index.ts', | ||
resolve: true, | ||
}, | ||
treeshake: true, | ||
clean: true, | ||
esbuildOptions(options) { | ||
options.define = { 'import.meta.vitest': 'undefined' } | ||
}, | ||
onSuccess: async () => { | ||
exec('tsc --emitDeclarationOnly') | ||
}, | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.