Skip to content

Commit

Permalink
Upgrade @typescript-eslint/utils to v8.8
Browse files Browse the repository at this point in the history
  • Loading branch information
kasperpeulen committed Oct 10, 2024
1 parent c4e9cec commit 1435cb8
Show file tree
Hide file tree
Showing 10 changed files with 500 additions and 204 deletions.
25 changes: 15 additions & 10 deletions lib/types/index.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
import { TSESLint } from '@typescript-eslint/utils'
import { CategoryId } from '../utils/constants'
import {
RuleRecommendation,
RuleRecommendationAcrossConfigs,
} from '@typescript-eslint/utils/ts-eslint'

export type RuleModule = TSESLint.RuleModule<'', []> & {
meta: { hasSuggestions?: boolean; docs: { recommendedConfig?: 'error' | 'warn' } }
}

// These 2 types are copied from @typescript-eslint/experimental-utils' CreateRuleMeta
// and modified to our needs
export type StorybookRuleMetaDocs<TOptions extends readonly unknown[]> = Omit<
TSESLint.RuleMetaDataDocs<TOptions>,
'url'
> & {
export type StorybookRuleMetaDocs = TSESLint.RuleMetaDataDocs & {
/**
* Whether or not this rule should be excluded from linter config
*/
Expand All @@ -19,15 +20,19 @@ export type StorybookRuleMetaDocs<TOptions extends readonly unknown[]> = Omit<
* Which configs the rule should be part of
*/
categories?: CategoryId[]
}

export type StorybookRuleMeta<
TMessageIds extends string,
TOptions extends readonly unknown[],
> = Omit<TSESLint.RuleMetaData<TMessageIds, TOptions>, 'docs'> & {
docs: StorybookRuleMetaDocs<TOptions>
/**
* If a string config name, which starting config this rule is enabled in.
* If an object, which settings it has enabled in each of those configs.
*/
recommended?: RuleRecommendation | RuleRecommendationAcrossConfigs<unknown[]>
}

export type StorybookRuleMeta<TMessageIds extends string> = TSESLint.RuleMetaData<
TMessageIds,
StorybookRuleMetaDocs
>

// Comment out for testing purposes:
// const docs: StorybookRuleMetaDocs = {
// description: 'bla',
Expand Down
10 changes: 5 additions & 5 deletions lib/utils/create-storybook-rule.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { ESLintUtils, TSESLint } from '@typescript-eslint/utils'

import { docsUrl } from '../utils'
import { StorybookRuleMeta } from '../types'
import { docsUrl } from './index'
import { StorybookRuleMeta, StorybookRuleMetaDocs } from '../types'

export function createStorybookRule<
TOptions extends readonly unknown[],
Expand All @@ -13,20 +13,20 @@ export function createStorybookRule<
...remainingConfig
}: Readonly<{
name: string
meta: StorybookRuleMeta<TMessageIds, TOptions>
meta: StorybookRuleMeta<TMessageIds>
defaultOptions: Readonly<TOptions>
create: (
context: Readonly<TSESLint.RuleContext<TMessageIds, TOptions>>,
optionsWithDefault: Readonly<TOptions>
) => TRuleListener
}>) {
return ESLintUtils.RuleCreator(docsUrl)({
return ESLintUtils.RuleCreator<StorybookRuleMetaDocs>(docsUrl)({
...remainingConfig,
create,
meta: {
...meta,
docs: {
...meta.docs,
...meta.docs!,
},
},
})
Expand Down
11 changes: 6 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"email": "[email protected]"
}
],
"main": "dist/index.js",
"main": "dist/lib/index.js",
"files": [
"dist/**/*",
"README.md"
Expand Down Expand Up @@ -61,14 +61,15 @@
"@types/eslint": "^8.56.2",
"@types/jest": "^29.5.12",
"@types/node": "^18.19.17",
"@types/semver": "^7.5.8",
"@types/requireindex": "^1.2.4",
"@typescript-eslint/eslint-plugin": "^7.15.0",
"@typescript-eslint/parser": "^7.15.0",
"@types/semver": "^7.5.8",
"@typescript-eslint/eslint-plugin": "^8.8.1",
"@typescript-eslint/parser": "^8.8.1",
"@typescript-eslint/rule-tester": "^8.8.1",
"auto": "^11.2.1",
"eslint": "^8.56.0",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-eslint-plugin": "^5.3.0",
"eslint-plugin-eslint-plugin": "^6.2.0",
"eslint-plugin-node": "^11.1.0",
"eslint-plugin-prettier": "^5.1.3",
"husky": "^9.0.11",
Expand Down
Loading

0 comments on commit 1435cb8

Please sign in to comment.