File tree Expand file tree Collapse file tree 4 files changed +18
-3
lines changed Expand file tree Collapse file tree 4 files changed +18
-3
lines changed Original file line number Diff line number Diff line change 1+ ---
2+ ' eslint-plugin-devup ' : patch
3+ ---
4+
5+ Support relative
Original file line number Diff line number Diff line change 11import { ESLintUtils } from '@typescript-eslint/utils'
2+ import { relative } from 'path'
23
34const 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 ( ! / s r c [ / \\ ] a p p [ / \\ ] / . test ( filename ) ) return { }
3334 const type = / p a g e \. [ j | t ] s x ? $ / . test ( filename )
Original file line number Diff line number Diff line change @@ -53,6 +53,11 @@ describe('component rule', () => {
5353 code : '' ,
5454 filename : 'src/app/404.tsx' ,
5555 } ,
56+ {
57+ // in linux
58+ code : '' ,
59+ filename : '/app/apps/demo/src/A.tsx' ,
60+ } ,
5661 {
5762 code : 'export function TestComponent(){return <Row><Col></Col></Row>}' ,
5863 filename : 'src/components/test-component.tsx' ,
Original file line number Diff line number Diff line change 11import { 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' : ''
You can’t perform that action at this time.
0 commit comments