Skip to content

Commit

Permalink
chore: add extensions for import
Browse files Browse the repository at this point in the history
  • Loading branch information
kazupon committed Sep 3, 2024
1 parent c19ec45 commit 27e42e5
Show file tree
Hide file tree
Showing 107 changed files with 748 additions and 562 deletions.
25 changes: 18 additions & 7 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
import {
comments,
defineConfig,
imports,
javascript,
comments,
typescript,
jsonc,
unicorn,
react,
regexp,
toml,
typescript,
unicorn,
vue,
react,
// svelte,
yaml,
toml
yaml
} from '@kazupon/eslint-config'

export default defineConfig(
Expand Down Expand Up @@ -40,7 +41,17 @@ export default defineConfig(
// TODO:
// sometimes, Resolving `parserOptions.project` is not working in `.svelte` files.
// extraFileExtensions: ['.vue', '.svelte']
extraFileExtensions: ['.vue']
extraFileExtensions: ['.vue'],
rules: {
'@typescript-eslint/consistent-type-imports': ['error', { disallowTypeAnnotations: false }]
}
}),
imports({
typescript: true,
rules: {
'import-x/first': 'error',
'import-x/extensions': ['error', 'always', { ignorePackages: true }]
}
}),
jsonc({
json: true,
Expand Down
5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,13 @@
"watch:unplugin": "pnpm run --filter=./packages/unplugin-svelte watch"
},
"devDependencies": {
"@kazupon/eslint-config": "^0.15.0",
"@kazupon/eslint-config": "^0.17.0",
"@kazupon/prettier-config": "^0.1.1",
"@types/node": "^20.14.10",
"bumpp": "^9.5.2",
"eslint": "^9.9.0",
"eslint-import-resolver-typescript": "^3.6.3",
"eslint-plugin-import-x": "^4.1.1",
"eslint-plugin-jsonc": "^2.16.0",
"eslint-plugin-react": "^7.35.0",
"eslint-plugin-react-hooks": "^4.6.2",
Expand All @@ -63,6 +65,7 @@
"eslint-plugin-svelte": "^2.43.0",
"eslint-plugin-toml": "^0.11.1",
"eslint-plugin-unicorn": "^54.0.0",
"eslint-plugin-unused-imports": "^4.1.3",
"eslint-plugin-vue": "^9.27.0",
"eslint-plugin-yml": "^1.14.0",
"gh-changelogen": "^0.2.8",
Expand Down
4 changes: 2 additions & 2 deletions packages/jsx-compiler/src/compile.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { describe, test, expect } from 'vitest'
import { parse } from '@babel/parser'
import { compile } from './compile'
import { describe, expect, test } from 'vitest'
import { compile } from './compile.ts'

const jsxCode = `
(<button onClick={increment}>
Expand Down
12 changes: 6 additions & 6 deletions packages/jsx-compiler/src/compile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,27 +5,27 @@
// Repository url: https://github.com/unplugin/unplugin-vue-jsx-vapor
// Code url: https://github.com/unplugin/unplugin-vue-jsx-vapor/tree/main/src/core/compiler

import { parse } from '@babel/parser'
import { ErrorCodes, createCompilerError, defaultOnError } from '@vue-vapor/compiler-dom'
import { generate } from '@vue-vapor/compiler-vapor'
import { parse } from '@babel/parser'
import { extend, isString } from '@vue-vapor/shared'
import { IRNodeTypes } from './ir/index.ts'
import { transform } from './transform.ts'
import {
transformChildren,
transformElement,
transformText,
transformVBind,
transformVOn
} from './transforms'
import { transform } from './transform'
import { IRNodeTypes } from './ir'
} from './transforms/index.ts'

import type {
CompilerOptions as BaseCompilerOptions,
VaporCodegenResult as BaseVaporCodegenResult,
RootIRNode as VaporRootIRNode
} from '@vue-vapor/compiler-vapor'
import type { RootIRNode, RootNode, JSXElement, JSXFragment, BabelProgram } from './ir'
import type { HackOptions, NodeTransform, DirectiveTransform } from './transforms'
import type { BabelProgram, JSXElement, JSXFragment, RootIRNode, RootNode } from './ir/index.ts'
import type { DirectiveTransform, HackOptions, NodeTransform } from './transforms/index.ts'

export interface VaporCodegenResult extends Omit<BaseVaporCodegenResult, 'ast'> {
ast: RootIRNode
Expand Down
12 changes: 6 additions & 6 deletions packages/jsx-compiler/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
// SPDX-License-Identifier: MIT
// Modifier: kazuya kawaguchi (a.k.a. kazupon)

export * from './types'
export * from './ir'
export * from './transforms'
export * from './transform'
export * from './errors'
export * from './compile'
export * from './compile.ts'
export * from './errors.ts'
export * from './ir/index.ts'
export * from './transform.ts'
export * from './transforms/index.ts'
export * from './types.ts'
6 changes: 3 additions & 3 deletions packages/jsx-compiler/src/ir/component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@
// Repository url: https://github.com/unplugin/unplugin-vue-jsx-vapor
// Code url: https://github.com/unplugin/unplugin-vue-jsx-vapor/tree/main/src/core/compiler

import { IRDynamicPropsKind } from '@vue-vapor/compiler-vapor'
import type { IRDynamicPropsKind } from '@vue-vapor/compiler-vapor'

import type { SimpleExpressionNode } from '@vue-vapor/compiler-dom'
import type { BlockIRNode, IRFor } from './nodes'
import type { DirectiveTransformResult } from '../transforms'
import type { DirectiveTransformResult } from '../transforms/index.ts'
import type { BlockIRNode, IRFor } from './nodes.ts'

// props
export interface IRProp extends Omit<DirectiveTransformResult, 'value'> {
Expand Down
6 changes: 3 additions & 3 deletions packages/jsx-compiler/src/ir/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// SPDX-License-Identifier: MIT
// Author: kazuya kawaguchi (a.k.a. kazupon)

export * from './nodes'
export * from './component'
export * from './jsx'
export * from './component.ts'
export * from './jsx.ts'
export * from './nodes.ts'
14 changes: 7 additions & 7 deletions packages/jsx-compiler/src/ir/jsx.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@
// Author: kazuya kawaguchi (a.k.a. kazupon)

export type {
CallExpression as BabelCallExpression,
Expression as BabelExpression,
Node as BabelNode,
Program as BabelProgram,
SourceLocation as BabelSourceLocation,
JSXAttribute,
JSXElement,
JSXFragment,
JSXText,
JSXExpressionContainer,
JSXFragment,
JSXSpreadAttribute,
Node as BabelNode,
Expression as BabelExpression,
Program as BabelProgram,
CallExpression as BabelCallExpression,
SourceLocation as BabelSourceLocation
JSXText
} from '@babel/types'
3 changes: 1 addition & 2 deletions packages/jsx-compiler/src/ir/nodes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,8 @@
// Repository url: https://github.com/unplugin/unplugin-vue-jsx-vapor
// Code url: https://github.com/unplugin/unplugin-vue-jsx-vapor/tree/main/src/core/compiler

import { IRNodeTypes } from '@vue-vapor/compiler-vapor'
import type { IRNodeTypes, IRDynamicInfo } from '@vue-vapor/compiler-vapor'

import type { IRDynamicInfo } from '@vue-vapor/compiler-vapor'
import type {
BindingTypes,
CompoundExpressionNode,
Expand Down
8 changes: 4 additions & 4 deletions packages/jsx-compiler/src/transform.test.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { vi, test, expect } from 'vitest'
import { parse } from '@babel/parser'
import { IRNodeTypes } from './ir'
import { transform } from './transform'
import { expect, test, vi } from 'vitest'
import { IRNodeTypes } from './ir/index.ts'
import { transform } from './transform.ts'

import type { RootNode, JSXElement, JSXFragment } from './ir'
import type { JSXElement, JSXFragment, RootNode } from './ir/index.ts'

function getRootNodeAst(source: string): RootNode {
const {
Expand Down
10 changes: 5 additions & 5 deletions packages/jsx-compiler/src/transform.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@
// Code url: https://github.com/unplugin/unplugin-vue-jsx-vapor/tree/main/src/core/compiler

import { isArray } from '@vue-vapor/shared'
import { IRNodeTypes } from './ir'
import { newBlock } from './transforms/utils'
import { TransformContext } from './transforms'
import { IRNodeTypes } from './ir/index.ts'
import { TransformContext } from './transforms/index.ts'
import { newBlock } from './transforms/utils.ts'

import type { RootIRNode, RootNode, BlockIRNode } from './ir'
import type { NodeTransform, TransformOptions } from './transforms'
import type { BlockIRNode, RootIRNode, RootNode } from './ir/index.ts'
import type { NodeTransform, TransformOptions } from './transforms/index.ts'

// AST (Babel) -> IR
export function transform(node: RootNode, options: TransformOptions = {}): RootIRNode {
Expand Down
12 changes: 6 additions & 6 deletions packages/jsx-compiler/src/transforms/_utils.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import { parse } from '@babel/parser'
import { generate } from '@vue-vapor/compiler-vapor'
import { transform } from '../transform'
import { IRNodeTypes } from '../ir'
import { IRNodeTypes } from '../ir/index.ts'
import { transform } from '../transform.ts'

import type {
RootIRNode as VaporRootIRNode,
CompilerOptions as VaporCompilerOptions
CompilerOptions as VaporCompilerOptions,
RootIRNode as VaporRootIRNode
} from '@vue-vapor/compiler-vapor'
import type { CompilerOptions } from '../compile'
import type { RootNode, JSXElement, JSXFragment } from '../ir'
import type { CompilerOptions } from '../compile.ts'
import type { JSXElement, JSXFragment, RootNode } from '../ir/index.ts'

export const DEFAULT_OPTIONS: CompilerOptions = {
prefixIdentifiers: true
Expand Down
20 changes: 10 additions & 10 deletions packages/jsx-compiler/src/transforms/context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,26 +5,26 @@
// Repository url: https://github.com/unplugin/unplugin-vue-jsx-vapor
// Code url: https://github.com/unplugin/unplugin-vue-jsx-vapor/tree/main/src/core/compiler

import { NOOP, extend, EMPTY_OBJ } from '@vue-vapor/shared'
import { defaultOnError, defaultOnWarn } from '@vue-vapor/compiler-dom'
import { newDynamic, isConstantExpression } from './utils'
import { DynamicFlag } from '../ir'
import { EMPTY_OBJ, NOOP, extend } from '@vue-vapor/shared'
import { DynamicFlag } from '../ir/index.ts'
import { isConstantExpression, newDynamic } from './utils.ts'

import type {
CompilerCompatOptions,
SimpleExpressionNode,
TransformOptions as BaseTransformOptions,
CommentNode,
TransformOptions as BaseTransformOptions
CompilerCompatOptions,
SimpleExpressionNode
} from '@vue-vapor/compiler-dom'
import type {
RootNode,
RootIRNode,
BlockIRNode,
OperationNode,
IRDynamicInfo,
IRSlots,
JSXElement,
JSXFragment
JSXFragment,
OperationNode,
RootIRNode,
RootNode
} from '../ir'
import type { HackOptions } from './types'

Expand Down
16 changes: 8 additions & 8 deletions packages/jsx-compiler/src/transforms/index.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
// SPDX-License-Identifier: MIT
// Author: kazuya kawaguchi (a.k.a. kazupon)

export * from './types'
export * from './context'
export * from './utils'
export * from './transformChildren'
export * from './transformElement'
export * from './transformText'
export * from './vBind'
export * from './vOn'
export * from './context.ts'
export * from './transformChildren.ts'
export * from './transformElement.ts'
export * from './transformText.ts'
export * from './types.ts'
export * from './utils.ts'
export * from './vBind.ts'
export * from './vOn.ts'
10 changes: 5 additions & 5 deletions packages/jsx-compiler/src/transforms/transformChildren.test.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { describe, expect, test } from 'vitest'
import { makeCompile } from './_utils'
import { transformChildren } from './transformChildren'
import { transformElement } from './transformElement'
import { transformText } from './transformText'
import { compile as vaporCompile } from '@vue-vapor/compiler-vapor'
import { describe, expect, test } from 'vitest'
import { makeCompile } from './_utils.ts'
import { transformChildren } from './transformChildren.ts'
import { transformElement } from './transformElement.ts'
import { transformText } from './transformText.ts'

const compile = makeCompile({
prefixIdentifiers: false,
Expand Down
12 changes: 6 additions & 6 deletions packages/jsx-compiler/src/transforms/transformChildren.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@
// Repository url: https://github.com/unplugin/unplugin-vue-jsx-vapor
// Code url: https://github.com/unplugin/unplugin-vue-jsx-vapor/tree/main/src/core/compiler

import { isComponentNode } from './utils'
import { IRNodeTypes, DynamicFlag } from '../ir'
import { transformNode } from '../transform'
import { DynamicFlag, IRNodeTypes } from '../ir/index.ts'
import { transformNode } from '../transform.ts'
import { isComponentNode } from './utils.ts'

import type { BabelNode, IRDynamicInfo } from '../ir'
import type { NodeTransform } from './types'
import type { TransformContext } from './context'
import type { BabelNode, IRDynamicInfo } from '../ir/index.ts'
import type { TransformContext } from './context.ts'
import type { NodeTransform } from './types.ts'

export const transformChildren: NodeTransform = (node, context) => {
const isFragment =
Expand Down
12 changes: 6 additions & 6 deletions packages/jsx-compiler/src/transforms/transformComment.test.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { expect, test } from 'vitest'
import { makeCompile } from './_utils'
import { transformComment } from './transformComment'
import { transformElement } from './transformElement'
import { transformChildren } from './transformChildren'
import { transformText } from './transformText'
import { compile as vaporCompile } from '@vue-vapor/compiler-vapor'
import { expect, test } from 'vitest'
import { makeCompile } from './_utils.ts'
import { transformChildren } from './transformChildren.ts'
import { transformComment } from './transformComment.ts'
import { transformElement } from './transformElement.ts'
import { transformText } from './transformText.ts'

const compileWithCommentTransform = makeCompile({
nodeTransforms: [transformText, transformChildren, transformElement, transformComment]
Expand Down
2 changes: 1 addition & 1 deletion packages/jsx-compiler/src/transforms/transformComment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
// import { DynamicFlag, IRNodeTypes, BabelNode } from '../ir'

// import type { TransformContext } from './context'
import type { NodeTransform } from './types'
import type { NodeTransform } from './types.ts'
// import type { JSXFragment, JSXElement } from '../ir'

export const transformComment: NodeTransform = (_node, _context) => {
Expand Down
14 changes: 7 additions & 7 deletions packages/jsx-compiler/src/transforms/transformElement.test.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { describe, expect, test } from 'vitest'
import { makeCompile } from './_utils'
import { transformElement } from './transformElement'
import { transformChildren } from './transformChildren'
import { transformText } from './transformText'
import { IRNodeTypes } from '../ir'
import { BindingTypes, NodeTypes } from '@vue-vapor/compiler-dom'
import { compile as vaporCompile } from '@vue-vapor/compiler-vapor'
import { NodeTypes, BindingTypes } from '@vue-vapor/compiler-dom'
import { describe, expect, test } from 'vitest'
import { IRNodeTypes } from '../ir/index.ts'
import { makeCompile } from './_utils.ts'
import { transformChildren } from './transformChildren.ts'
import { transformElement } from './transformElement.ts'
import { transformText } from './transformText.ts'

import type { BindingMetadata } from '@vue-vapor/compiler-dom'

Expand Down
Loading

0 comments on commit 27e42e5

Please sign in to comment.