Skip to content

Commit 5c08932

Browse files
authored
prevent-abbreviations: Do not rename exported TypeScript types (#1103)
1 parent 3cabd84 commit 5c08932

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

rules/prevent-abbreviations.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -424,6 +424,13 @@ const isExportedIdentifier = identifier => {
424424
return identifier.parent.parent.type === 'ExportNamedDeclaration';
425425
}
426426

427+
if (
428+
identifier.parent.type === 'TSTypeAliasDeclaration' &&
429+
identifier.parent.id === identifier
430+
) {
431+
return identifier.parent.parent.type === 'ExportNamedDeclaration';
432+
}
433+
427434
return false;
428435
};
429436

test/prevent-abbreviations.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1827,6 +1827,12 @@ runTest.typescript({
18271827
errors: 1
18281828
},
18291829

1830+
// #1102
1831+
noFixingTestCase({
1832+
code: 'export type Props = string',
1833+
errors: createErrors()
1834+
}),
1835+
18301836
// #347
18311837
{
18321838
code: outdent`
@@ -1858,7 +1864,7 @@ runTest.typescript({
18581864
export type PreloadProps<TExtraProps = null> = {}
18591865
`,
18601866
output: outdent`
1861-
export type PreloadProperties<TExtraProperties = null> = {}
1867+
export type PreloadProps<TExtraProperties = null> = {}
18621868
`,
18631869
errors: [...createErrors(), ...createErrors()]
18641870
}

0 commit comments

Comments
 (0)