Skip to content

Commit 7421dc3

Browse files
authored
Merge pull request #24 from dev-five-git/fix-relative
Support relative
2 parents 22e5f21 + a647ba2 commit 7421dc3

File tree

4 files changed

+14
-4
lines changed

4 files changed

+14
-4
lines changed

.changeset/mean-worlds-go.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'eslint-plugin-devup': patch
3+
---
4+
5+
Support relative

src/configs/__tests__/__snapshots__/recommended.test.ts.snap

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15395,7 +15395,7 @@ See https://tkdodo.eu/blog/react-query-fa-qs#2-the-queryclient-is-not-stable",
1539515395
},
1539615396
"fixable": "code",
1539715397
"messages": {
15398-
"componentFileShouldExportComponent": "컴포넌트 파일은 컴포넌트를 내보내야 합니다.",
15398+
"componentFileShouldExportComponent": "컴포넌트 파일은 컴포넌트를 내보내야 합니다. (컴포넌트명: {targetComponentName})",
1539915399
"componentNameShouldBeFollowDirectoryStructure": "컴포넌트 이름은 디렉토리명 혹은 파일명을 따라야 합니다.",
1540015400
},
1540115401
"schema": [],

src/rules/app-page/index.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { ESLintUtils } from '@typescript-eslint/utils'
2+
import { relative } from 'path'
23

34
const createRule = ESLintUtils.RuleCreator(
45
(name) =>
@@ -27,7 +28,7 @@ export const appPage = createRule({
2728
},
2829
},
2930
create(context) {
30-
const filename = context.physicalFilename
31+
const filename = relative(context.cwd, context.physicalFilename)
3132

3233
if (!/src[/\\]app[/\\]/.test(filename)) return {}
3334
const type = /page\.[j|t]sx?$/.test(filename)

src/rules/component/index.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { ESLintUtils, TSESTree } from '@typescript-eslint/utils'
2+
import { relative } from 'path'
23

34
/**
45
* 문자열을 파스칼 케이스로 변환합니다.
@@ -37,7 +38,7 @@ export const component = createRule({
3738
componentNameShouldBeFollowDirectoryStructure:
3839
'컴포넌트 이름은 디렉토리명 혹은 파일명을 따라야 합니다.',
3940
componentFileShouldExportComponent:
40-
'컴포넌트 파일은 컴포넌트를 내보내야 합니다.',
41+
'컴포넌트 파일은 컴포넌트를 내보내야 합니다. (컴포넌트명: {targetComponentName})',
4142
},
4243
type: 'problem',
4344
fixable: 'code',
@@ -47,7 +48,7 @@ export const component = createRule({
4748
},
4849
},
4950
create(context) {
50-
const filename = context.physicalFilename
51+
const filename = relative(context.cwd, context.physicalFilename)
5152

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

0 commit comments

Comments
 (0)