Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/mean-worlds-go.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'eslint-plugin-devup': patch
---

Support relative
Original file line number Diff line number Diff line change
Expand Up @@ -15395,7 +15395,7 @@ See https://tkdodo.eu/blog/react-query-fa-qs#2-the-queryclient-is-not-stable",
},
"fixable": "code",
"messages": {
"componentFileShouldExportComponent": "컴포넌트 파일은 컴포넌트를 내보내야 합니다.",
"componentFileShouldExportComponent": "컴포넌트 파일은 컴포넌트를 내보내야 합니다. (컴포넌트명: {targetComponentName})",
"componentNameShouldBeFollowDirectoryStructure": "컴포넌트 이름은 디렉토리명 혹은 파일명을 따라야 합니다.",
},
"schema": [],
Expand Down
3 changes: 2 additions & 1 deletion src/rules/app-page/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { ESLintUtils } from '@typescript-eslint/utils'
import { relative } from 'path'

const createRule = ESLintUtils.RuleCreator(
(name) =>
Expand Down Expand Up @@ -27,7 +28,7 @@ export const appPage = createRule({
},
},
create(context) {
const filename = context.physicalFilename
const filename = relative(context.cwd, context.physicalFilename)

if (!/src[/\\]app[/\\]/.test(filename)) return {}
const type = /page\.[j|t]sx?$/.test(filename)
Expand Down
8 changes: 6 additions & 2 deletions src/rules/component/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { ESLintUtils, TSESTree } from '@typescript-eslint/utils'
import { relative } from 'path'

/**
* 문자열을 파스칼 케이스로 변환합니다.
Expand Down Expand Up @@ -37,7 +38,7 @@ export const component = createRule({
componentNameShouldBeFollowDirectoryStructure:
'컴포넌트 이름은 디렉토리명 혹은 파일명을 따라야 합니다.',
componentFileShouldExportComponent:
'컴포넌트 파일은 컴포넌트를 내보내야 합니다.',
'컴포넌트 파일은 컴포넌트를 내보내야 합니다. (컴포넌트명: {targetComponentName})',
},
type: 'problem',
fixable: 'code',
Expand All @@ -47,7 +48,7 @@ export const component = createRule({
},
},
create(context) {
const filename = context.physicalFilename
const filename = relative(context.cwd, context.physicalFilename)

// 검사 대상이 아닌 파일은 빈 객체 반환
const isIncluded = INCLUDE_PATTERNS.some((pattern) =>
Expand Down Expand Up @@ -155,6 +156,9 @@ export const component = createRule({
context.report({
node: program,
messageId: 'componentFileShouldExportComponent',
data: {
targetComponentName,
},
fix(fixer) {
const hasContent = context.sourceCode.text.trim().length > 0
const newline = hasContent ? '\n' : ''
Expand Down