diff --git a/.changeset/mean-worlds-go.md b/.changeset/mean-worlds-go.md new file mode 100644 index 0000000..1f7171b --- /dev/null +++ b/.changeset/mean-worlds-go.md @@ -0,0 +1,5 @@ +--- +'eslint-plugin-devup': patch +--- + +Support relative diff --git a/src/configs/__tests__/__snapshots__/recommended.test.ts.snap b/src/configs/__tests__/__snapshots__/recommended.test.ts.snap index 0230f3c..670f746 100644 --- a/src/configs/__tests__/__snapshots__/recommended.test.ts.snap +++ b/src/configs/__tests__/__snapshots__/recommended.test.ts.snap @@ -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": [], diff --git a/src/rules/app-page/index.ts b/src/rules/app-page/index.ts index eacf10d..408e438 100644 --- a/src/rules/app-page/index.ts +++ b/src/rules/app-page/index.ts @@ -1,4 +1,5 @@ import { ESLintUtils } from '@typescript-eslint/utils' +import { relative } from 'path' const createRule = ESLintUtils.RuleCreator( (name) => @@ -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) diff --git a/src/rules/component/index.ts b/src/rules/component/index.ts index 7a87e9e..90b1352 100644 --- a/src/rules/component/index.ts +++ b/src/rules/component/index.ts @@ -1,4 +1,5 @@ import { ESLintUtils, TSESTree } from '@typescript-eslint/utils' +import { relative } from 'path' /** * 문자열을 파스칼 케이스로 변환합니다. @@ -37,7 +38,7 @@ export const component = createRule({ componentNameShouldBeFollowDirectoryStructure: '컴포넌트 이름은 디렉토리명 혹은 파일명을 따라야 합니다.', componentFileShouldExportComponent: - '컴포넌트 파일은 컴포넌트를 내보내야 합니다.', + '컴포넌트 파일은 컴포넌트를 내보내야 합니다. (컴포넌트명: {targetComponentName})', }, type: 'problem', fixable: 'code', @@ -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) => @@ -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' : ''