diff --git a/lib/rules/await-interactions.ts b/lib/rules/await-interactions.ts index 37e36ae..0d91315 100644 --- a/lib/rules/await-interactions.ts +++ b/lib/rules/await-interactions.ts @@ -3,13 +3,7 @@ * @author Yann Braga */ -import type { - ImportDeclaration, - CallExpression, - Identifier, - Node, - VariableDeclarator, -} from '@typescript-eslint/types/dist/ast-spec' +import { TSESTree, TSESLint } from '@typescript-eslint/utils' import { createStorybookRule } from '../utils/create-storybook-rule' import { CategoryId } from '../utils/constants' @@ -26,7 +20,6 @@ import { isProgram, isImportSpecifier, } from '../utils/ast' -import { ReportFixFunction } from '@typescript-eslint/experimental-utils/dist/ts-eslint' //------------------------------------------------------------------------------ // Rule Definition @@ -70,7 +63,7 @@ export = createStorybookRule({ 'play', ] - const getMethodThatShouldBeAwaited = (expr: CallExpression) => { + const getMethodThatShouldBeAwaited = (expr: TSESTree.CallExpression) => { const shouldAwait = (name: string) => { return FUNCTIONS_TO_BE_AWAITED.includes(name) || name.startsWith('findBy') } @@ -122,7 +115,7 @@ export = createStorybookRule({ return null } - const getClosestFunctionAncestor = (node: Node): Node | undefined => { + const getClosestFunctionAncestor = (node: TSESTree.Node): TSESTree.Node | undefined => { const parent = node.parent if (!parent || isProgram(parent)) return undefined @@ -137,7 +130,7 @@ export = createStorybookRule({ return getClosestFunctionAncestor(parent) } - const isUserEventFromStorybookImported = (node: ImportDeclaration) => { + const isUserEventFromStorybookImported = (node: TSESTree.ImportDeclaration) => { return ( node.source.value === '@storybook/testing-library' && node.specifiers.find( @@ -149,7 +142,7 @@ export = createStorybookRule({ ) } - const isExpectFromStorybookImported = (node: ImportDeclaration) => { + const isExpectFromStorybookImported = (node: TSESTree.ImportDeclaration) => { return ( node.source.value === '@storybook/jest' && node.specifiers.find( @@ -166,18 +159,21 @@ export = createStorybookRule({ */ let isImportedFromStorybook = true - let invocationsThatShouldBeAwaited = [] as Array<{ node: Node; method: Identifier }> + let invocationsThatShouldBeAwaited = [] as Array<{ + node: TSESTree.Node + method: TSESTree.Identifier + }> return { - ImportDeclaration(node: ImportDeclaration) { + ImportDeclaration(node: TSESTree.ImportDeclaration) { isImportedFromStorybook = isUserEventFromStorybookImported(node) || isExpectFromStorybookImported(node) }, - VariableDeclarator(node: VariableDeclarator) { + VariableDeclarator(node: TSESTree.VariableDeclarator) { isImportedFromStorybook = isImportedFromStorybook && isIdentifier(node.id) && node.id.name !== 'userEvent' }, - CallExpression(node: CallExpression) { + CallExpression(node: TSESTree.CallExpression) { const method = getMethodThatShouldBeAwaited(node) if (method && !isAwaitExpression(node.parent) && !isAwaitExpression(node.parent?.parent)) { invocationsThatShouldBeAwaited.push({ node, method }) @@ -190,7 +186,7 @@ export = createStorybookRule({ const parentFnNeedsAsync = parentFnNode && !('async' in parentFnNode && parentFnNode.async) - const fixFn: ReportFixFunction = (fixer) => { + const fixFn: TSESLint.ReportFixFunction = (fixer) => { const fixerResult = [fixer.insertTextBefore(node, 'await ')] if (parentFnNeedsAsync) { diff --git a/lib/rules/context-in-play-function.ts b/lib/rules/context-in-play-function.ts index 1bebd61..4aefdcf 100644 --- a/lib/rules/context-in-play-function.ts +++ b/lib/rules/context-in-play-function.ts @@ -3,7 +3,7 @@ * @author Yann Braga */ -import type { CallExpression, Node } from '@typescript-eslint/types/dist/ast-spec' +import { TSESTree } from "@typescript-eslint/utils"; import { createStorybookRule } from '../utils/create-storybook-rule' import { CategoryId } from '../utils/constants' @@ -45,7 +45,7 @@ export = createStorybookRule({ // any helper functions should go here or else delete this section - const isPlayFunctionFromAnotherStory = (expr: CallExpression) => { + const isPlayFunctionFromAnotherStory = (expr: TSESTree.CallExpression) => { if ( isTSNonNullExpression(expr.callee) && isMemberExpression(expr.callee.expression) && @@ -67,7 +67,7 @@ export = createStorybookRule({ } // Expression passing an argument called context OR spreading a variable called context - const isNotPassingContextCorrectly = (expr: CallExpression) => { + const isNotPassingContextCorrectly = (expr: TSESTree.CallExpression) => { const firstExpressionArgument = expr.arguments[0] if (!firstExpressionArgument) { @@ -100,10 +100,10 @@ export = createStorybookRule({ // Public //---------------------------------------------------------------------- - let invocationsWithoutProperContext = [] as Node[] + let invocationsWithoutProperContext: TSESTree.Node[] = []; return { - CallExpression(node: CallExpression) { + CallExpression(node: TSESTree.CallExpression) { if (isPlayFunctionFromAnotherStory(node) && isNotPassingContextCorrectly(node)) { invocationsWithoutProperContext.push(node) } diff --git a/lib/rules/csf-component.ts b/lib/rules/csf-component.ts index 5353c09..eeef85b 100644 --- a/lib/rules/csf-component.ts +++ b/lib/rules/csf-component.ts @@ -3,7 +3,7 @@ * @author Yann Braga */ -import { ExportDefaultDeclaration } from '@typescript-eslint/types/dist/ast-spec' +import { TSESTree } from "@typescript-eslint/utils"; import { getMetaObjectExpression } from '../utils' import { CategoryId } from '../utils/constants' import { createStorybookRule } from '../utils/create-storybook-rule' @@ -43,7 +43,7 @@ export = createStorybookRule({ //---------------------------------------------------------------------- return { - ExportDefaultDeclaration(node: ExportDefaultDeclaration) { + ExportDefaultDeclaration(node: TSESTree.ExportDefaultDeclaration) { const meta = getMetaObjectExpression(node, context) if (!meta) { diff --git a/lib/rules/default-exports.ts b/lib/rules/default-exports.ts index da8358e..4776177 100644 --- a/lib/rules/default-exports.ts +++ b/lib/rules/default-exports.ts @@ -4,12 +4,11 @@ */ import path from 'path' -import { Program, Node } from '@typescript-eslint/types/dist/ast-spec' +import { TSESLint, TSESTree } from '@typescript-eslint/utils' import { CategoryId } from '../utils/constants' import { isImportDeclaration, isLiteral, isIdentifier } from '../utils/ast' import { createStorybookRule } from '../utils/create-storybook-rule' -import { ReportFixFunction } from '@typescript-eslint/experimental-utils/dist/ts-eslint' //------------------------------------------------------------------------------ // Rule Definition @@ -42,9 +41,9 @@ export = createStorybookRule({ //---------------------------------------------------------------------- // any helper functions should go here or else delete this section - const getComponentName = (node: Program, filePath: string) => { + const getComponentName = (node: TSESTree.Program, filePath: string) => { const name = path.basename(filePath).split('.')[0] - const imported = node.body.find((stmt: Node) => { + const imported = node.body.find((stmt: TSESTree.Node) => { if ( isImportDeclaration(stmt) && isLiteral(stmt.source) && @@ -77,7 +76,7 @@ export = createStorybookRule({ ExportDefaultDeclaration: function () { hasDefaultExport = true }, - 'Program:exit': function (program: Program) { + 'Program:exit': function (program: TSESTree.Program) { if (!hasDefaultExport && !hasStoriesOfImport) { const componentName = getComponentName(program, context.getFilename()) const firstNonImportStatement = program.body.find((n) => !isImportDeclaration(n)) @@ -88,7 +87,7 @@ export = createStorybookRule({ messageId: 'shouldHaveDefaultExport', } as const - const fix: ReportFixFunction = (fixer) => { + const fix: TSESLint.ReportFixFunction = (fixer) => { const metaDeclaration = componentName ? `export default { component: ${componentName} }\n` : 'export default {}\n' diff --git a/lib/rules/hierarchy-separator.ts b/lib/rules/hierarchy-separator.ts index 384bb45..e6c186c 100644 --- a/lib/rules/hierarchy-separator.ts +++ b/lib/rules/hierarchy-separator.ts @@ -3,7 +3,7 @@ * @author Yann Braga */ -import { MethodDefinition, Property } from '@typescript-eslint/types/dist/ast-spec' +import { TSESTree } from "@typescript-eslint/utils"; import { getMetaObjectExpression } from '../utils' import { isLiteral, isSpreadElement } from '../utils/ast' import { CategoryId } from '../utils/constants' @@ -42,7 +42,7 @@ export = createStorybookRule({ const titleNode = meta.properties.find( (prop) => !isSpreadElement(prop) && 'name' in prop.key && prop.key?.name === 'title' - ) as MethodDefinition | Property | undefined + ) as TSESTree.MethodDefinition | TSESTree.Property | undefined if (!titleNode || !isLiteral(titleNode.value)) { return diff --git a/lib/rules/meta-inline-properties.ts b/lib/rules/meta-inline-properties.ts index 6ee6e05..9b98eb1 100644 --- a/lib/rules/meta-inline-properties.ts +++ b/lib/rules/meta-inline-properties.ts @@ -3,17 +3,14 @@ * @author Yann Braga */ -import { - Identifier, - MethodDefinition, - PrivateIdentifier, - Property, -} from '@typescript-eslint/types/dist/ast-spec' +import { TSESTree } from '@typescript-eslint/utils' import { getMetaObjectExpression } from '../utils' import { CategoryId } from '../utils/constants' import { createStorybookRule } from '../utils/create-storybook-rule' -type TDynamicProperty = (MethodDefinition | Property) & { key: Identifier | PrivateIdentifier } +type TDynamicProperty = (TSESTree.MethodDefinition | TSESTree.Property) & { + key: TSESTree.Identifier | TSESTree.PrivateIdentifier +} //------------------------------------------------------------------------------ // Rule Definition @@ -57,7 +54,7 @@ export = createStorybookRule({ // Helpers //---------------------------------------------------------------------- const isInline = (node: T | TDynamicProperty): node is T => { - if (!('value' in node)) { + if (!(node && typeof node === 'object' && 'value' in node)) { return false } diff --git a/lib/rules/no-title-property-in-meta.ts b/lib/rules/no-title-property-in-meta.ts index c519df6..c7beb0d 100644 --- a/lib/rules/no-title-property-in-meta.ts +++ b/lib/rules/no-title-property-in-meta.ts @@ -3,10 +3,10 @@ * @author Yann Braga */ +import { TSESTree } from "@typescript-eslint/utils"; import { getMetaObjectExpression } from '../utils' import { CategoryId } from '../utils/constants' import { createStorybookRule } from '../utils/create-storybook-rule' -import { Range } from '@typescript-eslint/types/dist/ast-spec' import { isSpreadElement } from '../utils/ast' //------------------------------------------------------------------------------ @@ -57,7 +57,7 @@ export = createStorybookRule({ titleNode.range[1] + 1 ) const hasComma = propertyTextWithExtraCharacter.slice(-1) === ',' - const propertyRange: Range = [ + const propertyRange: TSESTree.Range = [ titleNode.range[0], hasComma ? titleNode.range[1] + 1 : titleNode.range[1], ] diff --git a/lib/rules/no-uninstalled-addons.ts b/lib/rules/no-uninstalled-addons.ts index 665f268..033dcbc 100644 --- a/lib/rules/no-uninstalled-addons.ts +++ b/lib/rules/no-uninstalled-addons.ts @@ -18,7 +18,7 @@ import { isVariableDeclarator, isVariableDeclaration, } from '../utils/ast' -import { Property, ArrayExpression } from '@typescript-eslint/types/dist/ast-spec' +import { TSESTree } from "@typescript-eslint/utils"; //------------------------------------------------------------------------------ // Rule Definition @@ -133,7 +133,7 @@ export = createStorybookRule({ } const extractAllAddonsFromTheStorybookConfig = ( - addonsExpression: ArrayExpression | undefined + addonsExpression: TSESTree.ArrayExpression | undefined ) => { if (addonsExpression?.elements) { // extract all nodes taht are a string inside the addons array @@ -147,9 +147,9 @@ export = createStorybookRule({ const nodesWithAddonsInObj = addonsExpression.elements .map((elem) => (isObjectExpression(elem) ? elem : { properties: [] })) .map((elem) => { - const property: Property = elem.properties.find( + const property: TSESTree.Property = elem.properties.find( (prop) => isProperty(prop) && isIdentifier(prop.key) && prop.key.name === 'name' - ) as Property + ) as TSESTree.Property return isLiteral(property?.value) ? { value: property.value.value, node: property.value } : undefined @@ -166,7 +166,7 @@ export = createStorybookRule({ return { listOfAddons: [], listOfAddonElements: [] } } - function reportUninstalledAddons(addonsProp: ArrayExpression) { + function reportUninstalledAddons(addonsProp: TSESTree.ArrayExpression) { const packageJsonPath = resolve(packageJsonLocation || `./package.json`) let packageJsonObject: Record try { @@ -211,7 +211,7 @@ export = createStorybookRule({ AssignmentExpression: function (node) { if (isObjectExpression(node.right)) { const addonsProp = node.right.properties.find( - (prop): prop is Property => + (prop): prop is TSESTree.Property => isProperty(prop) && isIdentifier(prop.key) && prop.key.name === 'addons' ) @@ -223,7 +223,7 @@ export = createStorybookRule({ ExportDefaultDeclaration: function (node) { if (isObjectExpression(node.declaration)) { const addonsProp = node.declaration.properties.find( - (prop): prop is Property => + (prop): prop is TSESTree.Property => isProperty(prop) && isIdentifier(prop.key) && prop.key.name === 'addons' ) diff --git a/lib/rules/prefer-pascal-case.ts b/lib/rules/prefer-pascal-case.ts index b25cd7e..25cdb85 100644 --- a/lib/rules/prefer-pascal-case.ts +++ b/lib/rules/prefer-pascal-case.ts @@ -3,8 +3,7 @@ * @author Yann Braga */ -import { ASTUtils } from '@typescript-eslint/experimental-utils' -import { ExportNamedDeclaration, Identifier } from '@typescript-eslint/types/dist/ast-spec' +import { ASTUtils, TSESTree } from "@typescript-eslint/utils"; import { IncludeExcludeOptions, isExportStory } from '@storybook/csf' import { getDescriptor, getMetaObjectExpression } from '../utils' @@ -55,7 +54,7 @@ export = createStorybookRule({ .replace(new RegExp(/\w/), (s) => s.toUpperCase()) } - const checkAndReportError = (id: Identifier, nonStoryExportsConfig = {}) => { + const checkAndReportError = (id: TSESTree.Identifier, nonStoryExportsConfig = {}) => { const { name } = id if (!isExportStory(name, nonStoryExportsConfig) || name === '__namedExportsOrder') { return null @@ -103,7 +102,7 @@ export = createStorybookRule({ let meta let nonStoryExportsConfig: IncludeExcludeOptions - let namedExports: Identifier[] = [] + let namedExports: TSESTree.Identifier[] = [] let hasStoriesOfImport = false return { @@ -123,7 +122,7 @@ export = createStorybookRule({ } catch (err) {} } }, - ExportNamedDeclaration: function (node: ExportNamedDeclaration) { + ExportNamedDeclaration: function (node: TSESTree.ExportNamedDeclaration) { // if there are specifiers, node.declaration should be null if (!node.declaration) return diff --git a/lib/rules/story-exports.ts b/lib/rules/story-exports.ts index dd83f48..5006e4d 100644 --- a/lib/rules/story-exports.ts +++ b/lib/rules/story-exports.ts @@ -3,7 +3,6 @@ * @author Yann Braga */ -import type { Program } from '@typescript-eslint/types/dist/ast-spec' import { createStorybookRule } from '../utils/create-storybook-rule' import { CategoryId } from '../utils/constants' @@ -15,7 +14,7 @@ import { } from '../utils' import { isImportDeclaration } from '../utils/ast' import { IncludeExcludeOptions } from '@storybook/csf' -import { ObjectExpression, Identifier } from '@typescript-eslint/types/dist/ast-spec' +import { TSESTree } from "@typescript-eslint/utils"; //------------------------------------------------------------------------------ // Rule Definition @@ -54,8 +53,8 @@ export = createStorybookRule({ let hasStoriesOfImport = false let nonStoryExportsConfig: IncludeExcludeOptions = {} - let meta: ObjectExpression | null - let namedExports: Identifier[] = [] + let meta: TSESTree.ObjectExpression | null + let namedExports: TSESTree.Identifier[] = [] return { ImportSpecifier(node) { @@ -77,7 +76,7 @@ export = createStorybookRule({ ExportNamedDeclaration: function (node) { namedExports.push(...getAllNamedExports(node)) }, - 'Program:exit': function (program: Program) { + 'Program:exit': function (program: TSESTree.Program) { if (hasStoriesOfImport || !meta) { return } diff --git a/lib/rules/use-storybook-expect.ts b/lib/rules/use-storybook-expect.ts index c6bc5dd..a199bc4 100644 --- a/lib/rules/use-storybook-expect.ts +++ b/lib/rules/use-storybook-expect.ts @@ -7,7 +7,7 @@ import { CategoryId } from '../utils/constants' import { isIdentifier, isImportSpecifier } from '../utils/ast' import { createStorybookRule } from '../utils/create-storybook-rule' -import { ImportDeclaration, Identifier } from '@typescript-eslint/types/dist/ast-spec' +import { TSESTree } from "@typescript-eslint/utils"; //------------------------------------------------------------------------------ // Rule Definition @@ -44,7 +44,7 @@ export = createStorybookRule({ // Helpers //---------------------------------------------------------------------- - const isExpectFromStorybookImported = (node: ImportDeclaration) => { + const isExpectFromStorybookImported = (node: TSESTree.ImportDeclaration) => { return ( node.source.value === '@storybook/jest' && node.specifiers.find((spec) => isImportSpecifier(spec) && spec.imported.name === 'expect') @@ -56,7 +56,7 @@ export = createStorybookRule({ //---------------------------------------------------------------------- let isImportingFromStorybookExpect = false - let expectInvocations: Identifier[] = [] + let expectInvocations: TSESTree.Identifier[] = [] return { ImportDeclaration(node) { diff --git a/lib/rules/use-storybook-testing-library.ts b/lib/rules/use-storybook-testing-library.ts index 35cfa8b..98955be 100644 --- a/lib/rules/use-storybook-testing-library.ts +++ b/lib/rules/use-storybook-testing-library.ts @@ -3,15 +3,10 @@ * @author Yann Braga */ -import { - Range, - StringLiteral, - ImportDeclaration, - ImportClause, -} from '@typescript-eslint/types/dist/ast-spec' import { isImportDefaultSpecifier } from '../utils/ast' import { CategoryId } from '../utils/constants' import { createStorybookRule } from '../utils/create-storybook-rule' +import { TSESTree } from "@typescript-eslint/utils"; //------------------------------------------------------------------------------ // Rule Definition @@ -42,7 +37,7 @@ export = createStorybookRule({ //---------------------------------------------------------------------- // Helpers //---------------------------------------------------------------------- - const getRangeWithoutQuotes = (source: StringLiteral): Range => { + const getRangeWithoutQuotes = (source: TSESTree.StringLiteral): TSESTree.Range => { return [ // Not sure how to improve this. If I use node.source.range // it will eat the quotes and we do not want to specify whether the quotes are single or double @@ -51,10 +46,10 @@ export = createStorybookRule({ ] } - const hasDefaultImport = (specifiers: ImportClause[]) => + const hasDefaultImport = (specifiers: TSESTree.ImportClause[]) => specifiers.find((s) => isImportDefaultSpecifier(s)) - const getSpecifiers = (node: ImportDeclaration) => { + const getSpecifiers = (node: TSESTree.ImportDeclaration) => { const { specifiers } = node if (!specifiers[0]) { return null @@ -81,7 +76,7 @@ export = createStorybookRule({ } const text = fullText.substring(start, end) - return { range: [start, end] as Range, text } + return { range: [start, end] as TSESTree.Range, text } } const fixSpecifiers = (specifiersText: string) => { diff --git a/lib/types/index.ts b/lib/types/index.ts index f97019a..5c0017c 100644 --- a/lib/types/index.ts +++ b/lib/types/index.ts @@ -1,4 +1,4 @@ -import { TSESLint } from '@typescript-eslint/experimental-utils' +import { TSESLint } from '@typescript-eslint/utils' import { CategoryId } from '../utils/constants' export type RuleModule = TSESLint.RuleModule<'', []> & { diff --git a/lib/utils/ast.ts b/lib/utils/ast.ts index 9673e60..1292c11 100644 --- a/lib/utils/ast.ts +++ b/lib/utils/ast.ts @@ -1,5 +1,5 @@ -import { AST_NODE_TYPES, TSESTree } from '@typescript-eslint/experimental-utils' -export { ASTUtils } from '@typescript-eslint/experimental-utils' +import { AST_NODE_TYPES, TSESTree } from '@typescript-eslint/utils' +export { ASTUtils } from '@typescript-eslint/utils' const isNodeOfType = (nodeType: NodeType) => diff --git a/lib/utils/create-storybook-rule.ts b/lib/utils/create-storybook-rule.ts index 59a2eea..fa0adc0 100644 --- a/lib/utils/create-storybook-rule.ts +++ b/lib/utils/create-storybook-rule.ts @@ -1,13 +1,12 @@ -import { ESLintUtils } from '@typescript-eslint/experimental-utils' +import { ESLintUtils, TSESLint } from '@typescript-eslint/utils' import { docsUrl } from '../utils' import { StorybookRuleMeta } from '../types' -import { RuleContext, RuleListener } from '@typescript-eslint/experimental-utils/dist/ts-eslint' export function createStorybookRule< TOptions extends readonly unknown[], TMessageIds extends string, - TRuleListener extends RuleListener = RuleListener + TRuleListener extends TSESLint.RuleListener = TSESLint.RuleListener >({ create, meta, @@ -17,7 +16,7 @@ export function createStorybookRule< meta: StorybookRuleMeta defaultOptions: Readonly create: ( - context: Readonly>, + context: Readonly>, optionsWithDefault: Readonly ) => TRuleListener }>) { diff --git a/lib/utils/index.ts b/lib/utils/index.ts index a5ded74..6d3f0b0 100644 --- a/lib/utils/index.ts +++ b/lib/utils/index.ts @@ -1,11 +1,7 @@ import { IncludeExcludeOptions, isExportStory } from '@storybook/csf' -import { - ExportDefaultDeclaration, - ExportNamedDeclaration, - Identifier, - ObjectExpression, -} from '@typescript-eslint/types/dist/ast-spec' -import { ASTUtils } from '@typescript-eslint/experimental-utils' + +import { ASTUtils, TSESTree, TSESLint } from '@typescript-eslint/utils' + import { isFunctionDeclaration, isIdentifier, @@ -15,16 +11,15 @@ import { isVariableDeclaration, isVariableDeclarator, } from './ast' -import { RuleContext } from '@typescript-eslint/experimental-utils/dist/ts-eslint' export const docsUrl = (ruleName: string) => `https://github.com/storybookjs/eslint-plugin-storybook/blob/main/docs/rules/${ruleName}.md` export const getMetaObjectExpression = ( - node: ExportDefaultDeclaration, - context: Readonly> + node: TSESTree.ExportDefaultDeclaration, + context: Readonly> ) => { - let meta: ExportDefaultDeclaration['declaration'] | null = node.declaration + let meta: TSESTree.ExportDefaultDeclaration['declaration'] | null = node.declaration if (isIdentifier(meta)) { const variable = ASTUtils.findVariable(context.getScope(), meta.name) const decl = variable && variable.defs.find((def) => isVariableDeclarator(def.node)) @@ -40,7 +35,7 @@ export const getMetaObjectExpression = ( } export const getDescriptor = ( - metaDeclaration: ObjectExpression, + metaDeclaration: TSESTree.ObjectExpression, propertyName: string ): string[] | RegExp | undefined => { const property = @@ -76,11 +71,11 @@ export const getDescriptor = ( } export const isValidStoryExport = ( - node: Identifier, + node: TSESTree.Identifier, nonStoryExportsConfig: IncludeExcludeOptions ) => isExportStory(node.name, nonStoryExportsConfig) && node.name !== '__namedExportsOrder' -export const getAllNamedExports = (node: ExportNamedDeclaration) => { +export const getAllNamedExports = (node: TSESTree.ExportNamedDeclaration) => { // e.g. `export { MyStory }` if (!node.declaration && node.specifiers) { return node.specifiers.reduce((acc, specifier) => { @@ -88,7 +83,7 @@ export const getAllNamedExports = (node: ExportNamedDeclaration) => { acc.push(specifier.exported) } return acc - }, [] as Identifier[]) + }, [] as TSESTree.Identifier[]) } const decl = node.declaration diff --git a/package.json b/package.json index 991e2b8..65261eb 100644 --- a/package.json +++ b/package.json @@ -46,7 +46,7 @@ }, "dependencies": { "@storybook/csf": "^0.0.1", - "@typescript-eslint/experimental-utils": "^5.45.0", + "@typescript-eslint/utils": "^5.45.0", "requireindex": "^1.1.0", "ts-dedent": "^2.2.0" }, diff --git a/tests/lib/rules/csf-component.test.ts b/tests/lib/rules/csf-component.test.ts index 222eac1..8269db8 100644 --- a/tests/lib/rules/csf-component.test.ts +++ b/tests/lib/rules/csf-component.test.ts @@ -7,7 +7,7 @@ // Requirements //------------------------------------------------------------------------------ -import { AST_NODE_TYPES } from '@typescript-eslint/types' +import { AST_NODE_TYPES } from '@typescript-eslint/utils' import rule from '../../../lib/rules/csf-component' import ruleTester from '../../utils/rule-tester' diff --git a/tests/lib/rules/default-exports.test.ts b/tests/lib/rules/default-exports.test.ts index e313001..073bbf1 100644 --- a/tests/lib/rules/default-exports.test.ts +++ b/tests/lib/rules/default-exports.test.ts @@ -7,7 +7,6 @@ // Requirements //------------------------------------------------------------------------------ -import { AST_NODE_TYPES } from '@typescript-eslint/types' import dedent from 'ts-dedent' import rule from '../../../lib/rules/default-exports' diff --git a/tests/lib/rules/hierarchy-separator.test.ts b/tests/lib/rules/hierarchy-separator.test.ts index 5928b8b..5b1197d 100644 --- a/tests/lib/rules/hierarchy-separator.test.ts +++ b/tests/lib/rules/hierarchy-separator.test.ts @@ -7,7 +7,7 @@ // Requirements //------------------------------------------------------------------------------ -import { AST_NODE_TYPES } from '@typescript-eslint/types' +import { AST_NODE_TYPES } from '@typescript-eslint/utils' import dedent from 'ts-dedent' import rule from '../../../lib/rules/hierarchy-separator' diff --git a/tests/lib/rules/meta-inline-properties.test.ts b/tests/lib/rules/meta-inline-properties.test.ts index 67e1c5a..f893284 100644 --- a/tests/lib/rules/meta-inline-properties.test.ts +++ b/tests/lib/rules/meta-inline-properties.test.ts @@ -7,7 +7,7 @@ // Requirements //------------------------------------------------------------------------------ -import { AST_NODE_TYPES } from '@typescript-eslint/types' +import { AST_NODE_TYPES } from '@typescript-eslint/utils' import dedent from 'ts-dedent' import rule from '../../../lib/rules/meta-inline-properties' diff --git a/tests/lib/rules/no-redundant-story-name.test.ts b/tests/lib/rules/no-redundant-story-name.test.ts index e37eb84..97714a7 100644 --- a/tests/lib/rules/no-redundant-story-name.test.ts +++ b/tests/lib/rules/no-redundant-story-name.test.ts @@ -7,7 +7,7 @@ // Requirements //------------------------------------------------------------------------------ -import { AST_NODE_TYPES } from '@typescript-eslint/types' +import { AST_NODE_TYPES } from '@typescript-eslint/utils' import dedent from 'ts-dedent' import rule from '../../../lib/rules/no-redundant-story-name' diff --git a/tests/lib/rules/no-stories-of.test.ts b/tests/lib/rules/no-stories-of.test.ts index 2f5e509..7f47ea7 100644 --- a/tests/lib/rules/no-stories-of.test.ts +++ b/tests/lib/rules/no-stories-of.test.ts @@ -7,7 +7,7 @@ // Requirements //------------------------------------------------------------------------------ -import { AST_NODE_TYPES } from '@typescript-eslint/types' +import { AST_NODE_TYPES } from '@typescript-eslint/utils' import rule from '../../../lib/rules/no-stories-of' import ruleTester from '../../utils/rule-tester' diff --git a/tests/lib/rules/no-title-property-in-meta.test.ts b/tests/lib/rules/no-title-property-in-meta.test.ts index 81a8e94..a76f8ad 100644 --- a/tests/lib/rules/no-title-property-in-meta.test.ts +++ b/tests/lib/rules/no-title-property-in-meta.test.ts @@ -7,7 +7,7 @@ // Requirements //------------------------------------------------------------------------------ -import { AST_NODE_TYPES } from '@typescript-eslint/types' +import { AST_NODE_TYPES } from '@typescript-eslint/utils' import dedent from 'ts-dedent' import rule from '../../../lib/rules/no-title-property-in-meta' diff --git a/tests/lib/rules/no-uninstalled-addons.test.ts b/tests/lib/rules/no-uninstalled-addons.test.ts index 3be0686..5e2c26b 100644 --- a/tests/lib/rules/no-uninstalled-addons.test.ts +++ b/tests/lib/rules/no-uninstalled-addons.test.ts @@ -7,7 +7,7 @@ // Requirements //------------------------------------------------------------------------------ -import { AST_NODE_TYPES } from '@typescript-eslint/experimental-utils' +import { AST_NODE_TYPES } from '@typescript-eslint/utils' import rule from '../../../lib/rules/no-uninstalled-addons' import ruleTester from '../../utils/rule-tester' diff --git a/tests/lib/rules/prefer-pascal-case.test.ts b/tests/lib/rules/prefer-pascal-case.test.ts index ec7633e..9d2e884 100644 --- a/tests/lib/rules/prefer-pascal-case.test.ts +++ b/tests/lib/rules/prefer-pascal-case.test.ts @@ -7,7 +7,7 @@ // Requirements //------------------------------------------------------------------------------ -import { AST_NODE_TYPES } from '@typescript-eslint/types' +import { AST_NODE_TYPES } from '@typescript-eslint/utils' import dedent from 'ts-dedent' import rule from '../../../lib/rules/prefer-pascal-case' diff --git a/tests/lib/rules/use-storybook-expect.test.ts b/tests/lib/rules/use-storybook-expect.test.ts index 8fbd784..90f6112 100644 --- a/tests/lib/rules/use-storybook-expect.test.ts +++ b/tests/lib/rules/use-storybook-expect.test.ts @@ -7,7 +7,7 @@ // Requirements //------------------------------------------------------------------------------ -import { AST_NODE_TYPES } from '@typescript-eslint/types' +import { AST_NODE_TYPES } from '@typescript-eslint/utils' import dedent from 'ts-dedent' import rule from '../../../lib/rules/use-storybook-expect' diff --git a/tests/lib/rules/use-storybook-testing-library.test.ts b/tests/lib/rules/use-storybook-testing-library.test.ts index ed6112b..51967b5 100644 --- a/tests/lib/rules/use-storybook-testing-library.test.ts +++ b/tests/lib/rules/use-storybook-testing-library.test.ts @@ -7,7 +7,7 @@ // Requirements //------------------------------------------------------------------------------ -import { AST_NODE_TYPES } from '@typescript-eslint/types' +import { AST_NODE_TYPES } from '@typescript-eslint/utils' import rule from '../../../lib/rules/use-storybook-testing-library' import ruleTester from '../../utils/rule-tester' diff --git a/tests/utils/rule-tester.ts b/tests/utils/rule-tester.ts index 1b49670..2c843d7 100644 --- a/tests/utils/rule-tester.ts +++ b/tests/utils/rule-tester.ts @@ -1,5 +1,5 @@ import { resolve } from 'path' -import { TSESLint } from '@typescript-eslint/experimental-utils' +import { TSESLint } from '@typescript-eslint/utils' const DEFAULT_TEST_CASE_CONFIG = { filename: 'MyComponent.stories.js', diff --git a/yarn.lock b/yarn.lock index d568b1f..20275a9 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1655,13 +1655,6 @@ dependencies: "@types/yargs-parser" "*" -"@typescript-eslint/experimental-utils@^5.45.0": - version "5.45.0" - resolved "https://registry.yarnpkg.com/@typescript-eslint/experimental-utils/-/experimental-utils-5.45.0.tgz#b59fea61a855cb2b1fdbd0fb45934a844f4bf870" - integrity sha512-DnRQg5+3uHHt/gaifTjwg9OKbg9/TWehfJzYHQIDJboPEbF897BKDE/qoqMhW7nf0jWRV1mwVXTaUvtB1/9Gwg== - dependencies: - "@typescript-eslint/utils" "5.45.0" - "@typescript-eslint/parser@^5.3.0": version "5.3.0" resolved "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-5.3.0.tgz#7879f15e26d370ed3f653fb7dd06479531ed3ab9" @@ -1724,7 +1717,7 @@ semver "^7.3.7" tsutils "^3.21.0" -"@typescript-eslint/utils@5.45.0": +"@typescript-eslint/utils@^5.45.0": version "5.45.0" resolved "https://registry.yarnpkg.com/@typescript-eslint/utils/-/utils-5.45.0.tgz#9cca2996eee1b8615485a6918a5c763629c7acf5" integrity sha512-OUg2JvsVI1oIee/SwiejTot2OxwU8a7UfTFMOdlhD2y+Hl6memUSL4s98bpUTo8EpVEr0lmwlU7JSu/p2QpSvA== @@ -6045,9 +6038,9 @@ typescript-memoize@^1.0.0-alpha.3: integrity sha512-oJNge1qUrOK37d5Y6Ly2txKeuelYVsFtNF6U9kXIN7juudcQaHJQg2MxLOy0CqtkW65rVDYuTCOjnSIVPd8z3w== typescript@^4.4.4: - version "4.4.4" - resolved "https://registry.npmjs.org/typescript/-/typescript-4.4.4.tgz#2cd01a1a1f160704d3101fd5a58ff0f9fcb8030c" - integrity sha512-DqGhF5IKoBl8WNf8C1gu8q0xZSInh9j1kJJMqT3a94w1JzVaBU4EXOSMrz9yDqMT0xt3selp83fuFMQ0uzv6qA== + version "4.9.3" + resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.9.3.tgz#3aea307c1746b8c384435d8ac36b8a2e580d85db" + integrity sha512-CIfGzTelbKNEnLpLdGFgdyKhG23CKdKgQPOBc+OUNrkJ2vr+KSzsSV5kq5iWhEQbok+quxgGzrAtGWCyU7tHnA== typical@^4.0.0: version "4.0.0"